OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: FiLL2d on 03 Jul 2006, 01:25:10
-
Hi, glad to see the site back up! I missed it :(
I was wondering if anyone can look through this script and give me a solution as to why the player that activates arrest.sqs can only see the hints, I'm not sure but I think I may need to use global/public variables?? If thats the case can you show me where to use them ???
The menu for arrest is in the init field of a west soldier.
cop1 addaction ["Arrest","arrest.sqs"];
----arrest.sqs--------------------------------------------
_unit = _this select 0
? (cop1 == Player) : Goto "arrest"
? (cop2 == Player) : Goto "arrest"
? (cop3 == Player) : Goto "arrest"
? (cop4 == Player) : Goto "arrest"
? (cop5 == Player) : Goto "arrest"
#arrest
? (civ1 distance _unit < 10) : Goto "civ1arrest"
exit
#civ1arrest
[civ1, "2.5min"] exec "pristime.sqs"
-------------------------------------------------------------
----pristime.sqs------------------------------------------
_unit = _this select 0
_seetime = _this select 1
;jail
_capture = priscapture
_release = prisrelease
;secs
_1sec = 150
_2sec = 300
_3sec = 450
_4sec = 600
;mins
_1min = 2.5
_2min = 5
_3min = 7.5
_4min = 10
goto _seetime
#2.5min
_unit setpos getpos _capture
hint (format ["%1 has been sent to jail for %2 minutes", name unit, _1min])
~ _1sec
? (_unit distance _capture < 10) : Goto "release"
hint format ["%1 was due for release, but has since escaped", name _unit]
exit
#release
hint format ["%1 has been released ", name _unit]
_unit setpos getpos _release
-------------------------------------------------------------
-
addactions are local
therefore the script that it runs is local to the unit that initiated the addaction
your addaction script then calls for the pristime.sqs to run
this script is also only run on the machine that initiated the addaction
if you want a message to be seen by all, then replace the hint format with a custom radio message that needs to be defined in the description.ext
alternatively have a series of repeating triggers waiting on boolean conditions that run a simple script for your hint/titletext commands
eg to have all clients see
hint (format ["%1 has been sent to jail for %2 minutes", name unit, _1min])
have your addaction script publicvariable
a) the unit
tx_prisoner = _unit
b) the time period
tx_time = _1sec
c) the boolean that activates the message trigger
tx_messageA = true
{publicvariable _x}foreach ["tx_prisoner", "tx_time","tx_messageA"]
have your trigger
condition: tx_messageA, repeating
that on activation runs
[] exec messageA.sqs
messageA.sqs
hint (format ["%1 has been sent to jail for %2 minutes", name tx_prisoner, tx_time])
(leader group player) groupchat format [" << MESSAGE >> "%1 has been sent to jail for %2 minutes", name tx_prisoner, tx_time]
tx_messageA = false
NB>> to use a boolean in a trigger, you should initialise it in the INIT.sqs
eg
INI.SQS
tx_messageA = false
I wouldnt particularly see this as an advanced problem.
If you really wanna go the full hog, then implement COC network services, there is a function in it, that allows you to send strings across the network (BIS Publicvariable command wont do this)
-
aha, many thanks for your post. One thing though
have your addaction script publicvariable
How'd i make an addaction a publicvariable ? Thats the bit i didn't understand.
-
you'll kick yourself..
goes along the lines of
"publicvariable variable"
me thinks
-
the addaction is placed on a unit in the unit's init field in the mission editor, so everyone will be able to access the addaction, if they get close enough to the unit that has it attached.
however the script it runs will only be run on the players machine that ran the addaction
-
hm, ok I'm usng an addaction just local to that player now. As I don't want people sharing his actions...so
? player == cop1 : cop1arrest = player addAction ["Arrest","arrest.sqs"]
I understand that the code inside arrest.sqs will be local, so I need to use triggers that activate on bolean to display the information globally?
a) the unit
tx_prisoner = _unit
b) the time period
tx_time = _1sec
c) the boolean that activates the message trigger
tx_messageA = true
{publicvariable _x}foreach ["tx_prisoner", "tx_time","tx_messageA"]
does 'c)' belong in a tigger?
Please can you tell me which bits of code go where because I'm abit confused, thanks.
-
have your addaction script publicvariable
a) the unit
tx_prisoner = _unit
b) the time period
tx_time = _1sec
c) the boolean that activates the message trigger
tx_messageA = true
{publicvariable _x}foreach ["tx_prisoner", "tx_time","tx_messageA"]
it belongs in the addaction script
the trigger setup would be as follows
Activation, Nobody repeating
condition: tx_messageA
On activation: "" exec "messageA.sqs"
-
thanks, i got the global hint working, although it doesnt remember the player name and doesnt show it, just shows 2 blank spaces instead of the name. I've attached it if you can look at it.
Thanks for helping me, I appreciate it very much
EDIT: fixed, thanks all.
-
please only attach zip folders when submitting attachments.