Reload command
#1

hello everyone


i have a /reload command .the only problem is this:

at my weapon i have 24-13

and it puts ammo like this 34-13.how can i make it to be like 24-23

sorry for my bad english
Reply
#2

give us the code, so we can fix the errors..
Reply
#3

i dont have errors.i just wanna refill the second ammo

PS:i dont have the code at me.
Reply
#4

can someone help me
Reply
#5

you gotta show us the code , maybe you did some thing ronge . if you refuse showing us the code so why you posted here anyways ?
Reply
#6

ok this is my code


Код:
CMD:reload( playerid , params [ ] )
{



    if ( GetPlayerState ( playerid ) == 1 )
	{

        new Ammo = GetPlayerAmmo(playerid);
	
        if(GetPlayerWeapon(playerid) == 24)	ApplyAnimation ( playerid , "COLT45" , "colt45_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;	      SetPlayerAmmo(playerid, 24, Ammo+20);
        if(GetPlayerWeapon(playerid) == 22)	ApplyAnimation ( playerid , "COLT45" , "colt45_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;	      SetPlayerAmmo(playerid, 22, Ammo+20);
        if(GetPlayerWeapon(playerid) == 29)	ApplyAnimation ( playerid , "BUDDY" ,  "buddy_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;	          SetPlayerAmmo(playerid, 29, Ammo+20);
        if(GetPlayerWeapon(playerid) == 30)	ApplyAnimation ( playerid , "BUDDY" ,  "buddy_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;	          SetPlayerAmmo(playerid, 30, Ammo+20);
        if(GetPlayerWeapon(playerid) == 31)	ApplyAnimation ( playerid , "BUDDY" ,  "buddy_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;	          SetPlayerAmmo(playerid, 31, Ammo+20);
        if(GetPlayerWeapon(playerid) == 25) ApplyAnimation ( playerid , "PYTHON" , "pythonreload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;	          SetPlayerAmmo(playerid, 25, Ammo+20);
        if(GetPlayerWeapon(playerid) == 26) ApplyAnimation ( playerid , "COLT45" , "sawnoff_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;	      SetPlayerAmmo(playerid, 26, Ammo+20);
        if(GetPlayerWeapon(playerid) == 27) ApplyAnimation ( playerid , "PYTHON" , "pythonreload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;	          SetPlayerAmmo(playerid, 27, Ammo+20);
        if(GetPlayerWeapon(playerid) == 32) ApplyAnimation ( playerid , "UZI" ,    "UZI_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;	          SetPlayerAmmo(playerid, 32, Ammo+20);
        if(GetPlayerWeapon(playerid) == 28) ApplyAnimation ( playerid , "UZI" ,    "UZI_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;	          SetPlayerAmmo(playerid, 28, Ammo+20);
        if(GetPlayerWeapon(playerid) == 23) ApplyAnimation ( playerid , "SILENCED" ,"silence_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;	      SetPlayerAmmo(playerid, 23, Ammo+20);

                          
	}
    return ( 1 ) ;
}
Reply
#7

please help
Reply
#8

I tested it and worked fine (tested only on deagle, but it should works for all others)
It sets the player ammo to 0 to reset the weapon, and then give it again with new ammo, then GTA does the rest
pawn Код:
CMD:reload( playerid , params [ ] )
{
    #pragma unused params
    if ( GetPlayerState ( playerid ) == 1 )
    {
        new Ammo = GetPlayerAmmo(playerid);
   
        if(GetPlayerWeapon(playerid) == 24)
        {
            ApplyAnimation ( playerid , "COLT45" , "colt45_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;
            SetPlayerAmmo(playerid, 24, 0);
            GivePlayerWeapon(playerid, 24, Ammo);
        }
        if(GetPlayerWeapon(playerid) == 22)
        {
            ApplyAnimation ( playerid , "COLT45" , "colt45_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;
            SetPlayerAmmo(playerid, 22, 0);
            GivePlayerWeapon(playerid, 22, Ammo);
        }
        if(GetPlayerWeapon(playerid) == 29)
        {
            ApplyAnimation ( playerid , "BUDDY" ,  "buddy_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;
            SetPlayerAmmo(playerid, 29, 0);
            GivePlayerWeapon(playerid, 29, Ammo);
        }
        if(GetPlayerWeapon(playerid) == 30)
        {
            ApplyAnimation ( playerid , "BUDDY" ,  "buddy_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;
            SetPlayerAmmo(playerid, 30, 0);
            GivePlayerWeapon(playerid, 30, Ammo);
        }
        if(GetPlayerWeapon(playerid) == 31)
        {
            ApplyAnimation ( playerid , "BUDDY" ,  "buddy_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;
            SetPlayerAmmo(playerid, 31, 0);
            GivePlayerWeapon(playerid, 31, Ammo);
        }
        if(GetPlayerWeapon(playerid) == 25)
        {
            ApplyAnimation ( playerid , "PYTHON" , "pythonreload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;
            SetPlayerAmmo(playerid, 25, 0);
            GivePlayerWeapon(playerid, 25, Ammo);
        }
        if(GetPlayerWeapon(playerid) == 26)
        {
            ApplyAnimation ( playerid , "COLT45" , "sawnoff_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;
            SetPlayerAmmo(playerid, 26, 0);
            GivePlayerWeapon(playerid, 26, Ammo);
        }
        if(GetPlayerWeapon(playerid) == 27)
        {
            ApplyAnimation ( playerid , "PYTHON" , "pythonreload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;
            SetPlayerAmmo(playerid, 27, 0);
            GivePlayerWeapon(playerid, 27, Ammo);
        }
        if(GetPlayerWeapon(playerid) == 32)
        {
            ApplyAnimation ( playerid , "UZI" ,    "UZI_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;
            SetPlayerAmmo(playerid, 32, 0);
            GivePlayerWeapon(playerid, 32, Ammo);
        }
        if(GetPlayerWeapon(playerid) == 28)
        {
            ApplyAnimation ( playerid , "UZI" ,    "UZI_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;
            SetPlayerAmmo(playerid, 28, 0);
            GivePlayerWeapon(playerid, 28, Ammo);
        }
        if(GetPlayerWeapon(playerid) == 23)
        {
            ApplyAnimation ( playerid , "SILENCED" ,"silence_reload" , 4.0 , 0 , 0 , 0 , 0 , 0 ) ;
            SetPlayerAmmo(playerid, 23, 0);
            GivePlayerWeapon(playerid, 23, Ammo);
        }
    }
    return 1;
}
Reply
#9

AND - switch case!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)