SA-MP Forums Archive
[Help]What are these errors? - 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: [Help]What are these errors? (/showthread.php?tid=103044)



[Help]What are these errors? - Tigerbeast11 - 18.10.2009

Here is the code, taken from LAdmin, edited by me:

Код:
dcmd_slap(playerid,params[]) {
	if(PlayerInfo[playerid][LoggedIn] == 1) {
		if(PlayerInfo[playerid][Level] >= 2) {
		  new tmp[256], tmp2[256], Index;		tmp = strtok(params,Index), tmp2 = strtok(params,Index);
		  if(!strlen(params)) return SendClientMessage(playerid, red, "USAGE: /slap [playerid] [reason/with]");
			player1 = strval(tmp);  			new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
			GetPlayerName(player1, playername, sizeof(playername));
			GetPlayerName(playerid, adminname, sizeof(adminname));
			new Float:Health, Float:x, Float:y, Float:z; GetPlayerHealth(player1,Health);
			GetPlayerPos(player1,x,y,z); SetPlayerPos(player1,x,y,z+26); PlayerPlaySound(playerid,1190,0.0,0.0,0.0); PlayerPlaySound(player1,1190,0.0,0.0,0.0);

			if(strlen(tmp2)) {
				format(string,sizeof(string),"%s (id:%d) has slapped %s (id:%d) for: %s",adminname,playerid,playername,player1,params[2]); return SendClientMessageToAll(orange,string); }
				} else {
				format(string,sizeof(string),"%s (id:%d) has slapped %s (%d) for [No Reason Defined]",adminname,playerid,playername,player1); return SendClientMessageToAll(orange,string); }
		} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
	} else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
Errors:
Код:
(2597) : error 017: undefined symbol "player1"
(2606) : error 017: undefined symbol "string"
(2606) : error 017: undefined symbol "string"
(2606) : error 029: invalid expression, assumed zero
(2606) : fatal error 107: too many error messages on one line
Greetz



Re: [Help]What are these errors? - dice7 - 18.10.2009

Why are you using strtok inside dcmd ? The whole point of dcmd is not using slow and inefficient strtok in the first place.
And the errors are that the variables 'player1' and 'string' are not defined


Re: [Help]What are these errors? - Tigerbeast11 - 18.10.2009

Quote:
Originally Posted by dice7
Why are you using strtok inside dcmd ? The whole point of dcmd is not using slow and inefficient strtok in the first place.
This script is from LAdmin, so don't blame me for the scripting...


Quote:

And the errors are that the variables 'player1' and 'string' are not defined

How should I define them?