06.09.2009, 17:06
Does any one have like a /spec command for a rp server??
if(strcmp(cmd,"/spec",true) == 0)
{
if(PlayerInfo[playerid][pAdmin] < 1)
{
SendClientMessage(playerid, COLOR_WHITE, BAD_ADMIN_MESSAGE);
return 1;
}
tmp = strtok(cmdtext,idx);
if(strlen(tmp) == 0)
{
SendClientMessage(playerid, COLOR_GRAD1, "SYNTAX - /spec [playerid] (or /specoff to finish the session)");
return 1;
}
new otherplayer = ReturnUser(tmp);
if(otherplayer == INVALID_PLAYER_ID)
{
SendClientMessage(playerid, COLOR_GREY, "ERROR: That ID doesn't appear to be active.");
return 1;
}
if(Spectating[playerid] == 1)
{
KillTimer(refresher);
}
Unspec[playerid][sPint] = GetPlayerInterior( playerid );
Unspec[playerid][sVw] = GetPlayerVirtualWorld( playerid );
GetPlayerPos( playerid, Unspec[playerid][sPx], Unspec[playerid][sPy], Unspec[playerid][sPz] );
Spectating[playerid] = 1;
TogglePlayerSpectating( playerid, 1 );
format(string, sizeof(string), "You are spectating %s (ID: %d)", GetPlayerNameEx(otherplayer), otherplayer);
SendClientMessage(playerid, COLOR_YELLOW, string);
SpectatorRefresh(playerid, otherplayer);
refresher = SetTimerEx( "SpectatorRefresh", 3000, true, "dd", playerid, otherplayer );
SendClientMessage( playerid, COLOR_WHITE, "To complete your spectating session, type /specoff." );
return 1;
}
if(strcmp(cmd,"/specoff",true)==0)
{
if(PlayerInfo[playerid][pAdmin] < 1)
{
SendClientMessage(playerid, COLOR_GREY, "You're not an Administrator so you're unable to spectate anyway.");
return 1;
}
PlayerInfo[playerid][pHospitalized] = 0;
TogglePlayerSpectating(playerid, false);
Spectating[playerid] = 0;
SpecReturnPosDue[playerid] = 1;
SpecNewState[playerid] = 0;
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
KillTimer(refresher);
SetCameraBehindPlayer(playerid);
SetPlayerInterior( playerid, Unspec[playerid][sPint] );
SetPlayerVirtualWorld( playerid, Unspec[playerid][sVw] );
SetPlayerPos( playerid, Unspec[playerid][sPx], Unspec[playerid][sPy], Unspec[playerid][sPz] );
SendClientMessage(playerid, COLOR_YELLOW, "You are no longer spectating.");
SendClientMessage(playerid, COLOR_WHITE, "You have been returned to your previous position.");
return 1;
}
public SpectatorRefresh(playerid, otherplayer)
{
SetPlayerInterior(playerid, GetPlayerInterior(otherplayer));
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(otherplayer));
if(IsPlayerInAnyVehicle(otherplayer)==1)
{
if(SpecNewState[playerid] != 1)
{
PlayerSpectateVehicle(playerid, GetPlayerVehicleID(otherplayer));
SpecNewState[playerid] = 1;
}
}
else
{
if(SpecNewState[playerid] != 2)
{
PlayerSpectatePlayer(playerid, otherplayer);
SpecNewState[playerid] = 2;
}
}
}