Range Point.
#1

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

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
Reply
#3

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

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

Remove the minigun...?
Reply
#5

Does anyone know ?
Reply
#6

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

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

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);
    }
Reply
#9

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


Forum Jump:


Users browsing this thread: 1 Guest(s)