Jump to content

Elevator Script for Players and Vehicles [WIP/Prototype]


Axe Cop

Recommended Posts

I'm getting 

 

"Elevator script initialized"
Error in expression <false];
};
} else {
player removeAction s_player_elevator_next;
s_player_elevato>
  Error position: <s_player_elevator_next;
s_player_elevato>
  Error Undefined variable in expression: s_player_elevator_next
File mpmissions\__CUR_MP.Panthera2\Addons\elevator\elevator_init.sqf, line 71

In my Client RPT, running 1051, 112555

 

This also happens on clients with the new steam patch, and as server hosts are kinda forcing the servers to go to this patch i think it would be prudent to get the script compatible with it.

 

Epoch: 1.0.5.1

A2OA: 1.63.125548

Link to comment
Share on other sites

as far as I know many script work like this, at least the scripts I know never define global variables before they are used (that is the problem here I would say)..

so the fix would be to initialize all variables starting with "s_", e,g.

s_player_elevator_next = -1;

that was not necessary before.. :/

Link to comment
Share on other sites

  • 2 weeks later...

Yeah the elevator itself can be build out of anything in the game, but I don't know about desync or whatever if it will be to complex, so keep it simple at first. :)

The elevator works for everything that will be near the platform, so players + vehicles at least.

It might look weird but objects can't fall through when it's moving (even with heavy desync)..

Database delete all MetalFloor_Preview_DZ after x days. Where i can add this floor that can be repaired same as all crafting walls, floors etc from 30m plot pole?

 

b_560_95_1.png

Link to comment
Share on other sites

To fix the undefined variables for elevator add:

	s_player_elevator_next = -1;
	s_player_elevator_previous = -1;
	s_player_elevator_select = -1;
	s_player_elevator_upgrade = -1;
	s_player_elevator_upgrade_stop = -1;
	s_player_elevator_call = -1;
	s_player_elevator_id = -1;

Variables.sqf(custom) to :

//Player self-action handles
dayz_resetSelfActions = {
Link to comment
Share on other sites

 

To fix the undefined variables for elevator add:

	s_player_elevator_next = -1;
	s_player_elevator_previous = -1;
	s_player_elevator_select = -1;
	s_player_elevator_upgrade = -1;
	s_player_elevator_upgrade_stop = -1;
	s_player_elevator_call = -1;
	s_player_elevator_id = -1;

Variables.sqf(custom) to :

//Player self-action handles
dayz_resetSelfActions = {

 

 

So you are saying to add a variables.sqf file to the elevator directory and put this in it?

//Player self-action handles
dayz_resetSelfActions = {

   s_player_elevator_next = -1;
    s_player_elevator_previous = -1;
    s_player_elevator_select = -1;
    s_player_elevator_upgrade = -1;
    s_player_elevator_upgrade_stop = -1;
    s_player_elevator_call = -1;
    s_player_elevator_id = -1;

}
Link to comment
Share on other sites

No there already is a variables.sqf in epoch, you need to add the variables to the list dayz_resetSelfActions in there, little knowledge of epoch and scripting should be enough to do that... I thought. :D

 

Nope... been running several epoch servers on dedi box for less than 2 weeks now. Half were setup by someone else, so i am trying to figure it out as i go. 

 

This newbie is getting there, just sometimes needs a little push in the right direction. 

Link to comment
Share on other sites

Nope... been running several epoch servers on dedi box for less than 2 weeks now. Half were setup by someone else, so i am trying to figure it out as i go. 

 

This newbie is getting there, just sometimes needs a little push in the right direction. 

 

We all started where you are my friend, do not be put off... It's what we are here for :)

 

Ask as many questions as you like as the more you do the more you learn ;-) Honestly I had no clue what a variables file was either until I came here and started asking questions and as a n00b I like to pass on recent knowledge i gained to help others that are in the same boat :)

 

GL & HF

 

Pry

Link to comment
Share on other sites

You mean with crowbar / etool / toolbox? Players keep asking me I don't know what to answer because they don't seem to get an option.

The elevator itself is just a metal floor, so it can be removed like one!

the stop points cant be removed by default, you need to modify the epoch script if you want players to be able to do that by themselves.

Link to comment
Share on other sites

For those that have done this simple setup and have not gotten it working - there is an error in the github files

 - one was touched on in an earlier post must use the raw files...just downloading the files will be in html format

the main issue is this

 

 _folder+"elevator_actions.sqf"   = wrong

 _folder + "elevator_actions.sqf"  = correct

 

look for and add the space to all the _folder instances - 5 or 6 if I remember correct

hope this helps

Link to comment
Share on other sites

So I'll be honest, I've never used the mod before but I had an itch this morning, maybe you all can scratch it.

 

I'm playing on an overpoch server, from a quick search this mod works on them (pls let me know if that is not the general consensus)

 

My itch is this.... being able to combine the pieces together to make one giant elevator (lets say something big enough to land a MV-22 on and have it lift no problem. 

 

On our sever we also have Vector building, I assume this doesn't cause issues with that but would it be possible to make large doors (lets say hangar doors?) with this mod?

 

I'd be curious to know if there was a way to lock the elevators too, like you upgrade it with a combo lock

Link to comment
Share on other sites

So I'll be honest, I've never used the mod before but I had an itch this morning, maybe you all can scratch it.

 

I'm playing on an overpoch server, from a quick search this mod works on them (pls let me know if that is not the general consensus)

 

My itch is this.... being able to combine the pieces together to make one giant elevator (lets say something big enough to land a MV-22 on and have it lift no problem. 

 

On our sever we also have Vector building, I assume this doesn't cause issues with that but would it be possible to make large doors (lets say hangar doors?) with this mod?

 

I'd be curious to know if there was a way to lock the elevators too, like you upgrade it with a combo lock

should all be possible yes, but that takes some time scripting what you want.. you can just attach objects to another in arma, like players and vehicles to the elevator platform when it moves or in general players inside vehicles :)

Link to comment
Share on other sites

you script is great !!  but due to the desync players/vehicles tend to desync through the panel and blowup or die.  So I thought maby instead of a elevator you could make it a teleport pad.  Step on one pad, maby get a timer telling you your going to be teleported after so many seconds if you don't step off then you get moved to the other pad.

Link to comment
Share on other sites

teleporting is possible but usually the elevator with desync should work, because I have attached all players and vehicles to the platform.. it is the same as with players inside vehicles there might be heavy desync but even if the vehicle drives through objects with teh desync they should not die!?

Link to comment
Share on other sites

  • 2 weeks later...

Hey if any of you are using by Zupa and rosska85 there is now away to control who uses the elevator.  I would suggest diffing if you made changes to the elevator_init.sqf file like the folder location.  This is the best I could come up with so if you see a better way let us know.  If there name is on the plotpole they get the selection to use and build.
 
Edit:  TheHound found that the selection for calling the elevator is still avalible if your not on the plot pole.  Changed code to block all selections if not on plot pole.
 
elevator_init.sqf

private ["_folder","_ct","_findNearestPoles","_findNearestPole","_IsNearPlot"];

if (isServer || isDedicated) exitWith {
	diag_log "Error: Elevator script should NOT be started on the server";
};
if (count _this != 1) exitWith {
	diag_log "Error: elevator_init.sqf called with wrong parameter count (the only parameter should be the folder of the script relative to the mission folder)";
};

_folder = (_this select 0) + "\";

// global variables
if (isNil "ELE_PlatformClass") then { ELE_PlatformClass = "MetalFloor_DZ" };
if (isNil "ELE_StopClass") then { ELE_StopClass = "MetalFloor_Preview_DZ" };
if (isNil "ELE_MaxRange") then { ELE_MaxRange = 25 }; // m
if (isNil "ELE_Size") then { ELE_Size = 4 }; // m
if (isNil "ELE_Speed") then { ELE_Speed = 2 }; // m/s
if (isNil "ELE_StopWaitTime") then { ELE_StopWaitTime = 5 }; // s
if (isNil "ELE_UpdatesPerSecond") then { ELE_UpdatesPerSecond = 60 }; // animation updates per second
if (isNil "ELE_RequiredBuildTools") then { ELE_RequiredBuildTools = ["ItemToolbox", "ItemCrowbar"] }; // required tools for building an elevator and elevator stop
if (isNil "ELE_RequiredBuildItems") then { ELE_RequiredBuildItems = [["PartGeneric",4], "PartEngine", "ItemGenerator", "ItemJerrycan"] }; // required items to build an elevator
if (isNil "ELE_RequiredBuildStopItems") then { ELE_RequiredBuildStopItems = [["PartGeneric",4]] }; // required items to build an elevator stop
if (isNil "ELE_Debug") then { ELE_Debug = false }; // debug flag

ELE_elevator = nil;

// global functions
call compile preprocessFileLineNumbers (_folder + "vector.sqf");
call compile preprocessFileLineNumbers (_folder + "ac_functions.sqf");
call compile preprocessFileLineNumbers (_folder + "elevator_functions.sqf");

diag_log "Elevator script initialized";

// elevator actions
while {true} do {
	_ct = cursorTarget;
            _findNearestPoles = nearestObjects[player, ["Plastic_Pole_EP1_DZ"], DZE_PlotPole select 0];
            _IsNearPlot = count (_findNearestPoles);
            _fuid  = [];
            _allowed = [];
        if(_IsNearPlot > 0)then{
            _thePlot = _findNearestPoles select 0;
            _owner =  _thePlot getVariable ["ownerPUID","010"];
            _friends = _thePlot getVariable ["plotfriends", []];

        {
            _friendUID = _x select 0;
            _fuid  =  _fuid  + [_friendUID];
        } forEach _friends;

         _allowed = [_owner];    
         _allowed = [_owner] +  _fuid;

        };
	if ((!isNull _ct) && ((getPlayerUID player) in _allowed) && {(player distance _ct) < ELE_Size}) then {
		// has target
		if (typeOf _ct == ELE_PlatformClass) then {
			// elevator actions
			if ([_ct] call ELE_fnc_isElevator) then {
				if (s_player_elevator_next < 0 && {[_ct] call ELE_fnc_hasNextStop}) then {
					s_player_elevator_next = player addAction ["<t color=""#ffffff"">Activate Elevator: Next Stop</t>", _folder+"elevator_actions.sqf", ["next",_ct], 5, false];
				};
				if (s_player_elevator_previous < 0 && {[_ct] call ELE_fnc_hasPreviousStop}) then {
					s_player_elevator_previous = player addAction ["<t color=""#ffffff"">Activate Elevator: Previous Stop</t>", _folder+"elevator_actions.sqf", ["previous",_ct], 5, false];
				};
				if (s_player_elevator_select < 0) then {
					s_player_elevator_select = player addAction ["<t color=""#ffffff"">Select Elevator</t>", _folder+"elevator_actions.sqf", ["select",_ct], 1, false];
				};
			} else {
				if (s_player_elevator_upgrade < 0) then {
					s_player_elevator_upgrade = player addAction ["<t color=""#ffffff"">Upgrade to Elevator</t>", _folder+"elevator_build.sqf", ["build",_ct], 0, false];
				};
				if (s_player_elevator_upgrade_stop < 0) then {
					s_player_elevator_upgrade_stop = player addAction ["<t color=""#ffffff"">Upgrade to Elevator Stop</t>", _folder+"elevator_build.sqf", ["build_stop",_ct], 0, false];
				};
			};
		};
		// elevator stop actions
		if ([_ct] call ELE_fnc_isElevatorStop) then {
			if (s_player_elevator_call < 0) then {
				s_player_elevator_call = player addAction ["<t color=""#ffffff"">Call Elevator</t>", _folder+"elevator_actions.sqf", ["call",_ct], 5, false];
			};
		};
		// debug actions
		if (s_player_elevator_id < 0 && ELE_Debug) then {
			s_player_elevator_id = player addAction ["<t color=""#ddffffff"">Show Elevator ID</t>", _folder+"elevator_actions.sqf", ["id",_ct], 0, false];
		};
	} else {
		player removeAction s_player_elevator_next;
		s_player_elevator_next = -1;
		player removeAction s_player_elevator_previous;
		s_player_elevator_previous = -1;
		player removeAction s_player_elevator_select;
		s_player_elevator_select = -1;
		player removeAction s_player_elevator_upgrade;
		s_player_elevator_upgrade = -1;
		player removeAction s_player_elevator_upgrade_stop;
		s_player_elevator_upgrade_stop = -1;
		player removeAction s_player_elevator_call;
		s_player_elevator_call = -1;
		player removeAction s_player_elevator_id;
		s_player_elevator_id = -1;
	};
	sleep 1;
};


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
×
×
  • Create New...