Jump to content
  • 0

Usage of the RANDOM variable


Proximus

Question

I would like to know if is possible to do the following:

 

EXAMPLE: round(random 8) * 10

 

The random is between 0 and 8.

 

We use this to put random coins on AI.

But when a player checks and AI's wallet and it returns 0 coins (so random = 0), the players money is not being saved anymore and he/she needs to relog to get the correct amount again.

 

So i would like the Random to always return at least 1.

 

Hope it's clear and i hope you guys can help me :)

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Using this from Zupa:

 

 

 

change

        _unit enableAI "TARGET";
        _unit enableAI "AUTOTARGET";
        _unit enableAI "MOVE";
        _unit enableAI "ANIM";
        _unit enableAI "FSM";
        _unit setCombatMode ai_combatmode;
        _unit setBehaviour ai_behaviour;
        removeAllWeapons _unit;
        removeAllItems _unit;
        _unit addweapon _weapon;

to 

        _unit enableAI "TARGET";
        _unit enableAI "AUTOTARGET";
        _unit enableAI "MOVE";
        _unit enableAI "ANIM";
        _unit enableAI "FSM";
        _unit setCombatMode ai_combatmode;
        _unit setBehaviour ai_behaviour;
        removeAllWeapons _unit;
        removeAllItems _unit;
        _unit addweapon _weapon;

// Soul Hive
        _unit setVariable["CashMoney",5000,true];
// 999 Hive
_unit setVariable["headShots",5000,true];

Or how much cash u want, i put 5000 now, change that number to your likings

 

 

If u want like random generated cash try this:

 

Between 0 to 20000 ( always +1000)

        _unit enableAI "TARGET";
        _unit enableAI "AUTOTARGET";
        _unit enableAI "MOVE";
        _unit enableAI "ANIM";
        _unit enableAI "FSM";
        _unit setCombatMode ai_combatmode;
        _unit setBehaviour ai_behaviour;
        removeAllWeapons _unit;
        removeAllItems _unit;
        _unit addweapon _weapon;


_cash = round(random 20) * 1000; // number between 0 and 20 000

// Soul Hive
        _unit setVariable["CashMoney",_cash ,true];
// 999 Hive
_unit setVariable["headShots",_cash ,true];

 

Link to comment
Share on other sites

  • 0

Yes, as I said. If it does not matter that you don't get all the numbers between 0 and 200, take what you have.

If it matters, don't take it ,)

I guess Zupa wanted 1000,2000,3000 and so on only. He cannot get other values. Random x gets you a number between 0 and x. If you multiply that with something else (e.g. 2 as the lowest next meaningful number) you already only get half of the numbers between 0 and x.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...