Vehicles Spawns / Cleanup?

My new thing to figure out is if I can set a playername/id on the vehicle on spawn and eject anyone else who tried to become the driver. Seems like an EH on the vehicle will do it.
 
Okay, I got you. You tried client or server .. I recall you saying that before.
The box deal. The box spawns, then if the player dies next to the box it is not deleted. They respawn and now they get a second box.
Solution:
profilenamespace setvariable["reward", 1]; when the box is created.
profilenamespace setvariable["reward", 0]; when the box is deleted
Now they have respawned and we are about to create a box. Check and see if there is a current box using this line:
profilenamespace getvariable["reward",0];
... if that returns 1 then we know they already have a box and they dont get a second one.

Suggestion
: Personally, I would use a timer and they can only get a single box each restart. That would mean setting a global variable using the characters UID
When you create the box you do this .... It checks if the _playerUID variable has been set. Each player will have a separate _playerUID variable set on the server missionnamespace with a value of 1 when the box is created and we check that value every time they spawn and dont create it again during this restart. These variables are deleted at restart (the profilenamespace is NOT deleted).
Code:
if (missionnamespace getvariable[_playerUID,0] == 0 ) then {
_playerUID = Getplayeruid player;
missionnamespace setvariable[_playerUID,1];
//CREATE BOX NOW
};

I might suggest you take all your definitions of the gear for each humanity level and put that in a separate file and then simply use #include to place it back into your code. This would make it much more readable.
Anyway, if its working .. Good.
 
My new thing to figure out is if I can set a playername/id on the vehicle on spawn and eject anyone else who tried to become the driver. Seems like an EH on the vehicle will do it.


_vehicle addMPEventHandler ["GetIn", {if (player is not owner) then player action["eject", _vehicle];}]

edit: yeah, setvariable owner and then if player is not == the owner..
 
Of course the driver thing is not that easy since there is not "MoveToDriver" EH. Anyway, not worried about that.

Stress testing and it works well when you login/logout/login.
Now I'm finding that the vehicles are suddenly spawning with gear in them. Some of it I've never seen before (strobe lights, lapua magnum ammo) and I can't take any of it out of the vehicle. Related code, basically the same as the vehicle spawn in DZMS. All on server side. Sigh, its never easy in dayz:
Code:
        _vehClass = _vehList call BIS_fnc_selectRandom;
        _vehicle = createVehicle [_vehClass,[(_coords select 0) - 4, (_coords select 1) + 4,0],[], 0, "CAN_COLLIDE"];
        _objectID = str(round(random 999999));
        _vehicle setVariable ["ObjectID", _objectID, true];
        _vehicle setVariable ["ObjectUID", _objectID, true];
  
//        _vehicle setVariable ["Mission",1,true];
        dayz_serverObjectMonitor set [count dayz_serverObjectMonitor, _vehicle];
        //publicVariableServer "dayz_serverObjectMonitor"; // running on Server, so no need.

        waitUntil {(!isNull _vehicle)};
        clearMagazineCargo _vehicle;
        clearWeaponCargo _vehicle;
        //_vehicle addMagazineCargoGlobal ["ItemJerryCan"];

      
        _ranFuel = random 1;
        if (_ranFuel < .25) then {_ranFuel = .25;};
        _vehicle setFuel _ranFuel;
        _vehicle setvelocity [0,0,1];
        _vehicle setDir (round(random 360));
        _vehicle setVehicleLock "UNLOCKED";
 
by default, vehicles have stuff in them depending on their type. Dayz removes the gear or has overwritten the class (the _dz vehicles) to remove the gear.
To test for someone moving in as driver you will have to add a script to the vehicle (getin eventhandler) that runs constantly and checks if the vehicle driver is allowed.
if(driver _vehicle == player) then {
Remember, the player object is only available on the client who owns that object. so this will take some thought on how to do it.

so add to your code
clearWeaponCargo _vehicle
clearMagazineCargo _vehicle
 
run the getin eventhandler on each client on those vehicles. Player gets in and code is fired that checks every 5 seconds if he is the driver ( if(driver _vehicle == player) then { ) and ejects him if he is driver but not supposed to be, and code exits if he is not in the vehicle
 
I am clearing the vehicle in the code above, which is why I'm perplexed. The trigger you suggest is similar to the aibus code, got it.

Had:
clearMagazineCargo _vehicle;
clearWeaponCargo _vehicle;


Switched to:
clearMagazineCargoGlobal _vehicle;
clearWeaponCargoGlobal _vehicle;

Seems to work, but I'm still plugging away on other inconsistencies.
 
oh, yeah, I didnt look that close. Assumed if there was stuff in the vehicle you had not done that.
this line is not needed. waitUntil {(!isNull _vehicle)};
since you have already created the vehicle, its not going to be a null object.
 
Back
Top