Home   Help Search Login Register  

Author Topic: Running a Script onl ServerSide  (Read 1112 times)

0 Members and 1 Guest are viewing this topic.

RaiN_MaN

  • Guest
Running a Script onl ServerSide
« on: 16 Nov 2003, 00:01:37 »
Hi

I'm using a vehicle respawn script in a multiplay mission. It waits untile the vehicle gets 1 dammage and then copies the type of the vehicle, deletes it and creates a new one at the location the unit was the firts time the script started. The script works perfectly while i'm the only client connected. As soons as i play with a friend the script spawns 2 vehicles. Since i'm running version 1.94 and, if i remember correctly, one of the new features is that version 1.94 executes all scripts on the server and on all clients. I'm not sure but i think the script creates two vehicles since two clients are connected and the script gets executed two times. Is there a way to restrict the execution of a script only to server side? I really would hate it to have to write another page of code only to be sure this script gets executed only one time everytime the vehicle get's destroyed. I couldn't find anything dealing with this probelm, can someone help me?

Thx!

The script:
Code: [Select]
_Vehicle = _this select 0
_RPos = getPos _Vehicle
_RFace = getDir _vehicle
_RType = typeOf _vehicle

#WaitForDead
~10
?(!(getDammage _Vehicle == 1)) : GoTo "WaitForDead"

#WaitStop
~4
? (speed _Vehicle > 0 && getPos _Vehicle select 2 > 0) : GoTo "WaitStop"

~5
deleteVehicle _Vehicle
~5
_NewV = _RType createVehicle _RPos
_NewV setDir _RFace

[_NewV] exec "vrespawn.sqs"

Offline CrashDome

  • Members
  • *
Re:Running a Script onl ServerSide
« Reply #1 on: 16 Nov 2003, 11:03:02 »
put a gamelogic unit on your map and call it "Server" or "ServerLogic" or something...

in the script, very first line... put:

? !(local <logicname>):exit

and replace logicname with whatever you called it.


This is pretty basic stuff. You should have searched first or checked editor's depot.