23.03.2009, 20:48
Hi! when i insert /givecash cmd in my GM then i hvae 4 errors in one line!
there is my /givecash
and bottom of the script:
Whats wrong?
there is my /givecash
Код:
if(strcmp(cmd, "/givecash", true) == 0) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]"); return 1; } giveplayerid = strval(tmp); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]"); return 1; } moneys = strval(tmp); //printf("givecash_command: %d %d",giveplayerid,moneys); if (IsPlayerConnected(giveplayerid)) { GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); GetPlayerName(playerid, sendername, sizeof(sendername)); playermoney = GetPlayerMoney(playerid); if (moneys > 0 && playermoney >= moneys) { GivePlayerMoney(playerid, (0 - moneys)); GivePlayerMoney(giveplayerid, moneys); format(string, sizeof(string), "You have sent %s (id: %d), $%d.", giveplayer,giveplayerid, moneys); SendClientMessage(playerid, COLOR_YELLOW, string); format(string, sizeof(string), "You have recieved $%d from %s (id: %d).", moneys, sendername, playerid); SendClientMessage(giveplayerid, COLOR_YELLOW, string); printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid); } else { SendClientMessage(playerid, COLOR_YELLOW, "Invalid transaction amount."); } } else { format(string, sizeof(string), "%d is not an active player.", giveplayerid); SendClientMessage(playerid, COLOR_YELLOW, string); } return 1; }
Код:
stock 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; }