Help with /pay command -
magent - 30.12.2012
Hello i created this command so other players can give money to eachother.
new idx;
new cmd[256];
cmd = strtok(cmdtext, 1dx);
if(strcmp(cmd, "/money", true) == 0) {
return 1;
}
if(strcmp(cmd, "/pay", true) == 0) {
new tmp[256], temp2[256];
tmp = strtok(cmdtext, idx);
tmp2 = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_YELLOW, "Usage: /pay [ID] [amount]");
return 1;
}
if(!strlen(tmp2)) {
SendClientMessage(playerid, COLOR_YELLOW, "Usage: /pay [ID] [amount]");
return 1;
}
new receiver, money;
receive = strval(tmp);
money = strval(tmp2)
if(GetPlayerMoney(playerid, < money){
SendClientMessage(playerid, COLOR_YELLOW, "The amount you typed in is higher than the amount of cash you have.");
return 1;
}
new string[128];
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
new playername2[MAX_PLAYER_NAME];
GetPlayerName(receiver, playername2, sizeof(playername2));
format(string, sizeof(string), "You receive $%d from %s.", money, playername);
SendClientMessage(playerid, COLOR_YELLOW, string);
format(string, sizeof(string), "You give $%d to %s.", money, playername2);
SendClientMessage(playerid, COLOR_YELLOW, string);
GivePlayerMoney(playerid, (o - money));
GivePlayerMoney(receiver, money);
return 1;
}
When i compile it, it says:
C:\Users\Chrille\Desktop\gta Sa-mp\gamemodes\new.pwn(70
![Cool](images/smilies/cool.gif)
: error 017: undefined symbol "strtok"
C:\Users\Chrille\Desktop\gta Sa-mp\gamemodes\new.pwn(70
![Cool](images/smilies/cool.gif)
: error 017: undefined symbol "dx"
C:\Users\Chrille\Desktop\gta Sa-mp\gamemodes\new.pwn(70
![Cool](images/smilies/cool.gif)
: error 029: invalid expression, assumed zero
C:\Users\Chrille\Desktop\gta Sa-mp\gamemodes\new.pwn(70
![Cool](images/smilies/cool.gif)
: fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Re: Help with /pay command -
Feastahashi - 30.12.2012
I'd suggest you to use ZCMD and SSCANF, really faster. Look an example:
PS: I already had this command on my old script
pawn Код:
CMD:setcash(playerid,params[])
{
new id,value;
new string[128];
if(sscanf(params,"ui",id,value)) return Msg(playerid,color,""#red"USAGE: "#green"/setcash <id> <value>");
if(!IsPlayerConnected(id)) return Msg(playerid,color,NOT_CONNECTED);
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,value);
format(string,sizeof(string),""#red"[ADMIN]: %s (id: %d) "#ice"has set your cash for "#blue"%i$",GetMyName(playerid),playerid,value);
return Msg(id,color,string);
}
Sscanf download:
https://sampforum.blast.hk/showthread.php?tid=120356
ZCMD download:
https://sampforum.blast.hk/showthread.php?tid=91354
Re: Help with /pay command -
magent - 30.12.2012
ok thanks bro
Re: Help with /pay command -
magent - 30.12.2012
C:\Users\Chrille\Desktop\gta Sa-mp\filterscripts\pay.pwn(1
![Cool](images/smilies/cool.gif)
: warning 203: symbol is never used: "CMD_setcash"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.
Re: Help with /pay command -
Vinninho - 30.12.2012
Quote:
Originally Posted by magent
C:\Users\Chrille\Desktop\gta Sa-mp\filterscripts\pay.pwn(1 ![Cool](images/smilies/cool.gif) : warning 203: symbol is never used: "CMD_setcash"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.
|
Show the lines mate.
Re: Help with /pay command -
magent - 30.12.2012
#include <a_samp>
CMD_setcash(playerid,params[])
{
new id,value;
new string[128];
if(sscanf(params,"ui",id,value)) return Msg(playerid,color,""#red"USAGE: "#green"/setcash <id> <value>");
if(!IsPlayerConnected(id)) return Msg(playerid,color,NOT_CONNECTED);
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,value);
format(string,sizeof(string),""#red"[ADMIN]: %s (id: %d) "#ice"has set your cash for "#blue"%i$",GetMyName(playerid),playerid,value );
return Msg(id,color,string);
}
Re: Help with /pay command -
Vinninho - 30.12.2012
Quote:
Originally Posted by magent
#include <a_samp>
CMD_setcash(playerid,params[])
{
new id,value;
new string[128];
if(sscanf(params,"ui",id,value)) return Msg(playerid,color,""#red"USAGE: "#green"/setcash <id> <value>");
if(!IsPlayerConnected(id)) return Msg(playerid,color,NOT_CONNECTED);
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,value);
format(string,sizeof(string),""#red"[ADMIN]: %s (id: %d) "#ice"has set your cash for "#blue"%i$",GetMyName(playerid),playerid,value );
return Msg(id,color,string);
}
|
Download ZCMD, you made a look a like ZCMD, while you don't have the include. Download ZCMD and change
Код:
CMD_setcash(playerid,params[])
to
Код:
CMD:setcash(playerid,params[])
It should work fine after that!
Re: Help with /pay command -
magent - 30.12.2012
But i have zcmd
Re: Help with /pay command -
magent - 30.12.2012
I got zcmd in my include. I downloaded sscanf again but it still not working ://
Re: Help with /pay command -
Feastahashi - 30.12.2012
ZCMD format is like this:
pawn Код:
CMD:setcash(playerid,params[])