Hi there,
I'm currently facing problems with a trigger.
I want that everytime any vehicle enters a special area a Script is executed and the vehicle is passed to the script.
At the moment I'm using this trigger
The Script looks like the following
So what the script and the trigger should do is the following:
If a vehicle enters the trigger the trigger should fire and pass the vehicle and the triggername to the script vehicles.sqf.
The script should then select the trigger and the vehicle from the passed array.
Then it reads the ownerID via the getvariable command cause it should only do the things if the vehicle has no ownerID (in this case the default value of "0").
Then it checks whether _vehicle is a real vehicle cause AllVehicles is passing much other things too. If its a vehicle the script should recheck with the first wait until if the vehicle is in the trigger.
If it is and the ownerID is 0 then it should check whether there is already a variable claimed set at the vehicle, if not it should get the driver of the vehicle (if there is one) and get the playeruid of the driver and then add the claimed variable via setvariable (sets the playerUID of the driver).
The only problem I'm facing to is that sometimes the trigger fires for the vehicle and passes it to the script and sometimes not. And I can't figure out WHY, this is really frustrating
Hope someone has the right direction to show me where the error is..
Thanks
I'm currently facing problems with a trigger.
I want that everytime any vehicle enters a special area a Script is executed and the vehicle is passed to the script.
At the moment I'm using this trigger
Code:
class Item7
{
position[]={11460.791,317.30573,11351.464};
angle=310;
rectangular=1;
activationBy="ANY";
repeating=1;
interruptable=1;
age="UNKNOWN";
text="Vehicle1";
name="Vehicle1";
expCond="{_x iskindof 'AllVehicles'} count thisList > 0";
expActiv="{[Vehicle1,_x] execVM ""vehicle.sqf""} forEach thislist";
class Effects
{
};
};
The Script looks like the following
Code:
private ["_Basis","_vehicle","_ownerid","_driver","_ownerID","_playeruid","_claimer"];
_Basis = _this select 0;
_vehicle = _this select 1;
_ownerid = _vehicle getVariable ["characterID","0"];
if (_vehicle iskindof "Car" or _vehicle iskindof "Motorcycle" or _vehicle iskindof "Helicopter" or _vehicle iskindof "Plane")
then {
while {true} do {
waitUntil {vehicle _vehicle in list _Basis};
if (_ownerID == "0") then {
_claimer = _vehicle getVariable ["Claimed","0"];
if (_claimer == "0") then {
_driver = driver _vehicle;
if (!(isnull _driver)) then {
_playeruid = getPlayerUID _driver;
_vehicle setVariable ["Claimed",_playeruid,true];
_claimer = _vehicle getVariable ["Claimed","0"];
};
};
};
waitUntil {! (vehicle _vehicle in list _Basis)};
if (_ownerID == "0") then {
_vehicle setVariable ["Claimed",nil];
if (locked _vehicle) then {
dayzLockVehicle = [_vehicle,false];
if (local _vehicle) then {
dayzLockVehicle spawn local_lockUnlock
} else {
publicVariable "dayzLockVehicle";
};
};
};
};
};
So what the script and the trigger should do is the following:
If a vehicle enters the trigger the trigger should fire and pass the vehicle and the triggername to the script vehicles.sqf.
The script should then select the trigger and the vehicle from the passed array.
Then it reads the ownerID via the getvariable command cause it should only do the things if the vehicle has no ownerID (in this case the default value of "0").
Then it checks whether _vehicle is a real vehicle cause AllVehicles is passing much other things too. If its a vehicle the script should recheck with the first wait until if the vehicle is in the trigger.
If it is and the ownerID is 0 then it should check whether there is already a variable claimed set at the vehicle, if not it should get the driver of the vehicle (if there is one) and get the playeruid of the driver and then add the claimed variable via setvariable (sets the playerUID of the driver).
The only problem I'm facing to is that sometimes the trigger fires for the vehicle and passes it to the script and sometimes not. And I can't figure out WHY, this is really frustrating
Hope someone has the right direction to show me where the error is..
Thanks