Object not being destroyed and weapon are not been given - 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: Object not being destroyed and weapon are not been given (
/showthread.php?tid=504423)
Object not being destroyed and weapon are not been given -
Gaurav_Rawat - 04.04.2014
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
Re: Object not being destroyed and weapon are not been given - Patrick - 04.04.2014
@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;
}