Patou 10 Posted July 21, 2009 Hello, i try to make a rally's mpmission. I made a script that calculate the time done and get the player name. Now i want this script to insert the time of the player in a public list when he cross the line. So i made a publicVariable i called _classement. I declare it in the init.sqf _classement = [];publicVariable "_classement"; nul=[] execVM "briefing.sqf"; My problem is when i want to use this _classement it show only a list of "any" If i change my scripts to use _classement as a local variable it works fine and show what it should. Do i do wrong to declare the publicvariable? Share this post Link to post Share on other sites
fincuan 0 Posted July 21, 2009 (edited) The underline(_) means it's a variable local the the scope in which it's used and can't be declared public. It should be just classement. Also, and I don't know if it's intentional or not, but you're assigning briefing.sqf's scripthandle to a variable called nul, which in my opinion isn't needed here. Edited July 21, 2009 by Fincuan Share this post Link to post Share on other sites
Patou 10 Posted July 21, 2009 Now it works fine. Thank you very much. for the briefing i just copied what i found in tutorial. it works so i didn't search further. Share this post Link to post Share on other sites
Carpaazi 0 Posted July 26, 2009 Wait a minute... question about publicvariable: In multiplayer coop that i am creating, when task1 is succeeded, this kicks in IF (isServer) THEN {"objective1 = 1; PublicVariable "objective1"; blaa blaa blaa} quoting Patou: So i made a publicVariable i called _classement. I declare it in the init.sqf So do i need to "declare" publicvariable "objective1" somewhere before it works correctly? Share this post Link to post Share on other sites
Patou 10 Posted July 27, 2009 Always better to declare public variable at start to avoid errors. My self for ojectives i use boolean variables so i can just put the variable as condition in some triggers or waypoints for AI. Share this post Link to post Share on other sites
xeno 234 Posted July 27, 2009 Always better to declare public variable at start to avoid errors. It depends on what you want to make. If you define a variable that also gets send via publicVariable you have to take care that it doesn't overwrite the state that was send through publicVariable. When a JIP player connects a publicVariable gets also broadcasted to him (state of last executed publicVariable) and defining the variable in init.sqf for example will overwrite the publicVariable value. So you may end up with a wrong value. There are some workarrounds for it. You can use onPlayerConnected to publicVariable the variables again or you can check on the JIP client if the variable allready exists/is defined (isNil "my_public_variable"). Both are fine but sending the vars again in onPlayerConnected is not necessary. Xeno Share this post Link to post Share on other sites
Patou 10 Posted July 27, 2009 (edited) I forgot about jip. This init should work with jip. No? obj0=false; obj1=false; obj2=false; obj3=false; obj4=false; obj5=false; if ( isServer ) then { PublicVariable "obj0"; PublicVariable "obj1"; PublicVariable "obj2"; PublicVariable "obj3"; PublicVariable "obj4"; PublicVariable "obj5"; }; if (isServer) then { onPlayerConnected "[] execVM "update.sqf""; }; [] execVm "briefing.sqf"; with update.sqf being if ( isServer ) then { PublicVariable "obj0"; PublicVariable "obj1"; PublicVariable "obj2"; PublicVariable "obj3"; PublicVariable "obj4"; PublicVariable "obj5"; }; Edited July 27, 2009 by Patou Share this post Link to post Share on other sites
Carpaazi 0 Posted July 27, 2009 Is publicvariable (in my case PublicVariable "objective1"), and IsNil command connected to eachother? I undestand that IsNil/!IsNil command checks if Publicvariable is "true" or not? Share this post Link to post Share on other sites
Big Dawg KS 6 Posted July 27, 2009 IsNil checks if the variable exists (as in has had some value assigned to it at some point, since that's the only way to create new variables), whether public of private. Share this post Link to post Share on other sites
Carpaazi 0 Posted July 27, 2009 So when task1 is completed, and PublicVariable "objective1" kicks in, the (!IsNil objective1) in the briefing should show the task2? waitUntil { !isNil {player} }; waitUntil { player == player }; switch (side player) do { case WEST: // BLUFOR briefing goes here { player createDiaryRecord["Diary", ["Info", ""]]; player createDiaryRecord["Diary", ["Enemy forces", ""]]; player createDiaryRecord["Diary", ["Friendly forces", ""]]; player createDiaryRecord["Diary", ["Mission", ""]]; player createDiaryRecord["Diary", ["Situation", ""]]; // Second Objective IF (!isnil objective1) THEN { task2 = player createSimpleTask["The train"]; task2 setSimpleTaskDescription["...", "...", "..."]; task2 setSimpleTaskDestination markerpos ""; if (!isnil objective2) then {task2 setTaskState "Succeeded"; "obj2" setmarkercolorlocal "ColorGreen"; "obj2" setmarkertextlocal "Wagons destroyed!"} else {task2 setTaskState "Created"; task2 setSimpleTaskDestination (getMarkerPos "obj2"); }; // Primary Objective task1 = player createSimpleTask["Convoy"]; task1 setSimpleTaskDescription["Russian convoy just left <marker name='obj1start'>Berezino</marker> docks, and is taking the main road to <marker name='obj1kohde'>Elektrozavodsk</marker>. APC is in lead of the convoy, followed by two trucks carrying soldiers, and the last two trucks are service vehicles. Destroy at least the APC and service vehicles. Find a good ambush site near <marker name='lz'>LZ</marker>.", "Ambush convoy", "Ambush"]; task1 setSimpleTaskDestination markerpos "obj1"; if (!isnil objective1) then {task1 setTaskState "Succeeded";"obj1" setmarkercolorlocal "ColorGreen";"obj1start" setmarkercolorlocal "ColorGreen"; "obj1kohde" setmarkercolorlocal "ColorGreen"} else {task1 setTaskState "Created"; task1 setSimpleTaskDestination (getMarkerPos "obj1");}; }; case EAST: // REDFOR briefing goes here { }; case RESISTANCE: // RESISTANCE/INDEPENDENT briefing goes here { }; case CIVILIAN: // CIVILIAN briefing goes here { }; }; // run this file again when respawning (only setup the killed EH once though) if ( isNil{player getVariable "mk_killedEHadded"} ) then { player addEventHandler ["killed", { [] spawn { waitUntil { alive player }; // waitUntil player has respawned execVM "briefing.sqf"; }; }]; player setVariable ["mk_killedEHadded", true]; I also need someone to tell me where i need to place { }, because tasklist didn't show either task in game where ever i tried to put } after this line in code: IF (!isnil objective1) THEN {... Share this post Link to post Share on other sites