SA-MP Forums Archive
also need help with law caht - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: also need help with law caht (/showthread.php?tid=277369)



also need help with law caht - Tanush123 - 17.08.2011

when player does /lc nobody in law doesnt get a message
pawn Код:
CMD:lc(playerid,params[])
{
    if(PlayerData[playerid][IsLaw] == 1)
    {
        if(isnull(params)) return SendClientMessage(playerid,orange,"USAGE: /lc [message]");
        GetPlayerName(playerid,Nam,sizeof(Nam));
        format(str,sizeof(str),"[LAWCHAT] %s: %s",Nam,params);
        for(new i = 0; i < MAX_PLAYERS; ++i)
        {
            if(!IsPlayerConnected(i) && !IsPlayerNPC(i))
            {
                if(PlayerData[i][IsLaw] == 1)
                {
                    SendClientMessage(i,COLOR_BLUE,str);
                }
            }
        }
    }
    else return 0;
    return 1;
}



Re: also need help with law caht - KingTurtle - 17.08.2011

Its quite simple

if(!IsPlayerConnected(i)
You are not checking if the player is connected

pawn Код:
CMD:lc(playerid,params[])
{
    if(PlayerData[playerid][IsLaw] == 1)
    {
        if(isnull(params)) return SendClientMessage(playerid,orange,"USAGE: /lc [message]");
        GetPlayerName(playerid,Nam,sizeof(Nam));
        format(str,sizeof(str),"[LAWCHAT] %s: %s",Nam,params);
        for(new i = 0; i < MAX_PLAYERS; ++i)
        {
            if(IsPlayerConnected(i) && !IsPlayerNPC(i))
            {
                if(PlayerData[i][IsLaw] == 1)
                {
                    SendClientMessage(i,COLOR_BLUE,str);
                }
            }
        }
    }
    else return 0;
    return 1;
}
I fixed it above