SA-MP Forums Archive
Errors with /buyGrenades (Giving Credits!) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Errors with /buyGrenades (Giving Credits!) (/showthread.php?tid=90368)



Errors with /buyGrenades (Giving Credits!) - Sal_Kings - 07.08.2009

This is my script
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp(cmd, "/BuyGrenades", true) == 0)
	{
	new
	tmp[20],
	amount;
	tmp = strtok(cmdtext, index);
	if (strlen(tmp))
	{
	amount = strval(tmp);
	if (IsPlayerConnected(amount))
	{
	GivePlayerWeapon(playerid,16,amount");
	GivePlayerMoney(playerid,-amount*1000)
	}
	else
	{
	SendClientMessage(playerid, 0xFF0000AA, "You Don't Have enough Money!");
	}
	}
	else
	{
	SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/buygrenades <amount>\"");
	}
	return 1;
	}
	return 0;
}
These are my errors ...
Код:
C:\Documents and Settings\home\Desktop\samp02Xserver.win32\gamemodes\GunDealerJob.pwn(102) : error 017: undefined symbol "cmd"
C:\Documents and Settings\home\Desktop\samp02Xserver.win32\gamemodes\GunDealerJob.pwn(107) : error 017: undefined symbol "strtok"
C:\Documents and Settings\home\Desktop\samp02Xserver.win32\gamemodes\GunDealerJob.pwn(107) : error 033: array must be indexed (variable "tmp")
C:\Documents and Settings\home\Desktop\samp02Xserver.win32\gamemodes\GunDealerJob.pwn(113) : error 037: invalid string (possibly non-terminated string)
C:\Documents and Settings\home\Desktop\samp02Xserver.win32\gamemodes\GunDealerJob.pwn(113) : warning 215: expression has no effect
C:\Documents and Settings\home\Desktop\samp02Xserver.win32\gamemodes\GunDealerJob.pwn(113) : error 001: expected token: ";", but found ")"
C:\Documents and Settings\home\Desktop\samp02Xserver.win32\gamemodes\GunDealerJob.pwn(113) : error 029: invalid expression, assumed zero
C:\Documents and Settings\home\Desktop\samp02Xserver.win32\gamemodes\GunDealerJob.pwn(113) : fatal error 107: too many error messages on one line

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


7 Errors.
Help and i will add you in the Credits area for my FS i am working on.


Re: Errors with /buyGrenades (Giving Credits!) - kingworldsoft - 07.08.2009

The commando is:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new cmd[256];
	new idx;

	cmd = strtok(cmdtext, idx);
  if (strcmp(cmd, "/BuyGrenades", true) == 0)
	{
	new
	tmp[20],
	amount;
	
	if (strlen(tmp))
	{
	amount = strval(tmp);
	if (IsPlayerConnected(amount))
	{
   GivePlayerWeapon(playerid,16,342);
	 GivePlayerMoney(playerid,- 1000);
	}
	else
	{
	SendClientMessage(playerid, 0xFF0000AA, "You Don't Have enough Money!");
	}
	}
	else
	{
	SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/buygrenades <amount>\"");
	}
	return 1;
	}
	return 0;
}
And it adds at the end of gamemode or filterscript:
Код:
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;
}