Giving ammo
#1

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

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

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

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

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

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

Thanks for your help.REPed you both.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)