No reload gun
#1

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 !
Reply
#2

Hi

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

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

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

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;

Reply
#6

oh i got it, thanks alot bro!
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)