SA-MP Forums Archive
Spec name/target showing to all [Problem] - 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: Spec name/target showing to all [Problem] (/showthread.php?tid=376325)



Spec name/target showing to all [Problem] - kbalor - 09.09.2012

What is the problem with the codes below?? We have noticed that If we spec a normal player, It send to all as
"[Spec] %s (ID:%d) is testing %s (ID:%d)" Even normal player could see that we are currently spectating them. So fail XD What could be the problem. It must be Admin send to Admin. Not Admin send to all players.


pawn Код:
dcmd_spec(playerid,params[])
{
    if(AccInfo[playerid][Level] >= 1 || IsPlayerAdmin(playerid) || AccInfo[playerid][pVip] >= 1)
    {
        if(AccInfo[playerid][pGps] != -1)
        return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}>> First Disable the Gps System! (/gps off)");

        if(!strlen(params) || !IsNumeric(params)) return
        SendClientMessage(playerid, 0xFFFFFFFF, "{FFFF00}Usage: /spec [PlayerID]") &&
        SendClientMessage(playerid, 0xFFFFFFFF, "{FF9900}Function: Will spec a specified Player");

        new specplayerid = ReturnUser(params);
        if(AccInfo[specplayerid][Level] == ServerInfo[MaxAdminLevel] && AccInfo[playerid][Level] != ServerInfo[MaxAdminLevel])
        return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}>> You cannot use this command on this admin");

        if(IsPlayerConnected(specplayerid) && specplayerid != INVALID_PLAYER_ID)
        {
            if(specplayerid == playerid)
            return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}>> You cannot spectate Yourself");

            if(GetPlayerState(specplayerid) == PLAYER_STATE_SPECTATING && AccInfo[specplayerid][SpecID] != INVALID_PLAYER_ID)
            return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}>> Player spectating someone else");

            if(GetPlayerState(specplayerid) != 1 && GetPlayerState(specplayerid) != 2 && GetPlayerState(specplayerid) != 3)
            return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}>> Player not Spawned");

            if((AccInfo[specplayerid][Level] != ServerInfo[MaxAdminLevel]) || (AccInfo[specplayerid][Level] == ServerInfo[MaxAdminLevel] && AccInfo[playerid][Level] == ServerInfo[MaxAdminLevel]))
            {
                new string[128];
                format(string, sizeof(string), "[Spec] %s (ID:%d) is testing %s (ID:%d)", PlayerName2(playerid), playerid, PlayerName2(specplayerid), specplayerid);
                for(new i;i < MAX_PLAYERS; i++) if(AccInfo[playerid][Level] >= 1 && AccInfo[playerid][Level] > 1) SendClientMessage(i, grey, string);
                GetPlayerPos(playerid,Pos[playerid][0],Pos[playerid][1],Pos[playerid][2]);
                GetPlayerFacingAngle(playerid,Pos[playerid][3]);
                SendCommandToAdmins(playerid,"LSpec");
                SendClientMessage(playerid,blue,"Spectating On");
                return StartSpectate(playerid, specplayerid);
            }
            else return SendClientMessage(playerid, 0xFFFFFFFF,"{FF0000}>> You cannot spectate the highest level admin");
        }
        else return ErrorMessages(playerid, 2);
    }
    else return ErrorMessages(playerid, 1);
}



Re: Spec name/target showing to all [Problem] - kbalor - 10.09.2012

Is the problem exist in this line?

pawn Код:
if((AccInfo[specplayerid][Level] != ServerInfo[MaxAdminLevel]) || (AccInfo[specplayerid][Level] == ServerInfo[MaxAdminLevel] && AccInfo[playerid][Level] == ServerInfo[MaxAdminLevel]))
Or somewhere about here
pawn Код:
new string[128];
                format(string, sizeof(string), "[Spec] %s (ID:%d) is testing %s (ID:%d)", PlayerName2(playerid), playerid, PlayerName2(specplayerid), specplayerid);
                for(new i;i < MAX_PLAYERS; i++) if(AccInfo[playerid][Level] >= 1 && AccInfo[playerid][Level] > 1) SendClientMessage(i, grey, string);
                GetPlayerPos(playerid,Pos[playerid][0],Pos[playerid][1],Pos[playerid][2]);
                GetPlayerFacingAngle(playerid,Pos[playerid][3]);
                SendCommandToAdmins(playerid,"LSpec");
                SendClientMessage(playerid,blue,"Spectating On");
                return StartSpectate(playerid, specplayerid);
            }



Re: Spec name/target showing to all [Problem] - clarencecuzz - 10.09.2012

pawn Код:
for(new i;i < MAX_PLAYERS; i++)
                {
                    if(AccInfo[i][Level] >= 1)
                    {
                        SendClientMessage(i, grey, string);
                    }
                }
You had 'playerid' instead of 'i'...


Re: Spec name/target showing to all [Problem] - kbalor - 10.09.2012

Wow thank for another help man! +rep How about the other one?

pawn Код:
&& AccInfo[playerid][Level] > 1)
or should I remove this line?


Re: Spec name/target showing to all [Problem] - clarencecuzz - 10.09.2012

if(AccInfo[playerid][Level] >= 1) is the same as if(AccInfo[playerid][Level] == 1 || AccInfo[playerid][Level] > 1)

There is no need for
Код:
if [Level] is greater than 1
when you have
Код:
if [Level] is greater than OR equal to 1



Re: Spec name/target showing to all [Problem] - kbalor - 10.09.2012

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
if(AccInfo[playerid][Level] >= 1) is the same as if(AccInfo[playerid][Level] == 1 || AccInfo[playerid][Level] > 1)

There is no need for
Код:
if [Level] is greater than 1
when you have
Код:
if [Level] is greater than OR equal to 1
I got it now. Thanks again man! Appreciate your help.