OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Robinhansen on 19 May 2005, 15:02:21
-
I'm playing some coop mp-games at the moment were each player are in command of up to 12 soldiers pr. platoon. Each commander has severel specific "things" in the actionmenu. Every time the player dies he respawns as the 2IC and so on - Is it possible to handle over these "things" in the actionmenu from the dead commander to the next player :D
-
use something like the following script
#START
@! alive leader groupname
remove all the units actions
@ alive leader groupname
_leader = leader groupname
?!(local _leader):exit
_leader addaction.............................. etc etc
goto "START
the use of the @ sign calls for high cpu usage
you could also use the following, more efficient
#START
~0.5
?(! alive leader groupname): goto "REMOVEACTIONS"
goto "START"
#REMOVEACTIONS
remove all the units actions
_leader = leader groupname
?!(local _leader):exit
_leader addaction.............................. etc etc
goto "START"
-
Hm...okay! The group is called grp 14. The "grp14 = group this" tag is written in all the groupmembers initfield but NOT in the leaders field for a reason. The leader is named eng and the actions in the actionmenu is called ability. this is how the players initfield looks like:
ability = eng addaction ["Engineer abilities", "eng\abilities.sqs"]
and this is how the script looks like
#START
@! alive leader grp14
removeaction ability
@ alive leader grp14
_leader = leader grp14
?!(local _leader):exit
_leader ability = addaction ["Engnieer abiliies","eng\abilities.sqs"]
goto "START
#START
~0.5
?(! alive leader grp14): goto "REMOVEACTIONS"
goto "START"
#REMOVEACTIONS
removeaction ability
_leader = leader grp14
?!(local _leader):exit
_leader ability = addaction ["Engnieer abiliies","eng\abilities.sqs"]
goto "START"
But when I run the script I get this errormessage:
'removeaction #ability': error unknown operator ability
What shall I do different?
-
#START
@! alive (leader grp14)
(leader grp14) removeaction ability
@ alive (leader grp14)
_leader = leader grp14
?!(local _leader):exit
ability = _leader addaction ["Engnieer abiliies","eng\abilities.sqs"]
goto "START2"
#START2
~0.5
?(! alive (leader grp14)): goto "REMOVEACTIONS"
goto "START2"
#REMOVEACTIONS
_leader removeaction ability
_leader = leader grp14
?!(local _leader):exit
ability = _leader addaction ["Engnieer abiliies","eng\abilities.sqs"]
goto "START"
There, dunno if I fixed it right :P and don't know if you need all the () around leader grp14, but they don't do any harm :P
1: you can't have "#START" 2 places.
2: to remove a action you gotta use
unitname removeaction action
so not
removeaction ability
but
_leader removeaction ability
3: to add a action you write
actionname = unitname addaction ["Text","script.sqs"]
so not
_leader ability = addaction ["Engnieer abiliies","eng\abilities.sqs"]
but
ability = _leader addaction ["Engnieer abiliies","eng\abilities.sqs"]
Many quotes :o
Dunno if it's all right, but I hope so :P
oh, and btw, you could only use this part of the script:
#START
~0.5
?(! alive (leader grp14)): goto "REMOVEACTIONS"
goto "START"
#REMOVEACTIONS
_leader removeaction ability
_leader = leader grp14
?!(local _leader):exit
ability = _leader addaction ["Engnieer abiliies","eng\abilities.sqs"]
goto "START"
but, since the script exits for everyone who is not leader (?!(local _leader):exit), the script won't work when the new leader dies...cause then the script would only run on the leader, and when he dies, the script exits from him too, and it doesn't run anymore...bah, actions in MP sucks :-\