[ERROR] GiveCash
#1

Script:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp(cmd, "/givecash", true) == 0) {                    //4015
       new string[256];
	  new playermoney;                             //4017
	  new sendername[MAX_PLAYER_NAME];
	  new giveplayer[MAX_PLAYER_NAME];
	  new giveplayerid, moneys, idxx;
	  new tmp[256];
		tmp = strtok(cmdtext, idxx);

		if(!strlen(tmp)) {
			SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
			return 1;
		}
		giveplayerid = strval(tmp);

		tmp = strtok(cmdtext, idxx);
		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(%d), $%d.", giveplayer,giveplayerid, moneys);
				SendClientMessage(playerid, COLOR_YELLOW, string);
				format(string, sizeof(string), "You have recieved $%d from %s(%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;
	}
Error:

Код:
C:\Users\proprietario\Desktop\Tutto\Sa-Mp\GM\Clan Drift\gamemodes\ClanDrift.pwn(4015) : error 017: undefined symbol "cmd"
C:\Users\proprietario\Desktop\Tutto\Sa-Mp\GM\Clan Drift\gamemodes\ClanDrift.pwn(4017) : warning 217: loose indentation
C:\Users\proprietario\Desktop\Tutto\Sa-Mp\GM\Clan Drift\gamemodes\ClanDrift.pwn(4022) : error 017: undefined symbol "strtok"
C:\Users\proprietario\Desktop\Tutto\Sa-Mp\GM\Clan Drift\gamemodes\ClanDrift.pwn(4022) : error 033: array must be indexed (variable "tmp")
C:\Users\proprietario\Desktop\Tutto\Sa-Mp\GM\Clan Drift\gamemodes\ClanDrift.pwn(4030) : error 017: undefined symbol "strtok"
C:\Users\proprietario\Desktop\Tutto\Sa-Mp\GM\Clan Drift\gamemodes\ClanDrift.pwn(4030) : error 033: array must be indexed (variable "tmp")
C:\Users\proprietario\Desktop\Tutto\Sa-Mp\GM\Clan Drift\gamemodes\ClanDrift.pwn(4020) : warning 203: symbol is never used: "idxx"
C:\Users\proprietario\Desktop\Tutto\Sa-Mp\GM\Clan Drift\gamemodes\ClanDrift.pwn(4020 -- 4065) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Reply
#2

helpme pls.....
Reply
#3

Helppppp
Reply
#4

Past the lines with the errors here, and let's see if I may help you.
Reply
#5

under onplayercommandtext add :
Код:
new cmd[256];
bottom of ur script add :
Код:
//------------------------------------------------------------------------------------------------------
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;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)