SA-MP Forums Archive
Give money help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Give money help (/showthread.php?tid=242085)



Give money help - Soumi - 19.03.2011

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;
    } 



Re: Give money help - StreetGT - 19.03.2011

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;
    }



Re : Give money help - Soumi - 19.03.2011

Thanks a lot , i'll try this


Re: Give money help - PinkFloydLover - 19.03.2011

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



Re: Give money help - JaTochNietDan - 19.03.2011

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


Re: Give money help - Roomeo - 19.03.2011

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


Re : Give money help - Soumi - 19.03.2011

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


Re: Give money help - Biesmen - 19.03.2011

Just change it to the one of JaOfNietDan.


Re: Re : Give money help - JaTochNietDan - 19.03.2011

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.