How to make it say 'This Vehicle will despawn' on entering vehicle?

KrisiS

Member
Is it possible to have vehicles that were added via the editor come up with the message "Warning: This vehicle will disappear on server restart!" just as it does from DZMS ?

I tried changing this:
Code:
_vehicle_178 = objNull;
if (true) then
{
  _this = createVehicle ["Old_bike_TK_INS_EP1", [3718.2104, 14512.237, -0.00012207031], [], 0, "CAN_COLLIDE"];
  _vehicle_178 = _this;
  _this setDir -87.539024;
  _this setPos [3718.2104, 14512.237, -0.00012207031];
};

to this:
Code:
_vehicle_178 = objNull;
if (true) then
{
  _this = createVehicle ["Old_bike_TK_INS_EP1", [3718.2104, 14512.237, -0.00012207031], [], 0, "CAN_COLLIDE"];
  _vehicle_178 = _this;
  _this setDir -87.539024;
  _this setPos [3718.2104, 14512.237, -0.00012207031];
  _object addEventHandler ["GetIn",{
  _nil = [nil,(_this select 2),"loc",rTITLETEXT,"Warning: This vehicle will disappear on server restart!","PLAIN DOWN",5] call RE;
     }];
};

Doesn't work though,


Any ideas ?
Thanks
 
two methods: either before the player gets in, or after they get in

before they get in:
all mission vehicles are setting the variable dzai, or mission, or dzms, or whatever you choose, which is what you use as a marker to show it will despawn.
https://community.bistudio.com/wiki/setVariable
have this script running where it checks if cursortarget getvariable("mission",false) is equal to true in which case we pop up a message when they get within 2 meters

or check if they get into a vehicle:
here is your code to check if a player gets into a vehicle (i think, its from fn_selfactions)
Code:
_vehicle = vehicle player;
_inVehicle = (_vehicle != player);
and then check if the variable "mission" has been set and poop out a message
 
in my opinion the easiest way is following:

in your vehicle spawn code just add:
Code:
_this addEventHandler ["GetIn",{
            _nil = [nil,(_this select 2),"loc",rTITLETEXT,"Warning: This vehicle will disappear on server restart!","PLAIN DOWN",5] call RE;
        }];

the problem with your code is that you set the addeventHandler to _object but you only have _this defined. So try to change _object to _this and it should work
 
in my opinion the easiest way is following:

in your vehicle spawn code just add:
Code:
_this addEventHandler ["GetIn",{
            _nil = [nil,(_this select 2),"loc",rTITLETEXT,"Warning: This vehicle will disappear on server restart!","PLAIN DOWN",5] call RE;
        }];

the problem with your code is that you set the addeventHandler to _object but you only have _this defined. So try to change _object to _this and it should work
Yeah, there you go. use the correct variables :D
 
As always my friend, you have provided me with a simple/working solution...
Tested and working 100% :)

Ty !!
 
As always my friend, you have provided me with a simple/working solution...
Tested and working 100% :)

Ty !!
All hail schwede !!
Since you said the eventhandler wasn't working I didnt even look at your actual code, but eventhandlers are really the easiest way to do a lot of stuff because it removes all the detection code and they aren't hard to do once you understand the code. ... but I forget about them all the time and fixate on code ... going to have to write USE AN EVENTHANDLER, IDIOT on my monitor to remind me
 
I only now noticed that SchwEde had made the post,,, :( .. I had come here from an email notice and overlooked the creator to get to the goodies :)
My sincerest apologies SchwEde, sorry m8 and thank you very much for this quick and easy solution.
 
Back
Top