Jump to content
Sign in to follow this  
_.Dardo._

Percent system

Recommended Posts

Hello,i'd like to set some arrays basing on some percents, the problem is that those arrays/percents should be set globally,as every player should have the same reference to the same object.

Does anyone have any ideas? I've tried setting percents locally,but doing like this every player is going to have different arrays .

Could someone post any kind of pseudocode just for pointing me to the right direction?

Thank you for helping.

Share this post


Link to post
Share on other sites

Im spanish and I don't understand well what you mean with "arrays basing on some percents"

 

But I can say:

 

arrayVariable = ["hello","bye"];

publicVariable "arrayVariable";

 

everybody will have ["hello","bye"]

  • Like 1

Share this post


Link to post
Share on other sites

Im spanish and I don't understand well what you mean with "arrays basing on some percents"

But I can say:

arrayVariable = ["hello","bye"];

publicVariable "arrayVariable";

everybody will have ["hello","bye"]

For example:

_p= floor random 100;

switch (true) do {

case (_p < 10) : { _weaponpercent = ["coolweapon1", "coolweapon2"]};

case ((_p > 10) && (_p > 15)) : { _weaponpercent = [" Verycoolweapon1", "Verycoolweapon2"]};

I mean,my way sucks so hard ,so if you have something better to do those percents D:

This should give 10% to the first case and 5% to the second.

Share this post


Link to post
Share on other sites

You cannot make variables public for every pc if the variable is local even for the script is in.

 

So, the variable should be weaponpercent instead of _weaponpercent

 

And then, after the assign, all you have to do is:

 

publicVariable "weaponpercent";

 

Now all the PCs will have the same values.

 

Execute this only on the server, if not, each PC will execute the code, with different results for _p, with different values for weaponpercent, running across the network, all very messy, ok?

  • Like 1

Share this post


Link to post
Share on other sites

this is also not working  it should read  _p<15

case ((_p > 10) && (_p > 15)) : { _weaponpercent = [" Verycoolweapon1", "Verycoolweapon2"]};

 

 

slightly simpler way

 

_p= floor random 100;

switch (true) do {

case (_p < 5) : { _weaponpercent = ["coolweapon1", "coolweapon2"]};// 5%
case (_p <15): { _weaponpercent = [" Verycoolweapon1", "Verycoolweapon2"]};//10%

};

  • Like 1

Share this post


Link to post
Share on other sites

I believe I read a few updates ago that setVariable can now broadcast namespace variables, so honestly, if you actually read davidoss' links, you'd have seen that's exactly what you are looking for.

 

Pseudocode:

First Player:

Here is my array

Now I will broadcast my array

Second Player:

I need to use that array for something, let me grab it

 

Actual code:

//First player
_myArray = [0.90, 0.23, 0.58]; //here is my array
missionNamespace setVariable ["MyArray", _myArray, true]; //now I will broadcast my array

//Second player
_myArray = missionNamespace getVariable "MyArray"; //I need to use that array for something, let me grab it

If that fails, then barbolani's publicVariable method will work just as well.

 

Also, not sure if that switch statement will ever do what you want it to. You'd be much better off with nested if's (this game really needs "else if")

  • Like 1

Share this post


Link to post
Share on other sites

I believe I read a few updates ago that setVariable can now broadcast namespace variables, so honestly, if you actually read davidoss' links, you'd have seen that's exactly what you are looking for.

Pseudocode:

First Player:

Here is my array

Now I will broadcast my array

Second Player:

I need to use that array for something, let me grab it

Actual code:

//First player_myArray = [0.90, 0.23, 0.58]; //here is my arraymissionNamespace setVariable ["MyArray", _myArray, true]; //now I will broadcast my array//Second player_myArray = missionNamespace getVariable "MyArray"; //I need to use that array for something, let me grab it
If that fails, then barbolani's publicVariable method will work just as well.

Also, not sure if that switch statement will ever do what you want it to. You'd be much better off with nested if's (this game really needs "else if")

So you reccomend me to use if & else instead of switch cases?

Share this post


Link to post
Share on other sites

missionNamespace and setVariable will not broadcast the variable with true on the end! use publicVariable instead!

Share this post


Link to post
Share on other sites

missionNamespace and setVariable will not broadcast the variable with true on the end! use publicVariable instead!

I Need to broadcast only a number,from what i read on the wiki it should work

Share this post


Link to post
Share on other sites

Well so,everything is working fine. By the way,i know that the select random function,actually is not that 'random', so i'm wondering: using www.random.org APIs,would it be possible to integrate their scripts into arma using any kind of addons? I know this is a weird question,but i'd like to make my script more 'random'. Thank you all for answers.

Share this post


Link to post
Share on other sites

If you can predict a 100% times the result of a 50% random pick, then I will pay you 100 K € and we go together to hack some online casino...

  • Like 1

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  

×