SA-MP Forums Archive
No reload gun - 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: No reload gun (/showthread.php?tid=656260)



No reload gun - Jaua10 - 11.07.2018

Hey guys i made a simple cmd about no reload my guns, but i cant disabled it when i make /noreload this is what i have:

PHP Code:
CMD:noreload(playeridparams[])
    {
        if(
IsPlayerConnected(playerid))
        {
            if (
PlayerInfo[playerid][pAdmin] >= 3)
            {
                {
                    {
                        
SetTimer("NoReload"2501);
                        
SendClientMessage(playeridCOLOR_SUCCESS"No reload mode, has been enabled !");
                    }
                }
            }
            else
            {
                
SendClientMessage(playeridCOLOR_CORRECTION"You are not authorized to use this command !");
            }
        }
        return 
1;
    }
public 
NoReload(playerid)
{
    
GivePlayerWeapon(playeridGetPlayerWeapon(playerid), 10);
    return 
1;

what i made bad? now i want if i type again /noreload says No reload mode, has been disabled !


Re: No reload gun - TadePoleMG - 11.07.2018

Hi

Use SetTimerEx for playerid and also use variable for timer like PlayerNoReloadTime[MAX_PLAYERS] and it works.


Re: No reload gun - Jaua10 - 11.07.2018

I TRY TO USE IT BUT PAWN CLOSE WHEN I TRY TO COMPILE any suggestion?


Re: No reload gun - beckzy - 11.07.2018

I'm not sure why you're giving the player 10 ammo every 0.25 seconds, but the correct way to do it is: https://pastebin.com/RbZMa3Ly


Re: No reload gun - GangstaSunny. - 11.07.2018

Quote:
Originally Posted by BeckzyBoi
View Post
I'm not sure why you're giving the player 10 ammo every 0.25 seconds, but the correct way to do it is: https://pastebin.com/RbZMa3Ly
Which gives the player 10 ammo every 0.25 seconds even if he's not shooting. Also he would lose his weapon if he got like a minigun and a little lag.

This would be the correct way.
PHP Code:
CMD:noreload(playeridparams[])
{
    if(
IsPlayerConnected(playerid))
    {
        if(
PlayerInfo[playerid][pAdmin] < 3)return SendClientMessage(playeridCOLOR_CORRECTION"You are not authorized to use this command !");
        if(
GetPVarInt(playerid,"NoReloadActive") > 0)//turn off
        
{
            
DeletePVar(playerid,"NoReloadActive");
            
SendClientMessage(playeridCOLOR_SUCCESS"No-Reload deactivated!");
        }
        else 
//turn on
        
{
            
SetPVarInt(playerid,"NoReloadActive",1);
            
SendClientMessage(playeridCOLOR_SUCCESS"No-Reload activated!");
        }
        return 
1;
    }
    return 
1;
}
public 
OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ//called if the player shot
{
    if(
GetPVarInt(playerid,"NoReloadActive") > 0){GivePlayerWeapon(playeridGetPlayerWeapon(playerid), GetPlayerAmmo(playerid)+10);} // give the player +10 ammo
    
return 1;




Re: No reload gun - Jaua10 - 11.07.2018

oh i got it, thanks alot bro!