PDA

View Full Version : /sp (spec) does not work


AwokenNeoX
09/02/2017, 01:18 PM
The command is to spec another player if he is Admin Level 5 or higher.
Then the script check if I am InCamMod (in Camera Modus) if no then I can use spec and if I type /sp again it turns off
If I type /sp I only get the Error Message "* Sorry, player is not connected"

dcmd_sp(playerid,params[])
{
if(AccInfo[playerid][Level] >= 2 || IsPlayerAdmin(playerid))
{
if(AccInfo[playerid][InCamMod] == 0)
{
AccInfo[playerid][InCamMod] = 1;
if(AccInfo[playerid][pGps] != -1)
return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Sorry, you need to disable the GPS first (/gps off)");

if(!strlen(params) || !IsNumeric(params))
{
SendClientMessage(playerid, COLOR_YELLOW, "** Usage: /sp [PlayerID]");
SendClientMessage(playerid, COLOR_YELLOW, "* Will spec a specified Player");
return true;
}

new specplayerid = ReturnUser(params);
if(AccInfo[specplayerid][Level] == ServerInfo[MaxAdminLevel] && AccInfo[playerid][Level] != ServerInfo[MaxAdminLevel])
return SendClientMessage(playerid,COLOR_MESSAGE_YELLOW,"* Sorry, You cannot use this command on this admin!");

if(IsPlayerConnected(specplayerid) && specplayerid != INVALID_PLAYER_ID)
{
if(specplayerid == playerid)
return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Sorry, You cannot spectate yourself!");

if(GetPlayerState(specplayerid) == PLAYER_STATE_SPECTATING && AccInfo[specplayerid][SpecID] != INVALID_PLAYER_ID)
return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Sorry, this player is spectating someone else!");

if(GetPlayerState(specplayerid) != 1 && GetPlayerState(specplayerid) != 2 && GetPlayerState(specplayerid) != 3)
return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Sorry, the player has not Spawned!");

if((AccInfo[specplayerid][Level] != ServerInfo[MaxAdminLevel]) || (AccInfo[specplayerid][Level] == ServerInfo[MaxAdminLevel] && AccInfo[playerid][Level] == ServerInfo[MaxAdminLevel]))
{
GetPlayerPos(playerid,Pos[playerid][0],Pos[playerid][1],Pos[playerid][2]);
GetPlayerFacingAngle(playerid,Pos[playerid][3]);
SendCommandToAdmins(playerid,"LSpec");
SendClientMessage(playerid,COLOR_MESSAGE_YELLOW,"|- Spectating On -|");
return StartSpectate(playerid, specplayerid);
}
else return SendClientMessage(playerid,COLOR_MESSAGE_YELLOW,"* Sorry, You cannot spectate the highest level admin");
}
else
{
AccInfo[playerid][God] = 0;
StopSpectate(playerid);
TogglePlayerControllable(playerid, 0);
SetTimerEx("ReturnPosition",1000,0,"d",playerid);
return SendClientMessage(playerid,blue,"|- Spectating Off -|");
}

}
else return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW,"* Sorry, player is not connected!");

}
else return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW,"* Sorry, you are not allowed to use this command!");
}


The command was working, I just added the little else part if he typed /sp again then sp turns off but now nothing works

oMa37
09/02/2017, 01:25 PM
dcmd_sp(playerid,params[])
{
if(AccInfo[playerid][Level] >= 2 || IsPlayerAdmin(playerid))
{
if(AccInfo[playerid][InCamMod] == 0)
{
AccInfo[playerid][InCamMod] = 1;
if(AccInfo[playerid][pGps] != -1)
return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Sorry, you need to disable the GPS first (/gps off)");

if(!strlen(params) || !IsNumeric(params))
{
SendClientMessage(playerid, COLOR_YELLOW, "** Usage: /sp [PlayerID]");
SendClientMessage(playerid, COLOR_YELLOW, "* Will spec a specified Player");
return true;
}

new specplayerid = ReturnUser(params);
if(AccInfo[specplayerid][Level] == ServerInfo[MaxAdminLevel] && AccInfo[playerid][Level] != ServerInfo[MaxAdminLevel])
return SendClientMessage(playerid,COLOR_MESSAGE_YELLOW,"* Sorry, You cannot use this command on this admin!");

if(IsPlayerConnected(specplayerid) && specplayerid != INVALID_PLAYER_ID)
{
if(specplayerid == playerid)
return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Sorry, You cannot spectate yourself!");

if(GetPlayerState(specplayerid) == PLAYER_STATE_SPECTATING && AccInfo[specplayerid][SpecID] != INVALID_PLAYER_ID)
return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Sorry, this player is spectating someone else!");

if(GetPlayerState(specplayerid) != 1 && GetPlayerState(specplayerid) != 2 && GetPlayerState(specplayerid) != 3)
return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Sorry, the player has not Spawned!");

if((AccInfo[specplayerid][Level] != ServerInfo[MaxAdminLevel]) || (AccInfo[specplayerid][Level] == ServerInfo[MaxAdminLevel] && AccInfo[playerid][Level] == ServerInfo[MaxAdminLevel]))
{
GetPlayerPos(playerid,Pos[playerid][0],Pos[playerid][1],Pos[playerid][2]);
GetPlayerFacingAngle(playerid,Pos[playerid][3]);
SendCommandToAdmins(playerid,"LSpec");
SendClientMessage(playerid,COLOR_MESSAGE_YELLOW,"|- Spectating On -|");
return StartSpectate(playerid, specplayerid);
}
else return SendClientMessage(playerid,COLOR_MESSAGE_YELLOW,"* Sorry, You cannot spectate the highest level admin");
}
else return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW,"* Sorry, player is not connected!");
}
else
{
AccInfo[playerid][God] = 0;
StopSpectate(playerid);
TogglePlayerControllable(playerid, 0);
SetTimerEx("ReturnPosition",1000,0,"d",playerid);
return SendClientMessage(playerid,blue,"|- Spectating Off -|");
}
}
else return SendClientMessage(playerid, COLOR_MESSAGE_YELLOW,"* Sorry, you are not allowed to use this command!");
}


This should work, You were returning the message when the InCamMod variable was 1.

AwokenNeoX
09/02/2017, 01:45 PM
This should work, You were returning the message when the InCamMod variable was 1.

I tried it again, the command is working now but not perfect. If I only type /sp without id he said "* Usage /sp id" thats good. Now If I type /sp 1 for exmaple he still still specing me for a secound then I get the message spec disbaled. if I type only /sp then without id again he did not show me "* Usage: /sp id" again.. only spec disabled