Anti weapon radius
#1

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.
Reply
#2

Код:
if(IsPlayerInRangeOfPoint(playerid,playerid, Float:radius, Float:x, Float:y, Float:z))
  {
    if(Weapon[playerid]==1)
     {
       ResetPlayerWeapons(playerid);
      }
   }
This is just a logic code.
Reply
#3

But if they out from the radius doest it give the weapon back to them?
Reply
#4

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
        }
    }
}
Reply
#5

Код:
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);
         }
   }
Reply
#6

Is this also include if they spawn a weapon in the radius, doest it be reset also?
Reply
#7

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
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)