Command unworking
#1

I got this spectate command not working..when i type it nothing happenes..

Код:
CMD:spec(playerid, params[])
{
	if (pInClass[playerid])
	{
	    return 1;
	}

	if (! IsPlayerAdmin(playerid) && pStats[playerid][userAdmin] < 1)
	{
	    return SendClientMessage(playerid, COLOR_TOMATO, "You must be admin level 1+ to use this command.");
	}

    new targetid;
    if (sscanf(params, "u", targetid))
	{
		return SendClientMessage(playerid, COLOR_THISTLE, "USAGE: /spec [player]");
	}

	if (targetid == playerid)
	{
		return SendClientMessage(playerid, COLOR_TOMATO, "You can't spectate to yourself.");
	}

	if (! IsPlayerConnected(targetid))
	{
		return SendClientMessage(playerid, COLOR_TOMATO, "The specified player is not conected.");
	}

	if (pInClass[targetid] && GetPlayerState(targetid) == PLAYER_STATE_SPECTATING)
	{
		return SendClientMessage(playerid, COLOR_TOMATO, "The specified player is not spawned.");
	}

	PlayerSpectatePlayer(playerid, targetid);

	new buf[150];
	format(buf, sizeof(buf), "You are now spectating %s(%i).", ReturnPlayerName(targetid), targetid);
	SendClientMessage(playerid, COLOR_DODGER_BLUE, buf);
	SendClientMessage(playerid, COLOR_DODGER_BLUE, "You can type /specoff when you wish to stop spectating.");
    return 1;
}
Reply
#2

You need to TogglePlayerSpectating before PlayerSpecPlayer.
Reply
#3

Like this??
Код:
CMD:spec(playerid, params[])
{
	if (pInClass[playerid])
	{
	    return 1;
	}

	if (! IsPlayerAdmin(playerid) && pStats[playerid][userAdmin] < 1)
	{
	    return SendClientMessage(playerid, COLOR_TOMATO, "You must be admin level 1+ to use this command.");
	}

    new targetid;
    if (sscanf(params, "u", targetid))
	{
		return SendClientMessage(playerid, COLOR_THISTLE, "USAGE: /spec [player]");
	}

	if (targetid == playerid)
	{
		return SendClientMessage(playerid, COLOR_TOMATO, "You can't spectate to yourself.");
	}

	if (! IsPlayerConnected(targetid))
	{
		return SendClientMessage(playerid, COLOR_TOMATO, "The specified player is not conected.");
	}

	if (pInClass[targetid] && GetPlayerState(targetid) == PLAYER_STATE_SPECTATING)
	{
		return SendClientMessage(playerid, COLOR_TOMATO, "The specified player is not spawned.");
	}
	
    TogglePlayerSpectating(playerid, true);
	PlayerSpectatePlayer(playerid, targetid);

	new buf[150];
	format(buf, sizeof(buf), "You are now spectating %s(%i).", ReturnPlayerName(targetid), targetid);
	SendClientMessage(playerid, COLOR_DODGER_BLUE, buf);
	SendClientMessage(playerid, COLOR_DODGER_BLUE, "You can type /specoff when you wish to stop spectating.");
    return 1;
}
EDIT:
Fixed thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)