21.05.2015, 10:43
Hello,
I'm using this /spec command in my server.
I can't see anything wrong in the code.
But sometimes, the spec mode gets off randomly?
When an admin is spectating some player, after few sec/mins the spec mode is off? why without /stopspec it shouldn't go off? but it does.
How can i fix this.
I'm using this /spec command in my server.
Код:
COMMAND:spectate(playerid, params[])
{
if (PlayerInfo[playerid][pAdminlevel] > 0)
{
if (PlayerInfo[playerid][pSpawned] == 1)
{
new TargetID,string[256];
new Float:X,Float:Y,Float:Z,Float:A,I,W,vehicleid;
if(sscanf(params, "u", TargetID))
{
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /spectate (Name/Id) - Enter A Valid Name/Id");
return 1;
}
if(!IsPlayerConnected(TargetID) || TargetID == INVALID_PLAYER_ID)
{
SendClientMessage(playerid, COLOR_ERROR, "That Player Is Not Connected.");
return 1;
}
if(IsPlayerNPC(TargetID))
{
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Spectate a BOT.");
return 1;
}
if (PlayerInfo[TargetID][pSpawned] == 0)
{
format(string, sizeof(string), "%s (%i) Has Not Spawned.",PlayerInfo[TargetID][pName],TargetID);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
format(string, sizeof(string), "Spectating %s (%i).",PlayerInfo[TargetID][pName],TargetID);
SendClientMessage(playerid,COLOR_ADMIN, string);
if (PlayerInfo[playerid][pSpecID] == -1)
{
GetPlayerPos(playerid,X,Y,Z);
GetPlayerFacingAngle(playerid,A);
I = GetPlayerInterior(playerid);
W = GetPlayerVirtualWorld(playerid);
PlayerInfo[playerid][pSpecX] = X;
PlayerInfo[playerid][pSpecY] = Y;
PlayerInfo[playerid][pSpecZ] = Z;
PlayerInfo[playerid][pSpecA] = A;
PlayerInfo[playerid][pSpecI] = I;
PlayerInfo[playerid][pSpecW] = W;
}
PlayerInfo[playerid][pSpecID] = TargetID;
if (IsPlayerInAnyVehicle(TargetID)) {
vehicleid = GetPlayerVehicleID(TargetID);
TogglePlayerSpectating(playerid, 1);
PlayerSpectateVehicle(playerid, vehicleid);
SetPlayerInterior(playerid,GetPlayerInterior(TargetID));
SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(TargetID));
}
else
{
TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, TargetID);
SetPlayerInterior(playerid,GetPlayerInterior(TargetID));
SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(TargetID));
}
}else{
SendClientMessage(playerid, COLOR_ERROR, "You Cannot Use This Command While You're Dead.");
}
}else{
SendClientMessage(playerid, COLOR_ERROR, "Unknown Command! Type /cmds For Available Commands.");
}
return 1;
}
But sometimes, the spec mode gets off randomly?
When an admin is spectating some player, after few sec/mins the spec mode is off? why without /stopspec it shouldn't go off? but it does.
How can i fix this.

