Anti weapon radius - 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: Anti weapon radius (
/showthread.php?tid=517275)
Anti weapon radius -
Shazwan - 04.06.2014
How to make a radius point that when player enter the radius they cant use the weapon, unless they are out from the radius they can use it again.
Re: Anti weapon radius -
Rittik - 04.06.2014
Код:
if(IsPlayerInRangeOfPoint(playerid,playerid, Float:radius, Float:x, Float:y, Float:z))
{
if(Weapon[playerid]==1)
{
ResetPlayerWeapons(playerid);
}
}
This is just a logic code.
Re: Anti weapon radius -
Shazwan - 04.06.2014
But if they out from the radius doest it give the weapon back to them?
Re: Anti weapon radius -
Koala818 - 04.06.2014
You can use OnPlayerUpdate or A timer that checks if the player is in range and if it is, you'll set the the fist. It'll look like:
pawn Код:
public OnPlayerUpdate(playerid)
{
if(IsPlayerInRangeOfPoint(...)) //If they are in the range that you want
{
if(GetPlayerWeapon(playerid)!=0) //If They have another weapon beside fist
{
SetPlayerArmedWeapon(playerid,0); //Set their armed weapon to fist
}
}
}
Re: Anti weapon radius -
Rittik - 04.06.2014
Код:
if(IsPlayerInRangeOfPoint(playerid,playerid, Float:radius, Float:x, Float:y, Float:z))
{
if(Weapon[playerid]==1)
{
for(i=0;i<13;i++)
{
array=GetPlayerWeapon(playerid); //make an array to store weapons
}
ResetPlayerWeapons(playerid);
}
}
else
{
for(i=0;i<13;i++)
{
GivePlayerWeapon(playerid,make an array here,ammo);
}
}
Re: Anti weapon radius -
Shazwan - 04.06.2014
Is this also include if they spawn a weapon in the radius, doest it be reset also?
Re: Anti weapon radius -
BlackSirrah239 - 04.06.2014
Quote:
Originally Posted by Shazwan
Is this also include if they spawn a weapon in the radius, doest it be reset also?
|
Yes. So long as they are in the radius of the point, they cannot use a weapon using the provided code from other users. So whether you spawn, tp, walk or fly in, you cant use a weapon if you are in range of the point. You can use variables to add exceptions, for example:
Код:
new g_iWeaponExcepted[MAX_PLAYERS];
if(IsPlayerAdmin(playerid)) //if the player is an RCON admin they can use a gun in the area
g_iWeaponExcepted[playerid] = 1;
if(IsPlayerInRangeOfPoint(playerid, 50.0, x, y, z) && g_iWeaponExcepted[playerid] != 1)
{
//disarms the player
}