Jump to content
  • 0

One time while in vehicle


Dxnxex

Question

Hello,

Actualy I have experience with codding, but I can´t get system what is here so I´m newbie. I found scripts what can be used in Arma 2, but I do not have them in head.

The main is, I need to help to understand how it works and get it done.

I want to create script what says. If you are in vehicle do this, but only 1 time.

in init is:

execVM "addons\xxx.sqf";

 

private["_vehicle","_inVehicle"];

while {true} do {

_vehicle = vehicle player;
_inVehicle = (_vehicle != player);

if (_inVehicle) then {
        
        //titleText ["","WHITE IN"];
        
        if (typeOf vehicle player == "AH1Z") then {
        titleText ["","WHITE IN"];
        taskHint ["Show this text",[0.46, 0.89, 0.15, 1], "taskNew"];
        };
        
    };
    sleep 10;
};

I do understand that code,

if player is in vehicle do white screen and task hint text if player is in AH1Z then wait 10 sec and back to start 

but I do not found the anything what say "just entered vehicle" or

somehow make when you enter vehicle set this variable to true and if it´s true do not start code. When you get out of vehicle set variable to false again.

 

Then I need help with these.

I have AH1Z, UH60M .... , and make this script do not work for AH1Z but for whole list of vehicles.. should it be _VehicleList = ["AH1Z",UH60M"]; or how?

 

Thank you :)

 

 

 

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

go to the script that spawns in the specific vehicle  (e.g. servermonitor if spawned from hive, or server_publishvehicle when bought from trader etc.).

add this:

_vehicle addEventHandler ["GetIn",{_nil = [nil,(_this select 2),"loc",rTITLETEXT,"This vehicle needs to be hotwired in order to work.","PLAIN DOWN",5] call RE;}];

 

Reconfigure it for your purpose. this will only be executed when a player enters a vehicle (once).

Link to comment
Share on other sites

  • 0
4 hours ago, seelenapparat said:

go to the script that spawns in the specific vehicle  (e.g. servermonitor if spawned from hive, or server_publishvehicle when bought from trader etc.).

add this:


_vehicle addEventHandler ["GetIn",{_nil = [nil,(_this select 2),"loc",rTITLETEXT,"This vehicle needs to be hotwired in order to work.","PLAIN DOWN",5] call RE;}];

 

Reconfigure it for your purpose. this will only be executed when a player enters a vehicle (once).

I do not test it yet (I'm at work), but doesn't this mean really once? I need to do it everytime but once you get in to specific vehicle.

And what is that "loc" stands for?  This script need no execute? It's because of call RE?

Thank you

 

Edit: I need to make script that say .. "everytime when you enter the listed vehicle show text" or like "every time you entered ah1z then show text 'this is super helicopter' "

Link to comment
Share on other sites

  • 0
8 minutes ago, seelenapparat said:

an eventhandler works like you described it.

once you enter the vehicle. the code is executed.

everytime you enter it. sry for making it so unclear.

yes the loc part is from the RE part of this. it means local the player.

So where I should go with your code and mine ? I'm really confused how these works so pardon me.

 Is my code useful to this or not?

What I think I need to do it is delete my codes and put your to servermonitor (pbo server files I think) and that should work.

Link to comment
Share on other sites

  • 0
5 minutes ago, seelenapparat said:

the eventhandler getin must be attached to where you create the vehicle.

search for createvehicle and look where the other eventhandlers are attached.

servermonitor etc.

definetly serverside.

ok I will try to look after I get home in 5 hours and will try to figure it out how it works.

Probably it will not get good... So I will ask for more  help.

Thank you for help and teach.

Link to comment
Share on other sites

  • 0
On 11/11/2019 at 4:48 PM, seelenapparat said:

the eventhandler getin must be attached to where you create the vehicle.

search for createvehicle and look where the other eventhandlers are attached.

servermonitor etc.

definetly serverside.

Hello,

I do not FIGURE it out .. I really don´t know where to put it and how to edit it so I found and modify anything else what is usefull too.

I found the code what add action into vehicle in which I´m sitting, but there is problem, NOT so big, but can you help me to fix it?


DZE_Category_1 = ["AH1Z"];
DZE_Category_2 = ["MH60S","Mi24_D"];
DZE_Category_all = DZE_Category_1 + DZE_Category_2;

while {true} do {
	
   sleep 0.1;
   _vehicle = (vehicle player);
   _inVehicle = (_vehicle != player);
   
   if (_inVehicle) then {
	   
		//In CATEGORY 1 Vehicles
		if (typeOf vehicle player in DZE_Category_1) then {   
	   _action = _vehicle addAction ["<t color='#92E143'>1st Class</t>", "addons\X_script.sqf",[],-1,false];
		};
	
		//In CATEGORY 2 Vehicle
		if (typeOf vehicle player in DZE_Category_2) then {   
	   _action = _vehicle addAction ["<t color='#E88C23'>2nd CLASS</t>", "addons\X_script.sqf",[],-1,false];
		};
		
	   };
   
   waitUntil {!((vehicle player) == _vehicle)};
   _vehicle removeaction _action;
   
};

 

PROBLEM n.1

This code works like .. if you are in vehicle which is in Category 1 then add action .. just for info in which category you are and that X_script do nothing. But FIRST problem is why I need to use whole this 

["<t color='#92E143'>1st Class</t>", "addons\X_script.sqf",[],-1,false];

Instead of this? (This one do not works, nothing will add)

["a useless action that does nothing", {}];

 

PROBLEM n.2

and second one (I do copied so I do not understand what does it mean), but problem is when I leave the vehicle the action will stay there and I want to removeaction after I leave the vehicle.

P.S. What does it do ? (BUT IT WORKS)

waitUntil {!((vehicle player) == _vehicle)};

Waiting for what ? Waiting until player is not player ?

EDIT ... It´s worse like next one.

 

HELP but not PROBLEM

I do used my own part of the script, but its little worse than the previous one.

waitUntil {!(vehicle player) == _inVehicle};

This allways add action and do not remove them. Why ? I thought it mean "Wait until player is not in vehicle then remove actions".

 

EDIT: Maybe I do fix it by making _action not local but variable (only action without _)

Thank you for help :)

Link to comment
Share on other sites

  • 0

what you are trying now is the lazy and at the same time more complicated stuff.

first of all, how do you spawn that vehicle? is it coming from the database? (then check server_monitor.sqf)

is it bought via a trader? (check the server_publishvehicle.sqf scripts)

is it spawned via admintool? (check that one instead)

then search for the line that has createvehicle in it, e.g.:
 

_object = _class createVehicle [0,0,0];

after that you find some setvariable stuff etc.

further down there should be something like this:

_object call fnc_veh_ResetEH;

after that, place the line I gave you.

_object addEventHandler ["GetIn",{_nil = [nil,(_this select 2),"loc",rTITLETEXT,"This vehicle needs to be hotwired in order to work.","PLAIN DOWN",5] call RE;}];

 

done.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...