SA-MP Forums Archive
Pickups. - 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: Pickups. (/showthread.php?tid=675170)



Pickups. - Saman22 - 06.05.2020

Can anyone help me? How can I make 4 pickups health for the players and they can use them with money and if their money is less than $1200, the server will not allow them to use this pickup.


Re: Pickups. - Mike861 - 06.05.2020

https://sampwiki.blast.hk/wiki/CreatePickup
https://sampwiki.blast.hk/wiki/OnPlayerPickUpPickup

Under OnPlayerPickUpPickup where the pickupid is the one of the health ones:
Code:
new playermoney = GetPlayerMoney(playerid);
if(playermoney < 1200)
{
   //do what you want
   return 0;
}



Re: Pickups. - beckzy - 06.05.2020

Somewhere:
Code:
new healthpickups[4];
In OnGameModeInit (change the x, y, z):
Code:
healthpickups[0] = CreatePickup(1240, 1, x, y, z);
healthpickups[1] = CreatePickup(1240, 1, x, y, z);
healthpickups[2] = CreatePickup(1240, 1, x, y, z);
healthpickups[3] = CreatePickup(1240, 1, x, y, z);
}
In OnPlayerPickUpPickup:
Code:
for (new p = 0; p < sizeof(healthpickups); p++)
{
    if (healthpickups[p] != pickupid) continue;
    if (GetPlayerMoney(playerid) >= 1200)
    {
        new Float:health;
        GetPlayerHealth(playerid, health);
        if (health < 100.0)
        {
            GivePlayerMoney(playerid, -1200);
            SetPlayerHealth(playerid, 100.0);
        }
    }
    return 1;
}