SA-MP Forums Archive
Too many errors on 1 line ? ++REP - 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)
+--- Thread: Too many errors on 1 line ? ++REP (/showthread.php?tid=610515)



Too many errors on 1 line ? ++REP - YoussefHammad - 25.06.2016

Код:
CMD:spec(playerid,params[])
{
	if(pInfo[playerid][Admin]>=2)
	{
		new pID,string[128],string3[128],Name[MAX_PLAYER_NAME];
		if(sscanf(params,"u",pID))return SendClientMessage(playerid,COLOR_GREEN,"/spec [id]");
		GetPlayerName(playerid,Name,sizeof(Name));
		format(string,sizeof(string),"You're now spectating %s",Name(pID));//ERROR LINE
		for(new i=0;i<GetMaxPlayers();i++)
		{
		if(IsPlayerConnected(i))
		{
		if(pInfo[i][Admin]>=1)
		{
	    format(string3,sizeof(string3),"A: %s [LEVEL %i] used the SPEC command.",Name(playerid),pInfo[playerid][pAdmin]);
		SendClientMessage(i,COLOR_ORANGE,string3);
		}
		}
		}
	 	SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
	 	TogglePlayerSpectating(playerid,1);
	    PlayerSpectatePlayer(playerid,pID,SPECTATE_MODE_NORMAL);
	}
	else
	{
	    SendClientMessage(playerid,0xFF0000FF,"<!>You are not authorized to use this command!");
	}
    return 1;
}
Errors:
Код:
C:\Windows.old.000\Users\Youssf Hammad\Desktop\SA-MP related shit\Server\gamemodes\LSCnR.pwn(4633) : error 012: invalid function call, not a valid address
C:\Windows.old.000\Users\Youssf Hammad\Desktop\SA-MP related shit\Server\gamemodes\LSCnR.pwn(4633) : warning 215: expression has no effect
C:\Windows.old.000\Users\Youssf Hammad\Desktop\SA-MP related shit\Server\gamemodes\LSCnR.pwn(4633) : error 001: expected token: ";", but found ")"
C:\Windows.old.000\Users\Youssf Hammad\Desktop\SA-MP related shit\Server\gamemodes\LSCnR.pwn(4633) : error 029: invalid expression, assumed zero
C:\Windows.old.000\Users\Youssf Hammad\Desktop\SA-MP related shit\Server\gamemodes\LSCnR.pwn(4633) : fatal error 107: too many error messages on one line

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


4 Errors.
Thanks


Re: Too many errors on 1 line ? ++REP - AroseKhanNiazi - 25.06.2016

Код:
CMD:spec(playerid,params[])
{
	if(pInfo[playerid][Admin]>=2)
	{
		new pID,string[128],string3[128],Name[MAX_PLAYER_NAME];
		if(sscanf(params,"u",pID))return SendClientMessage(playerid,COLOR_GREEN,"/spec [id]");
		if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid,0xFF0000FF,"Please enter a valid player id.");
		GetPlayerName(pID,Name,sizeof(Name));
		format(string,sizeof(string),"You're now spectating %s",Name);//ERROR LINE
		GetPlayerName(playerid,Name,sizeof(Name));
		for(new i=0;i<GetMaxPlayers();i++)
		{
			if(IsPlayerConnected(i))
			{
				if(pInfo[i][Admin]>=1)
				{
					format(string3,sizeof(string3),"A: %s [LEVEL %i] used the SPEC command.",Name,pInfo[playerid][pAdmin]);
					SendClientMessage(i,COLOR_ORANGE,string3);
				}
			}
		}
	 	SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
	 	TogglePlayerSpectating(playerid,1);
	    PlayerSpectatePlayer(playerid,pID,SPECTATE_MODE_NORMAL);
	}
	else
	{
	    SendClientMessage(playerid,0xFF0000FF,"<!>You are not authorized to use this command!");
	}
    return 1;
}
Fixed

String var is a different var it's not a array.

You didn't check if the Target ID is valid or not it would have caused that command to crash.
Added code for that too.
Код:
if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid,0xFF0000FF,"Please enter a valid player id.");



Re: Too many errors on 1 line ? ++REP - YoussefHammad - 25.06.2016

Thanks, +Repped