illegal gun in front of cop = wanted -
aNdReSk - 16.07.2010
Hey, help me out with the logic to get this done:
If my weapon is a Rocket Launcher, or a Chainsaw (let's use those 2) and Im near a cop, and Im not wanted, I get one wanted level star!
Can it be done WITHOUT A TIMER?
Maybe on player change weapon?
Re: illegal gun in front of cop = wanted -
dice7 - 16.07.2010
It can be done via timer or OnPlayerUpdate
Re: illegal gun in front of cop = wanted -
ToPhrESH - 16.07.2010
Ugh
i don't know how to make it where your close to admin but i can do it where if you have the weapon you are wanted
pawn Код:
OnGameModeInit()
{
if(GetPlayerWeapon(playerid) == your weapon id's here)
{
SetPlayerWantedLevel(playerid, 1);
}
return 1;
}
Re: illegal gun in front of cop = wanted -
aNdReSk - 16.07.2010
would it be smart to use on player update to check a players weapon? I mean not laggy?
Re: illegal gun in front of cop = wanted -
dice7 - 16.07.2010
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
Re: illegal gun in front of cop = wanted -
aNdReSk - 16.07.2010
Ok I was wondering since, when im running onplayerupdate gets called every time my player moves.. which means a lot of times!
Is a timer more or less efficient in this case?
I know both would work! But I want the most efficient way
Thanks in advance
Re: illegal gun in front of cop = wanted -
aNdReSk - 16.07.2010
Thanks for the advice ******! WIll go for the Timer