Give money help
#1

Hello , i am making a /payday command , i'm trying to send $5000 to all players when an admin types it

Here's the code , can you show me what should i add ?

PHP код:
if (strcmp("/payday"cmdtexttrue10) == 0)
    {
        if(
IsPlayerAdmin(playerid))
        {
                 
//I Need to add here , how to send $5000 to all players
        
}
        else
        {
        
SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
        }
        return 
1;
    } 
Reply
#2

pawn Код:
if (strcmp("/payday", cmdtext, true, 10) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
            for(new i; i< MAX_PLAYERS; i++)
            {
                GivePlayerMoney(i,5000);
            }                //I Need to add here , how to send $5000 to all players
        }
        else
        {
        SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
        }
        return 1;
    }
Reply
#3

Thanks a lot , i'll try this
Reply
#4

Also change this
pawn Код:
if (strcmp("/payday", cmdtext, true, 10) == 0)
to this
pawn Код:
if (strcmp("/payday", cmdtext, true, 6) == 0)
Reply
#5

Quote:
Originally Posted by Cale
Посмотреть сообщение
Also change this
pawn Код:
if (strcmp("/payday", cmdtext, true, 10) == 0)
to this
pawn Код:
if (strcmp("/payday", cmdtext, true, 6) == 0)
There are 7 characters in that string, so if you type /payda, the command will be processed! Why bother specifying a length at all? It won't achieve anything extra in this code!

pawn Код:
if (strcmp("/payday", cmdtext, true) == 0)
Should suffice
Reply
#6

Quote:
Originally Posted by Cale
Посмотреть сообщение
Also change this
pawn Код:
if (strcmp("/payday", cmdtext, true, 10) == 0)
to this
pawn Код:
if (strcmp("/payday", cmdtext, true, 6) == 0)
Wel To this
pawn Код:
if (strcmp("/payday", cmdtext, true, 7) == 0)
it's 7 Words not 6 :P
Reply
#7

What will change ? i made it 10 and it's working fine?
Reply
#8

Just change it to the one of JaOfNietDan.
Reply
#9

Quote:
Originally Posted by Soumi
Посмотреть сообщение
What will change ? i made it 10 and it's working fine?
Nothing, but why do you bother specifying a length at all? It will automatically stop comparing when it reaches a null character. So why go to the effort of specifying a length, it doesn't do anything in your code, and if you keep specifying a specific length of 10, and you make a command that is longer than 10 characters long, it will cause problems, so it's not the best of habits to be keeping.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)