SA-MP Forums Archive
Problem with spec - 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: Problem with spec (/showthread.php?tid=633895)



Problem with spec - akib - 09.05.2017

Hi
i have added an admin command spec player
not working
code:

Код:
CMD:spec(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 1&& !IsPlayerAdmin(playerid)) return 1;
	new targetid,pName[MAX_PLAYER_NAME];
	if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, -1 , "Correct Usage: /spec[Playerid]");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,COLOR_RED,"Player not connected.");
	GetPlayerName(targetid,pName,sizeof(pName));
	TogglePlayerSpectating(targetid, 1);
	new msg[126];
	format(msg,sizeof(msg),"[Spectate]You are spectating player %s",pName);
	SendClientMessage(playerid,COLOR_RED,msg);
	return 1;
}

CMD:specoff(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 1&& !IsPlayerAdmin(playerid)) return 1;
	new pName[MAX_PLAYER_NAME];
	TogglePlayerSpectating(targetid, 0);
	new msg[126];
	format(msg,sizeof(msg),"[Spectate]You are no more spectating player");
	SendClientMessage(playerid,COLOR_RED,msg);
	return 1;
}



Respuesta: Problem with spec - Ertouq - 09.05.2017

Why do you put Targetid here?
Код:
TogglePlayerSpectating(targetid, 1);
Replace by

Код:
TogglePlayerSpectating(playerid, 1);
in the two commands.