SA-MP Forums Archive
Reload command - 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: Reload command (/showthread.php?tid=455830)



Reload command - Alexica721 - 03.08.2013

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


Re: Reload command - DetoNater - 03.08.2013

give us the code, so we can fix the errors..


Re: Reload command - Alexica721 - 03.08.2013

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

PS:i dont have the code at me.


Re: Reload command - Alexica721 - 03.08.2013

can someone help me


Re: Reload command - Chrisis - 03.08.2013

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 ?


Re: Reload command - Alexica721 - 03.08.2013

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 ) ;
}



Re: Reload command - Alexica721 - 04.08.2013

please help


Re: Reload command - Sk1lleD - 04.08.2013

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;
}



Re: Reload command - RajatPawar - 04.08.2013

AND - switch case!