OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: RedHouse on 22 Jun 2005, 21:51:38
-
Ok I have a 2 problems:
a) When a player respawns how do I Add an action to him, from and killed event handler script.
b) does the respawned unit still have the same name, because I cannot get a scoring system to work because of it. Lets say i named a unit w1 in the editor, after tht unit respawns is he still called w1? And iff not is their anyway i can name the new unit w1?
-
when you respawn using normal respawn eg player v player type (not group respawn) you actually spawn into a new unit
the only thing that remains the same is the class of unit and the unit name,
hint format"%1"_name W1]
so if you are going to do your own scoring system then you would have to
add it using that variable
adding or removing an action via an addeventhandler killed is easy
INIT.SQS
player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]
tx_myaction = Player addaction ["Do My action","myaction.sqs"]
playerkilled.sqs]
Player removeaction tx_myaction
player removeAllEventHandlers "Killed"
@alive player
player addEventHandler ["killed", {_this exec "tx_sys\Client\playerkilled.sqs"}]
tx_myaction = Player addaction ["Do My action","myaction.sqs"]
If you offered some more insight into what you wanted your scoring system to achieve then i may be able to come up with a different alternative
-
well ive already tried that but player addAction & addEventHandler seems to just add it to your dead body. And are you sure the new unit keeps the same name?
-
And are you sure the new unit keeps the same name?
for ai units yes and the player unit obviously retains the players name
One more thing that remains the same is the group that the unit was in
try it
run the following code
Mission Editor
Create 2 units, one which you will play and another unit which is "Playable" and link it so its in your group
name this additional unit "W1"
and create a marker called respawn_west
Description.EXT
respawn=3
respawndelay=2
disabledAI = 0
Init .sqs
tx_Oldname = name W1
{_x addEventHandler ["killed", {_this exec "killed.sqs"}]}foreach units group player
Killed .sqs
{_x removealleventhandlers "killed"}foreach units group player
~5
{_x addEventHandler ["killed", {_this exec "killed.sqs"}]}foreach units group player
_array =[]
{_array = _array + [name _x]} foreach units group player
hint format ["Old = %1\nGroups= %2",tx_Oldname,_array]
exit
kill the unit in your group, wait for it to respawn
and kill it again
you will see the same name in the hint message which is the name of all units in your group
compare that name to the initially saved name of W1 and you will see they are indeed the same
to have your system work the way you want it too, will require some publicvariabling and manipulating arrays
-
cheers yea, i fixed it but found out the problem wasnt anyhing to do with the name, had me frustrated for days, cause everything looked good, nothing looked wrong.