SA-MP Forums Archive
Need help GivePlayerAmmo(playerid, weapon, ammo); - 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: Need help GivePlayerAmmo(playerid, weapon, ammo); (/showthread.php?tid=164716)



Need help GivePlayerAmmo(playerid, weapon, ammo); - Cypress - 01.08.2010

I want to make a shop that a player can buy only ammo for his weapon. I mean that if he hasn't got combat shotgun and want to buy ammo it will say him that he hasn't got this weapon to buy this ammo.

I don't want to give a weapon to a player, i want to give him only ammo for his weapon.

I don't know if this exist GivePlayerAmmo(playerid, weapon, ammo);

I searched but didn't find nothing.


Thanks


Re: Need help GivePlayerAmmo(playerid, weapon, ammo); - ViruZZzZ_ChiLLL - 01.08.2010

I kinda didn't get what you just said but on the ammo thingy here :

pawn Код:
SetPlayerAmmo(playerid, weaponslot, GetPlayerAmmo(playerid));



Re: Need help GivePlayerAmmo(playerid, weapon, ammo); - Cypress - 01.08.2010

Quote:
Originally Posted by ViruZZzZ_ChiLLL
Посмотреть сообщение
I kinda didn't get what you just said but on the ammo thingy here :

pawn Код:
SetPlayerAmmo(playerid, weaponslot, GetPlayerAmmo(playerid));
Can you give me an example for how to use this thing... BTW just read more carefull.

EDIT: I don't want to set players ammo, i want to give them more ammo. I don't want to give a weapon to a player, i want to give him only ammo for his weapon.
GivePlayerAmmo(playerid, weapon, ammo);


Re: Need help GivePlayerAmmo(playerid, weapon, ammo); - ViruZZzZ_ChiLLL - 01.08.2010

Okay, well here :
pawn Код:
new Ammo = GetPlayerAmmo(playerid);
SetPlayerAmmo(playerid, weaponslot, Ammo+3);
Then, that will give me +3 ammo on a certain weapon slot.


Re: Need help GivePlayerAmmo(playerid, weapon, ammo); - Kar - 01.08.2010

setplayerammo doesnt work in 0.3


Re: Need help GivePlayerAmmo(playerid, weapon, ammo); - Kyle - 01.08.2010

I think this stock will work, it gives ammo to his current weapon

pawn Код:
stock GivePlayerAmmo2(playerid, ammo)
{
    GivePlayerWeapon(playerid,GetPlayerWeapon(playerid),ammo);
}



Re: Need help GivePlayerAmmo(playerid, weapon, ammo); - Kar - 01.08.2010

also u should add getplayerweaponslot


Re: Need help GivePlayerAmmo(playerid, weapon, ammo); - Cypress - 01.08.2010

Quote:
Originally Posted by KyleSmith
Посмотреть сообщение
I think this stock will work, it gives ammo to his current weapon

pawn Код:
stock GivePlayerAmmo2(playerid, ammo)
{
    GivePlayerWeapon(playerid,GetPlayerWeapon(playerid),ammo);
}

Ye but can you show me an example how to give ammo to a weapon?


Re: Need help GivePlayerAmmo(playerid, weapon, ammo); - FireCat - 01.08.2010

try on the wiki to search GivePlayerAmmo i think it's there im not sure


Re: Need help GivePlayerAmmo(playerid, weapon, ammo); - Johndaonee - 02.08.2010

new ammo = GetPlayerAmmo(playerid);
SetPlayerAmmo(playerid, GetPlayerWeapon(playerid), ammo); works for me, just use that.
Remember to add + behind ammo and then how much he typed, you can do that yourself with new ammobuy = strval(tmp); and so on.. Then it would be.
SetPlayerAmmo(playerid, GetPlayerWeapon(playerid), ammo+ammobuy);
I think that would work