Help please
#1

Hey guys, Whats wrong with my /pay commanD?
pawn Код:
if (strcmp(cmd, "/pay", true) == 0)
    {

        new giveplayerid = strval(tmp);
      tmp = strtok(cmdtext, idx);
        giveplayerid = strval(tmp);
        new cashamount = strval(tmp2);
        if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pay [playerid] [amount]");
        if(!strlen(tmp2)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pay [playerid] [amount]");
        if(GetPlayerMoney(playerid) < cashamount) SendClientMessage(playerid, COLOR_RED, "Not enough money");
        {
       
        GivePlayerMoney(giveplayerid,cashamount);
        GivePlayerMoney(playerid,-cashamount);
        GetPlayerName(giveplayerid,playername,sizeof(playername));
        format(string,sizeof(string),"You sended %s %d money",playername,cashamount);
        SendClientMessage(playerid,COLOR_YELLOW,string);
       
        GetPlayerName(playerid,playername,sizeof(playername));
        format(string,sizeof(string),"%s has given you %d money.",playername,cashamount);
        SendClientMessage(giveplayerid,COLOR_YELLOW,string);

        }
        return 1;
 }
I also want that you can't give yourself money :P
I thought it was like:
if(ID == playerid) return SendClientMessage(giveplayerid,COLOR_YELLOW,"You can't give yourself money!");

Thanks
Reply
#2

This (apart from that you're using strtok):
pawn Код:
if(GetPlayerMoney(playerid) < cashamount) SendClientMessage(playerid, COLOR_RED, "Not enough money");
{
Reply
#3

I don't understand xD Can you fix the cmd for me? Than I will see it
Reply
#4

pawn Код:
if (strcmp(cmd, "/pay", true) == 0)
    {

        new giveplayerid = strval(tmp);
      tmp = strtok(cmdtext, idx);
        giveplayerid = strval(tmp);
        new cashamount = strval(tmp2);
        if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pay [playerid] [amount]");
        if(!strlen(tmp2)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pay [playerid] [amount]");
        if(GetPlayerMoney(playerid) < cashamount) SendClientMessage(playerid, COLOR_RED, "Not enough money");
else
        {
       
        GivePlayerMoney(giveplayerid,cashamount);
        GivePlayerMoney(playerid,-cashamount);
        GetPlayerName(giveplayerid,playername,sizeof(playername));
        format(string,sizeof(string),"You sended %s %d money",playername,cashamount);
        SendClientMessage(playerid,COLOR_YELLOW,string);
       
        GetPlayerName(playerid,playername,sizeof(playername));
        format(string,sizeof(string),"%s has given you %d money.",playername,cashamount);
        SendClientMessage(giveplayerid,COLOR_YELLOW,string);

        }
        return 1;
 }
Reply
#5

still doesnt work.
It shows me this:USAGE: /pay [playerid] [amount]
Reply
#6

You wrote both playerid & amount right?
Reply
#7

Well. You can see that in my command :P
Reply
#8

I meant you, when you tested it.
Reply
#9

I only ever use ZCMD and SSCANF2, you'll have to figure it out yourself if you want it in strtok and strcmp bart.

pawn Код:
CMD:pay(playerid, params[])
{
    new
        id, Amount;

    if(sscanf(params, "ud", id, Amount)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pay [playerid] [amount]");
    if(GetPlayerMoney(playerid) < Amount) return SendClientMessage(playerid, COLOR_RED, "Not enough money");
    if(playerid == id) return SendClientMessage(playerid, COLOR_RED, "Can't send yourself cash");
   
    GetPlayerName(giveplayerid,playername,sizeof(playername));
    GivePlayerMoney(giveplayerid,cashamount);
    GivePlayerMoney(playerid,-cashamount);
   
    format(string,sizeof(string),"You sent %s $%d",playername,cashamount);
    SendClientMessage(playerid,COLOR_YELLOW,string);

    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),"%s has sent you $%d",playername,cashamount);
    SendClientMessage(giveplayerid,COLOR_YELLOW,string);
   
    return 1;
}
Reply
#10

So ZCMD is really easier? Can you please teach me how to do ZCMD? I know nothing about it. I will really apreciate it or something .
I heard that strpcmd is kinda slow and such things.
I want to learn ZCMD. Please help.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)