illegal gun in front of cop = wanted
#5

pawn Код:
public OnGameModeInit()
{
    SetTimer("GunCheck", 1000, true); //set to 1 second and repeating
    return 0;
}


forward GunCheck();
public GunCheck()
{
    new max = GetMaxPlayers();
    for (new adminid = 0; adminid < max; adminid ++)
    {
        if (IsPlayerConnected(adminid))
        {
            if (IsPlayerAdmin(adminid))
            {
                for (new id = 0; id < max; id ++)
                {
                    if (IsPlayerConnected(id))
                    {
                        if (id != adminid)
                        {
                            new Float:x, Float:y, Float:z;
                            GetPlayerPos(adminid, x, y, z);
                            if (IsPlayerInRangeOfPoint(id, range, x, y, z)) //he's close to the admin
                            {
                                if (GetPlayerWeapon(playerid) == your weapon id's here)
                                {
                                    SetPlayerWantedLevel(playerid, 1);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
The outer loop (first for() ) check the players if anyone is an admin. If a player is an admin, the inner loop gets executed, which checks if a player so close enough the to player. If he is, then it checks if he has the right weapon.
https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint




And no, it won't be laggy using OnPlayerUpdate to check if the players weapons, hence creating OnPlayerSwitchWeapon or something like that. OnPlayerUpdate was made exactly for stuff like that
Reply


Messages In This Thread
illegal gun in front of cop = wanted - by aNdReSk - 16.07.2010, 08:24
Re: illegal gun in front of cop = wanted - by dice7 - 16.07.2010, 08:29
Re: illegal gun in front of cop = wanted - by ToPhrESH - 16.07.2010, 08:30
Re: illegal gun in front of cop = wanted - by aNdReSk - 16.07.2010, 08:45
Re: illegal gun in front of cop = wanted - by dice7 - 16.07.2010, 08:45
Re: illegal gun in front of cop = wanted - by aNdReSk - 16.07.2010, 08:52
Re: illegal gun in front of cop = wanted - by aNdReSk - 16.07.2010, 09:15

Forum Jump:


Users browsing this thread: 3 Guest(s)