05.01.2012, 04:05
I'm still learning to code, so I looked up a /pay command tutorial. Followed the steps, and I get 4 errors upon compiling.
Here is my code.
Error codes.
If anyone could provide an answer of why I'm getting these errors, it would be greatly appreciated. I will +Rep.
Here is my code.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new idx[256];
new cmd[256];
cmd = strtok(cmd, idx,
if(strcmp("/pay", cmd, true, 10) ==0)
{
new tmp[256], tmp2[256];
tmp = strtok(cmdtext, idx,
tmp2 = strtok(cmdtext, idx, //money
}
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_GREY, "Usage: /pay [playerid] [amount]");
return 1;
}
if(strlen(tmp2))
{
SendClientMessage(playerid, COLOR_GREY, "Usage: /pay [playerid] [amount]");
return 1;
}
new reciever, money;
reciever = strval(tmp);
money = strval(tmp2);
if(GetPlayerMoney(playerid) < money)
{
SendClientMessage(playerid, COLOR_GREY, "You don't have that much!");
return 1;
}
new string[128];
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
new playername2[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername2, sizeof(playername2));
format(string, sizeof(string), "You recieved &%d from %s.", money, playername);
SendClientMessage(playerid, COLOR_GREY, string);
format(string, sizeof(string), "You gave &%d to %s.", money, playername);
SendClientMessage(playerid, COLOR_GREY, string);
GivePlayerMoney(playerid, (0 - money));
GivePlayerMoney(reciever, money);
strtok(const string[], &index) {
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
return 1;
}
Код:
C:\Documents and Settings\Administrator\My Documents\My DM from scratch\gamemodes\new.pwn(236) : error 017: undefined symbol "strtok" C:\Documents and Settings\Administrator\My Documents\My DM from scratch\gamemodes\new.pwn(236 -- 238) : error 029: invalid expression, assumed zero C:\Documents and Settings\Administrator\My Documents\My DM from scratch\gamemodes\new.pwn(238 -- 239) : error 029: invalid expression, assumed zero C:\Documents and Settings\Administrator\My Documents\My DM from scratch\gamemodes\new.pwn(238 -- 239) : fatal error 107: too many error messages on one line Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 4 Errors.