Forum Jump :

Author Message


Posts: 50
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2015-04-10 16:14        
     
Hi everyone,

To put things in context:
- I made a prisonBuilder script which is serverside
- I'm running a dedi

What am I trying to achieve?
- addAction MP (done already but not synced for whatever reason, not JIP proof)
- sliding fences (got it to work when I host the mission myself... does not work when in a dedicated environment... no errors in RPT)

jailFunctions.sqf (server side, exec VM'd, just a sample)

PP_fnc_addActionMP = compileFinal
"
private[""_object""];

_object = _this select 0;

switch(_object) do
{
    case tablet1:
	{
	    _object addAction [""Open the gate"", PP_fnc_toggleGates,0,0,false,false,"""", ' vehicle player == player && player distance _target < 2 && (!(slidinggate5 getVariable ""TOGGLE_3"")) ']; 
        _object addAction [""Close the gate"", PP_fnc_toggleGates,0,0,false,false,"""", ' vehicle player == player && player distance _target < 2 && (slidinggate5 getVariable ""TOGGLE_3"") '];
	};
};
";

publicVariable "PP_fnc_addActionMP";

PP_fnc_toggleGates = compileFinal
"
private[""_object"",""_action"",""_gate1"",""_gate2"",""_var""];

_object = _this select 0;
_action = _this select 2;

switch(_object) do
{
    case tablet1:
    {
	    _gate1 = slidinggate5;
		_gate2 = slidinggate6;
		_var = _gate1 getVariable ""TOGGLE_3"";
		
		if(!_var) then 
		{
		    _gate1 setVariable [""TOGGLE_3"",true,true];
            _gate1 say3d ""Alarm_BLUFOR"";
			for ""_i"" from 1 to 50 do
            {	
			    _y = 0.1;
                _gate1 setPos [(getPos _gate1 select 0) + _y, (getPos _gate1 select 1), -0.05];
				_gate2 setPos [(getPos _gate2 select 0) - _y, (getPos _gate2 select 1), -0.05];
	            sleep 0.1;
            };
		}
		else 
		{
		    _gate1 setVariable [""TOGGLE_3"",false,true];
		    _gate1 say3d ""Alarm_BLUFOR"";
			for ""_i"" from 1 to 50 do
            {	
			    _y = 0.1;
                _gate1 setPos [(getPos _gate1 select 0) - _y, (getPos _gate1 select 1), -0.05];
				_gate2 setPos [(getPos _gate2 select 0) + _y, (getPos _gate2 select 1), -0.05];
	            sleep 0.1;
            };
		};
    };
};
";

publicVariable "PP_fnc_toggleGates";

prisonBuilder.sqf (server side, exec VM'd, just a sample)

tablet1 = createVehicle ["Land_Tablet_01_F", _markPos, [], 0, "CAN_COLLIDE"]; 
tablet1 attachTo [post1,[-0.23,0,1.7]]; 
tablet1 setVectorDirAndUp [[0,1,0],[-1,0,0]]; 
publicVariable "tablet1";

slidinggate5 = "Land_SportGround_fence_F" createVehicle _markPos; 
slidinggate5 attachTo [tower,[2.5,85,-9.5]]; 
_sl5pos = getPos slidinggate5; 
detach slidinggate5; 
slidinggate5 setDir _dir1; 
slidinggate5 setPos _sl5pos; 
slidinggate5 setVariable ["TOGGLE_3",false,true]; 
slidinggate5 allowDamage false; 
publicVariable "slidinggate5";

slidinggate6 = "Land_SportGround_fence_F" createVehicle _markPos; 
slidinggate6 attachTo [tower,[-2.5,85,-9.5]]; 
_sl6pos = getPos slidinggate6; 
detach slidinggate6; 
slidinggate6 setDir _dir1; 
slidinggate6 setPos _sl6pos; 
slidinggate6 allowDamage false; 
publicVariable "slidinggate6";

[[tablet1],"PP_fnc_addActionMP",true,true] call BIS_fnc_MP;

Any help would be greatly appreciated, thank you guys.

This post was edited by HoverGuy (2015-04-20 19:33, 971 days ago)


Author Message


Posts: 83
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name: J.Shock

 
#2 Posted at 2015-04-10 18:41        
     
Where are you execVMing this code (the file)?

John Shock
Scripter, Mission Developer

My scripts: Simple Mortar Script, Redressing Script, Cruise Control Script

My Missions: [COOP-40]Operation Bloody Bayonet

Advertisement


Author Message


Posts: 50
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2015-04-10 19:33        
     
Hi JShock,

Am execVMing both of these files in the init.sqf file (server side) which are then called compiled PreprocessFileLineNumbers in the initServer.sqf

This post was edited by HoverGuy (2015-04-10 21:01, 981 days ago)


Author Message


Posts: 83
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name: J.Shock

 
#4 Posted at 2015-04-10 20:54        
     
And try the following for your addAction lines, and you should be able to move the function defines to the initServer.sqf as well, because I'm using BIS_fnc_MP and only executing it on the server, so only the server needs to know what the function is. You also shouldn't need to PV the functions either (that's a lot of network traffic by itself anyhow).

_object addAction [""Open the gate"", {[[],"PP_fnc_toggleGates",false,false,false] call BIS_fnc_MP},0,0,false,false,"""", ' vehicle player == player && player distance _target < 2 && (!(slidinggate5 getVariable ""TOGGLE_3"")) ']; 
_object addAction [""Close the gate"", {[[],"PP_fnc_toggleGates",false,false,false] call BIS_fnc_MP},0,0,false,false,"""", ' vehicle player == player && player distance _target < 2 && (slidinggate5 getVariable ""TOGGLE_3"") '];

Though, I'm not quite sure what you mean by the actions "not synced for whatever reason, not JIP proof"

John Shock
Scripter, Mission Developer

My scripts: Simple Mortar Script, Redressing Script, Cruise Control Script

My Missions: [COOP-40]Operation Bloody Bayonet

Author Message


Posts: 50
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#5 Posted at 2015-04-10 21:09        
     
# JShock : And try the following for your addAction lines, and you should be able to move the function defines to the initServer.sqf as well, because I'm using BIS_fnc_MP and only executing it on the server, so only the server needs to know what the function is. You also shouldn't need to PV the functions either (that's a lot of network traffic by itself anyhow).

_object addAction [""Open the gate"", {[[],"PP_fnc_toggleGates",false,false,false] call BIS_fnc_MP},0,0,false,false,"""", ' vehicle player == player && player distance _target < 2 && (!(slidinggate5 getVariable ""TOGGLE_3"")) ']; 
_object addAction [""Close the gate"", {[[],"PP_fnc_toggleGates",false,false,false] call BIS_fnc_MP},0,0,false,false,"""", ' vehicle player == player && player distance _target < 2 && (slidinggate5 getVariable ""TOGGLE_3"") '];

Though, I'm not quite sure what you mean by the actions "not synced for whatever reason, not JIP proof"

Thanks for the answer, gonna try it now. By "not synced for whatever reason, not JIP proof" i mean I have all the addActions available when i join the game the first time, if i go back to the lobby then reconnect all the addActions have vanished.

My main goal is to make the addActions persistent for everyone which is not the case here and I don't know why.

I've been stuggling with this for 3 days.


Author Message


Posts: 83
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name: J.Shock

 
#6 Posted at 2015-04-10 21:18        
     
Hmm, it is strange because I swore with addAction being AG (arguments global), that it would sync on JIP, maybe try moving that function define and call to the initPlayerLocal.sqf and see if that helps or not...

Actually reading the wiki on addAction:

This command has local effect. Created action is only available on the computer where command was executed. To make action available to all players, command must be executed on all connected clients.

So putting it in the initPlayerLocal.sqf should work well.

John Shock
Scripter, Mission Developer

My scripts: Simple Mortar Script, Redressing Script, Cruise Control Script

My Missions: [COOP-40]Operation Bloody Bayonet

Author Message


Posts: 50
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#7 Posted at 2015-04-10 21:59        
     
Tryin it now, will get back to you when it's done.

Edit: Tried to put the stuff in initServer.sqf as well as in initPlayerLocal.sqf, actions don't even show up now... I also removed the PVs.

This thing's driving me nutz, really.
Tell me JShock, If you were to do something similar, how would you do? (step by step)

This post was edited by HoverGuy (2015-04-10 22:29, 981 days ago)


Author Message


Posts: 83
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name: J.Shock

 
#8 Posted at 2015-04-11 02:45        
     
It's just a locality issue, which are a pain in the a$$ sometimes...

I'm not too sure what it is at the moment though...

John Shock
Scripter, Mission Developer

My scripts: Simple Mortar Script, Redressing Script, Cruise Control Script

My Missions: [COOP-40]Operation Bloody Bayonet

Author Message


Posts: 50
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#9 Posted at 2015-04-11 14:10        
     
# JShock : It's just a locality issue, which are a pain in the a$$ sometimes...

I'm not too sure what it is at the moment though...

Got it to work again, but same issue no persistence at all. I guess you're right this might be related to locality... Thanks for your help anyways. Hope someone else can lay a hand tho. I was planning on releasing the prison template here later, will take more time than i thought.


Author Message


Posts: 83
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name: J.Shock

 
#10 Posted at 2015-04-11 22:50        
     
I mean the initPlayerLocal.sqf should be able to solve the issue, because it will add the action for all players connected at missions start, and for each JIP there after, so I'm not sure why it isn't working unless you have something structured in the wrong way.

https://community.bistudio.com/wiki/Event_Scripts

John Shock
Scripter, Mission Developer

My scripts: Simple Mortar Script, Redressing Script, Cruise Control Script

My Missions: [COOP-40]Operation Bloody Bayonet

Author Message


Posts: 50
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#11 Posted at 2015-04-11 23:07        
     
# JShock : I mean the initPlayerLocal.sqf should be able to solve the issue, because it will add the action for all players connected at missions start, and for each JIP there after, so I'm not sure why it isn't working unless you have something structured in the wrong way.

https://community.bistudio.com/wiki/Event_Scripts

Thanks for this!
I forgot to mention that the prisonBuilder.sqf script is execVM'd in the init.sqf file server side which is then packed into a PBO. To clarify things a bit the connection between the addOn and the mission is done in the initServer.sqf like this:
[] call compile PreprocessFileLineNumbers "\server\init.sqf";

So how should I logically set up the whole thing? Let's say I have these functions:
PP_fnc_addActionMP = 
{
private["_object"];

_object = _this select 0;
_object addAction ["Open the gate", PP_fnc_toggleGates,0,0,false,false,"", ' vehicle player == player && player distance _target < 2 && (!(slidinggate5 getVariable "TOGGLE_3")) ']; 
_object addAction ["Close the gate", PP_fnc_toggleGates,0,0,false,false,"", ' vehicle player == player && player distance _target < 2 && (slidinggate5 getVariable "TOGGLE_3") '];
};

PP_fnc_toggleGates =
{
private["_object","_action","_gate1","_gate2","_var"];

_object = _this select 0;
_action = _this select 2;
_gate1 = slidinggate5;
_gate2 = slidinggate6;
_var = _gate1 getVariable "TOGGLE_3";
		
if(!_var) then 
{
_gate1 setVariable ["TOGGLE_3",true,true];
_gate1 say3d "Alarm_BLUFOR";
for "_i" from 1 to 50 do
{	
_y = 0.1;
_gate1 setPos [(getPos _gate1 select 0) + _y, (getPos _gate1 select 1), -0.05];
_gate2 setPos [(getPos _gate2 select 0) - _y, (getPos _gate2 select 1), -0.05];
sleep 0.1;
};
} 
else 
{
_gate1 setVariable ["TOGGLE_3",false,true];
_gate1 say3d "Alarm_BLUFOR";
for "_i" from 1 to 50 do
{	
_y = 0.1;
_gate1 setPos [(getPos _gate1 select 0) - _y, (getPos _gate1 select 1), -0.05];
_gate2 setPos [(getPos _gate2 select 0) + _y, (getPos _gate2 select 1), -0.05];
sleep 0.1;
};
};
};

How should I broadcast em?


Author Message


Posts: 83
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name: J.Shock

 
#12 Posted at 2015-04-11 23:21        
     
Well because the actions have to be added to every client locally, that means that the PP_fnc_addActionMP needs to be defined for every client (the server shouldn't need to know anything for it). The PP_fnc_toggleGates function however can be ran server side I believe, that's why I altered it above with BIS_fnc_MP that made it only execute on the server, but if that doesn't work then have it defined in both initPlayerLocal.sqf and initServer.sqf.

But now having the information about it being an addon server side that may change some things, as I'm not too knowledgeable on addons/mods so...

John Shock
Scripter, Mission Developer

My scripts: Simple Mortar Script, Redressing Script, Cruise Control Script

My Missions: [COOP-40]Operation Bloody Bayonet

Author Message


Posts: 50
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#13 Posted at 2015-04-11 23:41        
     
# JShock : Well because the actions have to be added to every client locally, that means that the PP_fnc_addActionMP needs to be defined for every client (the server shouldn't need to know anything for it). The PP_fnc_toggleGates function however can be ran server side I believe, that's why I altered it above with BIS_fnc_MP that made it only execute on the server, but if that doesn't work then have it defined in both initPlayerLocal.sqf and initServer.sqf.

But now having the information about it being an addon server side that may change some things, as I'm not too knowledgeable on addons/mods so...

And how about adding the action to the tablet? initServer i believe:
[[tablet1],"PP_fnc_addActionMP",true,true] call BIS_fnc_MP;

Or maybe right after the object is spawned? The problem is: the two functions are initialized AFTER the prisonBuilder script thus creating an entry in the logs about an undefined variable which is the case.

This post was edited by HoverGuy (2015-04-11 23:48, 980 days ago)


Author Message


Posts: 83
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name: J.Shock

 
#14 Posted at 2015-04-11 23:48        
     
See if moving it out of the initServer and putting in the initPlayerLocal like this:

tablet1 call PP_fnc_addActionMP;

John Shock
Scripter, Mission Developer

My scripts: Simple Mortar Script, Redressing Script, Cruise Control Script

My Missions: [COOP-40]Operation Bloody Bayonet

Author Message


Posts: 50
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#15 Posted at 2015-04-12 01:24        
     
Finally got it to work! THANKS!

initPlayerLocal.sqf
PP_fnc_addActionMP = compileFinal
"
private[""_object""];

_object = _this select 0;
_object addAction [""Open the gate"", PP_fnc_toggleGates,0,0,false,false,"""", ' vehicle player == player && player distance _target < 2 && (!(slidinggate5 getVariable ""TOGGLE_3"")) '];  
_object addAction [""Close the gate"", PP_fnc_toggleGates,0,0,false,false,"""", ' vehicle player == player && player distance _target < 2 && (slidinggate5 getVariable ""TOGGLE_3"") '];
";

PP_fnc_toggleGates = compileFinal
"
private[""_object"",""_gate1"",""_gate2"",""_var""];

_object = _this select 0;
_gate1 = slidinggate5;
_gate2 = slidinggate6;
_var = _gate1 getVariable ""TOGGLE_3"";
	
if(!_var) then 
{
    _gate1 setVariable [""TOGGLE_3"",true,true];
    _gate1 say3d ""Alarm_BLUFOR"";
    for ""_i"" from 1 to 50 do
    {	
         _y = 0.1;
         _gate1 setPos [(getPos _gate1 select 0) + _y, (getPos _gate1 select 1), -0.05];
		_gate2 setPos [(getPos _gate2 select 0) - _y, (getPos _gate2 select 1), -0.05];
	    sleep 0.1;
    };
}
else 
{
    _gate1 setVariable [""TOGGLE_3"",false,true];
    _gate1 say3d ""Alarm_BLUFOR"";
	for ""_i"" from 1 to 50 do
    {
		_y = 0.1;
         _gate1 setPos [(getPos _gate1 select 0) - _y, (getPos _gate1 select 1), -0.05];
		_gate2 setPos [(getPos _gate2 select 0) + _y, (getPos _gate2 select 1), -0.05];
	    sleep 0.1;
    };
};
";

[[tablet1],"PP_fnc_addActionMP",true,true] call BIS_fnc_MP;

So if i'm right, what i did was to:
- Define the function everytime a player joins
- Broadcast the addAction function (because it's local)

But i don't get why I have to broadcast it everytime when the isPersistent parameter is set to true.

Anyways I still have an issue, the second point:
- sliding fences (got it to work when I host the mission myself... does not work when in a dedicated environment... no errors in RPT)

I can see the two gates are moving apart for like 0.2m... when expecting 5... and it's laggy! I don't know what can cause this behaviour. Any ideas?

This post was edited by HoverGuy (2015-04-14 13:09, 977 days ago)