Getting Players, Then turn into value
#1

How do i get All players online..

Then use them into a value amount?

like..

10 players = $10000
9 players = $9000
19 players = $19000..


So then i can use it in a GivePlayerMoney(playerid, money);

And also a format string..

format(string, sizeof(string), "[SERVER]: What Is %d%s%d%s%d? - Type /answer to answer this question! Worth %d score and $d!", number1, addsubtext1, number2, addsubtext2, number3, score, money);

So how can i do this?
Reply
#2

Quote:
Originally Posted by © HungryPinkPig ©
How do i get All players online..

Then use them into a value amount?

like..

10 players = $10000
9 players = $9000
19 players = $19000..


So then i can use it in a GivePlayerMoney(playerid, money);

And also a format string..

format(string, sizeof(string), "[SERVER]: What Is %d%s%d%s%d? - Type /answer to answer this question! Worth %d score and $d!", number1, addsubtext1, number2, addsubtext2, number3, score, money);

So how can i do this?
Add This function in your script:
pawn Код:
stock GetOnlinePlayers(){
    new players = 0;
    for(new i = 0; i<GetMaxPlayers();i++){
      if(IsPlayerConnected(i)){
        players++;
      }
    }
    return players;
}
Then use it like this:
pawn Код:
new money = GetOnlinePlayers()*1000;
format(string, sizeof(string), "[SERVER]: What Is %d%s%d%s%d? - Type /answer to answer this question! Worth %d score and $d!", number1, addsubtext1, number2, addsubtext2, number3, score, money);
It should work.
Reply
#3

Why don't you start using foreach, that is an include which is much more efficient than normal loops. And you can use Itter_Count(Player) to receive the amount of online players at the moment.

That would make your code:

pawn Код:
format(string, sizeof(string), "[SERVER]: What Is %d%s%d%s%d? - Type /answer to answer this question! Worth %d score and $d!", number1, addsubtext1, number2, addsubtext2, number3, score, Itter_Count(Player)*1000);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)