16.07.2010, 08:45
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);
}
}
}
}
}
}
}
}
}
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