Jump to content
Sign in to follow this  
nullsystems

SetPos problem and variable on dialog.

Recommended Posts

Is there anyway to use SetPos within an MP enviroment?

Also, any other function that works just like it?

Its so frustrating!

-----

I have another problem also...

1. Dialog activeText sets off a .sqs script

2. This spawns an _ammocrate and fills it.

3. I then only want 1 available before entering a trigger area.

Number 3 is the problem I have. Since the script is being called when you press the button....any variables automatically switch to 0.

eg: ( rough )

_crateAmmount = 0;

if (_crateAmmount < 2) then

{  

_ammocrate = "Reammobox" createvehicle [getpos heli1 select 0,getpos heli1 select 1,getpos heli1 select 2];

_ammocrate addweaponcargo ["Binocular",1];

_crateAmmount = _crateAmmount+1

}

else

{

hint 'Your quota is filled';

};

See what I mean? Each time the script is called fromt he dialog, it will just reset it to 0, any help would be appreciated! THank you biggrin_o.gif

PS: Can you place the IF statement in the ACTION tag of the dialog in description.ext? That would solve it.

Share this post


Link to post
Share on other sites

I just had a thought:

if (objective99 = false) then

{

_ammocrate = "Reammobox" createvehicle [getpos heli1 select 0,getpos heli1 select 1,getpos heli1 select 2];

_ammocrate addweaponcargo ["Binocular",1];

}

else

{

hint 'Your quota is filled';

};

Then, set a trigger at a "reload helipad" to set the trigger at true when activated by heli1

Think that would work?

Share this post


Link to post
Share on other sites

Try using a global variable.

To do so, in your init.sqs/f file declare and define it.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">CRATEAMOUNT = 0;

Then in your function which is called remove the old local variables...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

if (CRATEAMOUNT< 2) then

{  

  _ammocrate = "Reammobox" createvehicle [getpos heli1 select 0,getpos heli1 select 1,getpos heli1 select 2];

  _ammocrate addweaponcargo ["Binocular",1];

  CRATEAMOUNT = CRATEAMOUNT +1;

  if (isServer) then

  {

      publicVariable "CRATEAMOUNT";

  };

};

else

{

   hint 'Your quota is filled';

};

if (true) exitWith {};

What happened here is that local variables are only known to the script. Once the script ends, then that memory is freed. As such, the contents of that variable go back into the bit bucket.

A global variable should remain usable the life of the mission.

To make a global variable, take off the _ from the name.

_crateAmount becomes CRATEAMOUNT for instance.

I use all caps for global variables just to help me keep things in order, it's not necessary though.

One more thing, if this is for a MP type environment... you'll need to publicVariable any variable which needs to be transmitted to the clients. In this case, you'd need to update all the systems that one has been made.

use

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (isServer) then {publicVariable "CRATEAMOUNT"}

I've heard bad things start to happen when you have clients trying to publicVariable something, which is why we make sure only the server does it.

Share this post


Link to post
Share on other sites

wow, excellent example and use of functions there.

Line with 'else ' shows missing ;...odd, shouldnt need one should it ?

I added the ; but now nothing happens in the else section. Really odd.

Also, if I wanted to put the public variables back to 0, I can do that in any script, even that one right?

Share this post


Link to post
Share on other sites

Sorry, didn't have time to check syntax. smile_o.gif I think I might have left a dangling else in the above example.. (these are all just examples by the way, not tested at all. heheh)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

if (CRATEAMOUNT< 2) then

{  

   _ammocrate = "Reammobox" createvehicle [getpos heli1 select 0,getpos heli1 select 1,getpos heli1 select 2];

   _ammocrate addweaponcargo ["Binocular",1];

   CRATEAMOUNT = CRATEAMOUNT +1;

   if (isServer) then

   {

      publicVariable "CRATEAMOUNT";

   }

   else

   {

   };

}

else

{

  hint 'Your quota is filled';

};

if (true) exitWith {};

..and yes, you can change global variables from anywhere, that's what they're designed for. smile_o.gif

Share this post


Link to post
Share on other sites

Very odd. I just tested the last bit of code I gave you, and it worked quite nicely.

I was able to create two ammo boxes, and when trying to make the third it said "Your quota is filled". I set it up with a trigger (radio alpha) that called the .sqf... and used a helo 'H' marker named "heli1".

How've you got it set up?

Share this post


Link to post
Share on other sites

Mine is called from a dialog activetext click. Nothing special. It must be in my syntax or something.

Although I do have some problems with something else.

I have a gameLogic trigger setup eg:

cond: objective1 && objective2

onAct: plane lock false; hint 'plane unlocked'

Nothing special in the editor....

But the plane doesnt unlock for everyone.

I hosted this on my pc, had a friend test...and when he did the objectives....it showed the hint, but didint unlock....

When I did it, it worked perfect.....any ideas?

This is in editor, no scripting.

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  

×