Help with /pay command
#1

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 : error 017: undefined symbol "strtok"
C:\Users\Chrille\Desktop\gta Sa-mp\gamemodes\new.pwn(70 : error 017: undefined symbol "dx"
C:\Users\Chrille\Desktop\gta Sa-mp\gamemodes\new.pwn(70 : error 029: invalid expression, assumed zero
C:\Users\Chrille\Desktop\gta Sa-mp\gamemodes\new.pwn(70 : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#2

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
Reply
#3

ok thanks bro
Reply
#4

C:\Users\Chrille\Desktop\gta Sa-mp\filterscripts\pay.pwn(1 : warning 203: symbol is never used: "CMD_setcash"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning.
Reply
#5

Quote:
Originally Posted by magent
Посмотреть сообщение
C:\Users\Chrille\Desktop\gta Sa-mp\filterscripts\pay.pwn(1 : warning 203: symbol is never used: "CMD_setcash"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning.
Show the lines mate.
Reply
#6

#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);
}
Reply
#7

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!
Reply
#8

But i have zcmd
Reply
#9

I got zcmd in my include. I downloaded sscanf again but it still not working ://
Reply
#10

ZCMD format is like this:

pawn Код:
CMD:setcash(playerid,params[])
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)