Payday for random player?
#3

How you're going to use it is up to you...Whether you set a timer that goes off every so often or a command. This is the template I would use anyway, there might be a better way.

pawn Код:
new Broke[MAX_PLAYERS], MAX_BROKE=0; //max_players for the possibility everyone is broke (or close..if your server is full)
for(new i=0; i < MAX_PLAYERS; i++) //start our loop
{
    if(IsPlayerConnected(i)) //check if the player who's ID is our current loop index is connected
    {
        if(GetPlayerMoney(i) == 0) //if they are check if they have no money
        {
            //if they do
            Broke[MAX_BROKE] = i; //we use MAX_BROKE as a placeholder for our cell number, then we set that cell to their ID (in our Broke array)
            MAX_BROKE++; //increase the value of our MAX_BROKE variable + 1 so we can use it again as a cell number next time
        }
    }
}
new rand = random(MAX_BROKE); //pick a random number between 0 and the value MAX_BROKE holds
GivePlayerMoney(Broke[rand], 15000); //give the random broke player $15k

/*
    Let's run an unlikely scenario... Say everyone in the server has $0
    What we're going to do is loop through everyone, and do something like this...
   
    Broke[0] = 0;
    Broke[1] = 1;
    Broke[2] = 2;
    Broke[3] = 3;
    ..and so on
   
    If you have say 4 broke players.. ID 2, 6, 19, and 24. It would operate something like this..
   
    Broke[0] = 2;
    Broke[1] = 6;
    Broke[2] = 19;
    Broke[3] = 24;

    Then we randomize which array slot we're using.
   
    random(MAX_BROKE) as seen above is from 0-whatever value MAX_BROKE holds.

    From the example above, it will be 0-3. (0, 1, 2, 3)
   
    Say it was 2, then it will do this
   
    GivePlayerMoney(Broke[2], 15000);
    which will give ID 19 $15,000 as ID 19 is the value in the 2nd (or 3rd) cell.
*/
The second part is a little vague... How much money do you want them to lose?
Reply


Messages In This Thread
Payday for random player? - by Admigo - 20.05.2012, 11:21
Re: Payday for random player? - by HDFord - 20.05.2012, 11:28
Re: Payday for random player? - by [ABK]Antonio - 20.05.2012, 12:01

Forum Jump:


Users browsing this thread: 3 Guest(s)