Jump to content

Recommended Posts

in my mission im building i have objectives being created dynamicly during mission..

so i set objective1 false in init and so on...

everything works well unitil i host up dedicated and i need the player to get the updated var....

so i settup a jip.sqf called from a trigger in game with condition local player

example from arma commands getvariable

_aVariable = _myTruck getVariable "myVariable";

problem is i have no clue how to use this command in the context that i need need it to be...

sorry i know probably a newb quetion, some things i have a good grasp on, others im still newb...

---------- Post added at 02:00 PM ---------- Previous post was at 01:40 PM ----------

or maye its the way im declaring objective1 true?

objective1 = true; publicVariable "objective1";

either way when a player jips on on dedi i need him to get all the vars the server has set..

Share this post


Link to post
Share on other sites

You need to have something like this:

In init.sqf on the server:

onPlayerConnected
"
  publicVariable 'varName1';
  publicVariable 'varName2';
  .....
";

And then every time you set the value of varName1 on the server you need to do:

varName1 = true;
publicVariable "varName1";

That way as long as the clients don't mess with the variable value they'll always have the same value as the server does.

getVariable is a completely unrelated command meant to obtain values that were set earlier with setVariable.

Share this post


Link to post
Share on other sites

so your saying in my init which is like this without any is server check or anything

objective1 = false;

objective2 = false;

objective3 = false;

objective4 = false;

objective5 = false;

isnt being broadcasted to each jipping player

but i need to do this?

onplayerconnected {

objective1 = false;

objective2 = false;

objective3 = false;

objective4 = false;

objective5 = false;

};

because im already declaring this during mission

objective1 = true; publicVariable "objective1";

---------- Post added at 02:19 PM ---------- Previous post was at 02:15 PM ----------

and when i declare

objective1 = true or anyother objective its being picked random on server side only, so when i do publicvariable is it still being broadcasted public even though its being broadcasted inside

if (isServer) then

{

??

---------- Post added at 02:24 PM ---------- Previous post was at 02:19 PM ----------

err i didnt see you were declaring publicvariable in init, doesnt that set it to true?

---------- Post added at 02:25 PM ---------- Previous post was at 02:24 PM ----------

what if it isnt true yet?

---------- Post added at 03:03 PM ---------- Previous post was at 02:25 PM ----------

this worked well thankyou

onplayerconnected "

publicVariable 'objective1';

publicVariable 'objective2';

publicVariable 'objective3';

publicVariable 'objective4';

publicVariable 'objective5';

publicVariable 'objectivetrigger1';

publicVariable 'objectivetrigger2';

publicVariable 'objectivetrigger3';

publicVariable 'objectivetrigger4';

publicVariable 'objectivetrigger5';

"

;

Share this post


Link to post
Share on other sites

If your checking a variable that haven't been set to true it's considered false, so don't set your variables in the init.sqf. Clients that JIP will assume that the variables are false but if server at one point has set them to true and published them with publicVariable then it will be broadcasted to the JIPs as soon as they join. Dont hang me up on this though :p

Share this post


Link to post
Share on other sites

yea im still having problems, the onplayer conected worked for me on dedi or reg hos, but jipping in players dont get the update...

ill give your way a try jw...

---------- Post added at 04:14 PM ---------- Previous post was at 04:06 PM ----------

jw your method works without declaring the var to false in init and server , still have a major jip issue though...

Share this post


Link to post
Share on other sites

It's not that complicated.

objective1 = true; publicVariable "objective1";

That's enough, no onplayerconnect or false declarations needed.

If/when you need to use/check the variable, you can do it in a trigger straight away. In scripts you should use isnil "objective1".

Share this post


Link to post
Share on other sites

Most of the time undefined variables seem to be false, but in some cases it just gives an error or flat out does other weird sh*t, so you're better off making sure your variables are always initialized.

When you change the value of any variable it'll only change on that specific computer unless you publicVariable it after changing its value. For objective-related variables it's best to initialize them on the server and then publicVariable them immediately to all connected players and then also publicVariable them in the onPlayerConnected so that JIP players will have them updated too.

Share this post


Link to post
Share on other sites

so when my server gets a random objective from a list so

if (isServer) then

{};

and when i do

switch (_dummy) do

{

a case for each different obj..

and inside that case the var is given

objective1 = true; publicVariable "objective1";

is the var objective1 still gonna be broadcasted? being that its being declared from the isserver?

Share this post


Link to post
Share on other sites

It will be broadcast because you did publicVariable "objective1"; to all players that are connected at the moment, but AFAIK JIP players will need to have the server publicVariable it again after they join (normally done via onPlayerConnected).

Share this post


Link to post
Share on other sites
It will be broadcast because you did publicVariable "objective1"; to all players that are connected at the moment, but AFAIK JIP players will need to have the server publicVariable it again after they join (normally done via onPlayerConnected).

Wrong :)

Every variable processed by publicVariable will get transfered to JIP players (latest publicvariabled state).

But... if you define a default value for the var in init.sqf it will overwrite the allready broadcasted value for JIP players again.

So there is no need to send variables again in onPlayerConnected, just don't use default values in init.sqf for pv variables or do a nil check or pv them immediately on the server only at mission start.

Xeno

Share this post


Link to post
Share on other sites
Every variable processed by publicVariable will get transfered to JIP players (latest publicvariabled state).

But... if you define a default value for the var in init.sqf it will overwrite the allready broadcasted value for JIP players again.

So there is no need to send variables again in onPlayerConnected, just don't use default values in init.sqf for pv variables or do a nil check or pv them immediately on the server only at mission start.

Xeno

That actually very helpful Xeno, thanks for that. I've suffered recently from lack of understanding this cleary.

Share this post


Link to post
Share on other sites

Interesting, it may be worth adding to the wiki ;)

Anyway, yeah, only define the default values for the variable on the server or else you can get all kinds of trouble.

This still doesn't solve my issue with players not getting their loadouts when the JIP during briefing into a group with a human leader :(

Share this post


Link to post
Share on other sites

It's actually in the talk page of publicVariable on the biki gal. Also using onPlayerConnected is a bad thing too since you're setting what to do when a player connects, you're not adding it to some list, so unknowingly you could be messing something up.

And btw, the gear script issues you're having is because you're using a obsolete gear script imho. You really should reconsider killswitch's idea; my own interpretation of it has been working fine for months now.

Share this post


Link to post
Share on other sites

makes sense xeno thanks...

im still a little stuck however..

in my mission i have objectives being created, a alot like dom but different cases fo each objective...the obj,s are being picked and created server side only..no problem here.

problem is i have a trigger in game saying if objective 1 called then sets that obj active for player....

objective 1 called is being broadcasted public but within server side...

everything works even on dedi for the first player joining but jip players dont seem to be getting the pubvar......

Share this post


Link to post
Share on other sites

objective 1 called is being broadcasted public but within server side...

everything works even on dedi for the first player joining but jip players dont seem to be getting the pubvar......

If a variable is being broadcasted from server it will get updated on all clients also JIPs.

Share this post


Link to post
Share on other sites

eh thanks fellas all the info didnt fix the problem but the info allowed me to track down the problem......

so the problem was the initial objective of wait for orders created in the init was after a

if ((!isServer) && (player != player)) then

{

waitUntil {player == player};

};

so the initial objective was overwriting the new objectives for jip.........

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×