Help please -
bartje01 - 15.07.2010
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
Re: Help please -
Vince - 15.07.2010
This (apart from that you're using strtok):
pawn Код:
if(GetPlayerMoney(playerid) < cashamount) SendClientMessage(playerid, COLOR_RED, "Not enough money");
{
Re: Help please -
bartje01 - 15.07.2010
I don't understand xD Can you fix the cmd for me? Than I will see it
Re: Help please -
oliverrud - 15.07.2010
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;
}
Re: Help please -
bartje01 - 15.07.2010
still doesnt work.
It shows me this:USAGE: /pay [playerid] [amount]
Re: Help please -
oliverrud - 15.07.2010
You wrote both playerid & amount right?
Re: Help please -
bartje01 - 15.07.2010
Well. You can see that in my command :P
Re: Help please -
oliverrud - 15.07.2010
I meant you, when you tested it.
Re: Help please -
Joe_ - 15.07.2010
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;
}
Re: Help please -
bartje01 - 15.07.2010
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.