Object not being destroyed and weapon are not been given
#1

The code is placed @OnPlayerUpdate

pawn Код:
GetObjectPos(AmmoBox,X,Y,Z);
    foreach(Player,i)
    {
     if(IsPlayerInRangeOfPoint(i,0.5,X,Y,Z))
     {
      if(team[i] == A)
      {
      GivePlayerWeapon(playerid,23,60);
      GivePlayerWeapon(playerid,29,30);
      GivePlayerWeapon(playerid,33,30);
      GivePlayerWeapon(playerid,25,20);
      DestroyObject(AmmoBox);
      }
     }
    }
The code complies fine. But when i test it,The object remains there and the player who goes near the object "Ammo Box" doesn't get the Weapon.
I have no idea whats wrong. Waiting for your help thanks
Reply
#2

@Gaurav_Rawat - not the best way to do that, that will lag for sure! OnPlayerUpdate gets called every 300 ms, All I could suggest is create a Dynamic Area using streamer, example code below.

pawn Код:
new AmmoBoxArea = CreateDynamicCircle(X,Y, 4.0); //grab the X & Y position of the box and paste it in here.

public OnPlayerEnterDynamicArea(playerid, areaid)
{
    if(AmmoBoxArea == areaid)
    {
        if(team[playerid] == A)
        {
          GivePlayerWeapon(playerid,23,60);
          GivePlayerWeapon(playerid,29,30);
          GivePlayerWeapon(playerid,33,30);
          GivePlayerWeapon(playerid,25,20);
          DestroyObject(AmmoBox);
        }
    }
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)