SA-MP Forums Archive
Range Point. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Range Point. (/showthread.php?tid=253721)



Range Point. - Alex_Obando - 07.05.2011

Hello How can I do this:

If player is in this range point:
-163.2511,2620.0977,78.8033,28.4597

Then Give a minigun with 100 ammo.


Re: Range Point. - Seven_of_Nine - 07.05.2011

pawn Код:
if(IsPlayerInRangeOfPoint(playerid,30,-163.2511,2620.0977,78.8033,28.4597)) {
    if(GetPVarInt(playerid,"mini") == 0) {
        SetPVarInt(playerid,"mini",1);
        GivePlayerWeapon(playerid,38,100000);
    }
}
Put it under a callback like... OnPlayerUpdate

EDIT: under me, I xpanded the code with that.
I don't know what you wanna do when you have to make that PVar 0 xD


Re: Range Point. - Hiddos - 07.05.2011

Use OnPlayerUpdate, IsPlayerInRangeOfPoint, GivePlayerWeapon and a boolean to check if he already was in range of that point.


Respuesta: Range Point. - Alex_Obando - 07.05.2011

And if the player is here
-165.4904,2619.2251,98.2914,233.3485

Remove the minigun...?


Respuesta: Range Point. - Alex_Obando - 07.05.2011

Does anyone know ?


Re: Range Point. - BizzyD - 07.05.2011

pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 3.0,-165.4904,2619.2251,98.2914,233.3485))
    {
        ResetPlayerWeapons(playerid);
    }
Under On Player Update


Respuesta: Range Point. - Alex_Obando - 07.05.2011

But I just need the Minigun To reset not all the weapons...


Respuesta: Re: Range Point. - Alex_Obando - 07.05.2011

pawn Код:
public OnPlayerUpdate(playerid)
{

if(IsPlayerInRangeOfPoint(playerid,30,-163.2511,2620.0977,78.8033,28.4597)) {
    if(GetPVarInt(playerid,"mini") == 0) {
        SetPVarInt(playerid,"mini",1);
        GivePlayerWeapon(playerid,38,100000);
    }
}
if(IsPlayerInRangeOfPoint(playerid, 3.0,-165.4904,2619.2251,98.2914,233.3485))
    {
        ResetPlayerWeapons(playerid);
    }



Re: Range Point. - Seven_of_Nine - 07.05.2011

pawn Код:
stock RemovePlayerWeapon(playerid, weaponid)
{
    new plyWeapons[12]
    new plyAmmo[12]

    for(new slot = 0; slot != 12; slot++)
    {
        new wep, ammo
        GetPlayerWeaponData(playerid, slot, wep, ammo)
       
        if(wep != weaponid)
        {
            GetPlayerWeaponData(playerid, slot, plyWeapons[slot], plyAmmo[slot])
        }
    }
   
    ResetPlayerWeapons(playerid)
    for(new slot = 0; slot != 12; slot++)
    {
        GivePlayerWeapon(playerid, plyWeapons[slot], plyAmmo[slot])
    }
}
To the top of the script.
And then (OnPlayerUpdate)
pawn Код:
if(IsPlayerInRangeOfPoint(playerid,30,-163.2511,2620.0977,78.8033,28.4597)) {
    if(GetPVarInt(playerid,"mini") == 0) {
        SetPVarInt(playerid,"mini",1);
        GivePlayerWeapon(playerid,38,100000);
    }
}
if(IsPlayerInRangeOfPoint(playerid,30,-165.4904,2619.2251,98.2914,233.3485)) {
    if(GetPVarInt(playerid,"mini") == 1) {
        RemovePlayerWeapon(playerid,38);
        SetPVarInt(playerid,"mini",0);
    }
}
That should do it.