using a pubished variable from mission to server file

J3T

Valued Member!
Hey there,
so i was wondering how i can use my publicvariable.
So right now i did this to determine it and publish it to the server (found in the mission.sqm)
Code:
            expActiv="secprot = true; publicVariableServer ""secprot"";";

But when i try to use it in the player_onDisconnect.sqf (for example) on the server it won't work anymore.
Code:
   if (secprot == true) then {<random code that works};

Can anyone tell me why it won't work an maybe give me even a hint to to get it working?

every help is appreciated.

cheers J3T
 
If statements wait for the code to return "true", such as 1 = 1 or 1 + 1 = 2, so checking if the statement is true is the wrong syntax.
Instead you would do:
Code:
if (secprot) then {<random code that works};
 
wouldn't it be permantly after you entered it? Right now it shall be deactivated with this one:
Code:
            expDesactiv="secprot = false; publicVariableServer ""secprot"";";
because even if secprot is false it is still passed to the server and so it will still trigger the code


tested it, sadly it didn't work.
 
Last edited:
Code:
   if (secprot) then {
    _world = [[226,[17944.4,19747.1,0.001]],[297,[7026.44,2436.69,8.85e-04]],[115,[6045.51,6251.64,0.002]]];
    _num = (round (random (3)));
    _worlds = _world select _num;
    player setVariable["worldspace",_worlds,true];
    };

Triggered when you are inside of a specific area. But only if you disconnect there.
 
Instead of messing with publicVariables, what I would do is get the map grid coordinates of the area you want to be blacklisted, such as 035056, and add them to an array.
Then get the users worldspace and use mapGridPosition which will turn a worldspace into grid coordinates.
Then simply compare the users current grid coordinates to the blacklist and if it matches, set the worldspace.
If you use a global variable for the grid array, you could even have that array in the init for easy modifying.

Something like this:
Code:
_uGrid = mapGridPosition (getPos player);
_gridBlack = ["345345","353453","453664"];
if (_uGrid in _gridBlack) then {
    _world = [[226,[17944.4,19747.1,0.001]],[297,[7026.44,2436.69,8.85e-04]],[115,[6045.51,6251.64,0.002]]];
    _num = (round (random (3)));
    _worlds = _world select _num;
    player setVariable["worldspace",_worlds,true];
};
 
So i get you right, i'm just using the coords from the Ingamemap? (The one used for the gps)
 
Yes, you can get all the grid coordinates from the in game map. mapGridPosition will turn the players worldspace into grid coordinates and then you can just see if the players grid is in the array.
 
So i tried it but sadly didn't work.
Modified the Code to suit my needs
Code:
_uGrid = mapGridPosition (getPos player);
_gridBlack = ["005128","006128","007128","004129","005129","006129","007129","003130","004130","005130","006130","007130","008130","003131","004131","005131","006131","007131","008131","009131","003132","004132","005132","006132","007132","008132","009132","010132","003133","004133","005133","006133","007133","008133","009133","010133","011133","003134","004134","005134","006134","007134","008134","009134","010134","011134","012134","003135","004135","005135","006135","007135","008135","009135","010135","011135","012135","003136","004136","005136","006136","007136","008136","009136","010136","011136","012136","013136","003137","004137","005137","006137","007137","008137","009137","010137","011137","012137","013137","003138","004138","005138","006138","007138","008138","009138","010138","011138","012138","013138","003139","004139","005139","006139","007139","008139","009139","010139","011139","012139","013139","003140","004140","005140","006140","007140","008140","009140","010140","011140","012140","013140","003140","004140","005140","006140","007140","008140","009140","010140","011140","012140","013140","003141","004141","005141","006141","007141","008141","009141","010141","011141","012141","013141","004142","005142","006142","007142","008142","009142","010142","011142","012142","013142","005143","006143","007143","008143","009143","010143","011143","012143","013143","007144","008144","009144","010144","011144","012144","013144","008145","009145","010145","011145","012145","013145","009146","010146","011146","012146"];
if (_uGrid in _gridBlack) then {
    _world = [[226,[17944.4,19747.1,0.001]],[297,[7026.44,2436.69,8.85e-04]],[115,[6045.51,6251.64,0.002]]];
    _num = (round (random (3)));
    _worlds = _world select _num;
    player setVariable["worldspace",_worlds,true];
};

also tried _uGrid = mapGridPosition player; but it didn't work either.
Any more ideas?
 
still wont work.... damnit what the fuck is wrong there? And yes those are the right coords, checked them two times now
 
If Vampire gives me the permission to use his code (giving credits and stuff) i can write a tutorial for it.
 
Go for it. It's a very simple concept, and very usable.

You should be able to turn _gridBlack into a global and call it from the init.sqf for ease of use.
 
Back
Top