Help with max ammo for weapon
#1

Hi all. I have a question for player weapons. How can i set max ammo for some weapon in hand.? Example:
Max ammo in hand for Desert Eagle is 150 and when someone give me deagle with 200 ammo, it should automatically reduced ammo in my "hand" on 150. and it should tell me in chat that max ammo fot that weapon is 150. Thanks in advance
Reply
#2

Try this out.

PHP код:
new weapons[13][2];
for(new 
i=0i<13i++)
{
    
GetPlayerWeaponData(playeridiweapons[i][0], weapons[i][1]);
}
if(
weapons[2][0] == 24 && weapons[2][1] > 150)
{
    
// Checks if player has Desert Eagle on their inventory.
    // If the ammo for Desert Eagle exceeds 150, It will be setted back to 150.
    
SetPlayerAmmo(playeridweapons[2][0], 150);

Reply
#3

Код:
forward OruzjeRuka(playerid);
public OruzjeRuka(playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
new weapons[13][2];
for(new i=0; i<13; i++)
{
    GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
}
 
if(weapons[2][0] == 24 && weapons[2][1] > 150)
{
    // Checks if player has Desert Eagle on their inventory.
    // If the ammo for Desert Eagle exceeds 150, It will be setted back to 150.
    SetPlayerAmmo(playerid, weapons[2][0], 150);
}
return 1;
}
I put this under OnGameModeInit() I put the timer to check SetTimer("OruzjeRuka",1000,1);

OruzjeRuka=WeaponHand

I want to put other weapons too.
Reply
#4

Quote:
Originally Posted by Markoni990
Посмотреть сообщение
Код:
forward OruzjeRuka(playerid);
public OruzjeRuka(playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
new weapons[13][2];
for(new i=0; i<13; i++)
{
    GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
}
 
if(weapons[2][0] == 24 && weapons[2][1] > 150)
{
    // Checks if player has Desert Eagle on their inventory.
    // If the ammo for Desert Eagle exceeds 150, It will be setted back to 150.
    SetPlayerAmmo(playerid, weapons[2][0], 150);
}
return 1;
}
I put this under OnGameModeInit() I put the timer to check SetTimer("OruzjeRuka",1000,1);

OruzjeRuka=WeaponHand

I want to put other weapons too.
Simply do this

PHP код:
if(weapons[weaponslot][0] == weaponid && weapons[weaponslot][1] > ammo)
{
    
// Code here
    
SetPlayerAmmo(playeridweapons[weaponslot][0], ammo);

Weapon Slots for each WeaponIDs can be found here
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)