SA-MP Forums Archive
Giving 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)
+--- Thread: Giving ammo (/showthread.php?tid=455403)



Giving ammo - Necip - 01.08.2013

How can I make a command that gives infinity ammo to all of a player's weapons?


Re: Giving ammo - Yashas - 01.08.2013

GivePlayerWeapon(pid,wid,ammo); give ammo more than 10000, it will look like infinite ammo in the player's screen but note the ammo will keep decreasing.However updating it after some time would fix it.


Re: Giving ammo - BigGroter - 01.08.2013

pawn Код:
GetPlayerWeaponData(playerid, slot, &weapons, &ammo);
And like Yashas said.
pawn Код:
GivePlayerWeapon(pid,wid,ammo);



Re: Giving ammo - Necip - 01.08.2013

I know that function but I want to know how to give full ammo to all of the weapons he holds.


Re: Giving ammo - Yashas - 01.08.2013

GetPlayerWeaponData will provide you with the Weapon ID in the respective slot.Then use that ID and just set the ammo to 10000+ and done!.

Код:
stock GiveInfiniteAmmoToWeponSlot(playerid,weaponid,slotid=0)
{
    new wid,ammo;   
    if(slotid) { GetPlayerWeaponData(playerid,slotid,wid,ammo);
    else { wid = weaponid }
    GivePlayerWeapon(playerid,wid,10000);    
}
This code might do the job.You can provide slotid or weaponid, its optional.Call it with the correct arguments and it will work.List of weapon IDs are available at SAMP wiki.

EDIT:This will give infinity ammo for all the weapons.
Код:
stock GiveInfinityAmmoToAllWeapons(playerid)
{
    new wid,ammo; 
    for (new i = 0; i < 13; i++)
    {
         GetPlayerWeaponData(playerid, i,wid, ammo);
         GivePlayerWeapon(playerid,wid,10000); 
     }
}



Re: Giving ammo - JimmyCh - 01.08.2013

Maybe something like the following:
pawn Код:
CMD:giveallinf(playerid, params[])
{
if(!IsPlayerAdmin(playerid) return SendClientMessage(playerid, -1, "You're not an RCON admin!");
else
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected[i])
    new gunid;
    gunid = GetPlayerWeapon(i);
    SetPlayerAmmo(i, gunid, cellmax);
}
}
return 1;
}
Like that?


Re: Giving ammo - Necip - 01.08.2013

Thanks for your help.REPed you both.