Instead of the boring setdammage 1 or grenade explosion effects in border zone triggers, camp killers, spawn protectors, ... I want to have something different.
So I build a script which should throw the unit entering a trigger area to a direction. SetPos being so "unrealistic" I wanted to use SetVelocity, but then my troubles started.
Here's the script how it currently is:
_unit = _this select 0
#start
~0.2
?(vehicle _unit in list zone1trig) || (vehicle _unit in list zone2trig) || (vehicle _unit in list zone3trig) || (vehicle _unit in list zone4trig): goto "THROW"
goto "start"
#THROW
?_unit != (vehicle _unit): goto "THROWVEHICLE"
_unit say "boom1"
?(local _unit): hint format ["%1, you're not allowed to enter the Eastern parts of Nogova.", name _unit]
_xi = 0
_yi = 0
_zi = 0
?(speed (vehicle _unit) < 0): _dircor = 1
?(speed (vehicle _unit) > 0): _dircor = 0
#calc
(vehicle _unit) setPos [(getPos _unit select 0) - _xi * (sin(getDir _unit)),(getPos _unit select 1) - _yi * (cos(getDir _unit)),_zi]
~0.001
?_dircor == 0: _xi = _xi + 2
?_dircor == 0: _yi = _yi + 2
_zi = _zi + 8
?_dircor == 1: _xi = _xi - 2
?_dircor == 1: _yi = _yi - 2
? (getPos _unit select 2) < 150 : goto "calc"
_chute = "Parachutewest" createVehicle [getPos _unit select 0,getPos _unit select 1,getpos _unit select 2]
_chute setPos [getpos _unit select 0,getpos _unit select 1,getpos _unit select 2]
_unit moveindriver _chute
~20
goto "start"
#THROWVEHICLE
_unit say "boom1"
(vehicle _unit) setvelocity [-80-(random 50),-80+(random 160),100+(random 100)]
?(local _unit): hint format ["%1, you're not allowed to enter the Eastern parts of Nogova", name _unit]
~20
goto "start"
I know that SetVelocity doesn't work for player units directly, so as you see the script detects if the unit is in a vehicle. If he is in a vehicle then SetVelocity will be used, but if not the script will use SetPos.
Now, when testing this in MP with me being the server and MI_Fred the client we found that the server worked fine, but the SetVelocity part didn't work on the client. I could hear the "boom1" sound, but nothing happened - it's like the command had no effect on the unit.
My question is simple. Why? :beat:
editI was just reading some old topic in the official forums and it says that if I setpos the unit above the ground I could then use SetVelocity on him straight, without him being in a vehicle. But that's not the point. The point is that why doesn't the SetVelocity work for the client even if he's in a vehicle.
editAgain I was reading some old posts in the official forums. One of them says that
A VEHICLE is always LOCAL to its DRIVER.
. Now I'm so confused that what's left of my brain doesn't apear to function that well.. Would that quote have anything to do with why my script doesn't work on the client?
editOh, and also the part where the parachute is created, doesn't work on the client. I (server) can see an empty parachute falling from the sky after the client player dropped at 200km/h to solid ground (ouch). So maybe there's something fishy in the entire script or just the MoveInDriver command not working on the client? An earlier version created a bike and the client wasn't 'MovedInDriver' in that either.
The script is executed from
init.sqs with
[unitname] exec "script.sqs"