OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: 24Gamer on 03 May 2004, 19:08:37

Title: Problem with Vehicle Respawn Script, Help Needed
Post by: 24Gamer on 03 May 2004, 19:08:37
Here is the Script i made;

?!(local Server):exit

_obj = _this select 0
_vdelay = _this select 1
_type = _this select 2

_pos = getPos _obj
_dir = getDir _obj

#alive
?(getdammage _obj < 1): goto "alive"
Hint Format ["%1 Destroyed, It will respawn in %2s", _type, _vdelay]

#Spawn
~_vdelay
deleteVehicle _obj
~1
_obj = _type createVehicle _pos
_obj setDir _dir
Hint Format ["%1 Has Respawned", _type]
goto "init"


the following code is attached to each object i wish to spawn;
[this, 30, "Truck5tReammo"] exec "vehicle.sqs"


the problem is that a vehicle is spawned for every player playing.
when i was testing it on my own it was ok but once i tested it online it kept spawning multiples.
i think it has something to do with the script running on all the computers.
is ?!(local Server):exit wrong?
Title: Re:Problem with Vehicle Respawn Script, Help Needed
Post by: Artak on 03 May 2004, 19:20:33
It's right, but I bet you haven't placed a gamelogic named as 'Server' in editor have you?

What the '?!(local Server):exit' line actually does is that it checks if a unit called 'Server' is local to the machine where the script is executed and if not it exits the script. The 'unit' should be a gamelogic because gamelogics are local on server only.
Title: Re:Problem with Vehicle Respawn Script, Help Needed
Post by: 24Gamer on 03 May 2004, 19:41:18
you guessed right   ;)
thanks ill try it and hope it works  :D
Title: Re:Problem with Vehicle Respawn Script, Help Needed
Post by: 24Gamer on 03 May 2004, 19:53:48
well erm  :-\
it worked but now it only spawns the vehicle once
vehicle destroyed = vehicle respawned -> vehicle destroyed = script not called
Title: Re:Problem with Vehicle Respawn Script, Help Needed
Post by: 24Gamer on 03 May 2004, 19:58:22
don't worry just a little bug in my script
it is now fully functional  :D
thanks for the help  :)