SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 11/07/2018, 01:36 PM   #1
Jaua10
Huge Clucker
 
Join Date: Apr 2011
Posts: 310
Reputation: 13
Default No reload gun

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 !
Jaua10 is offline   Reply With Quote
Old 11/07/2018, 03:28 PM   #2
TadePoleMG
Big Clucker
 
TadePoleMG's Avatar
 
Join Date: Apr 2018
Location: Uttar Pradesh, India
Posts: 163
Reputation: 2
Default Re: No reload gun

Hi

Use SetTimerEx for playerid and also use variable for timer like PlayerNoReloadTime[MAX_PLAYERS] and it works.
__________________
-| Gaming 'N' Scripting |-
TadePoleMG is offline   Reply With Quote
Old 11/07/2018, 03:28 PM   #3
Jaua10
Huge Clucker
 
Join Date: Apr 2011
Posts: 310
Reputation: 13
Default Re: No reload gun

I TRY TO USE IT BUT PAWN CLOSE WHEN I TRY TO COMPILE any suggestion?
Jaua10 is offline   Reply With Quote
Old 11/07/2018, 04:10 PM   #4
beckzy
Beta Tester
 
Join Date: Dec 2006
Posts: 1,276
Reputation: 172
Default Re: No reload gun

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
__________________
beckzy is offline   Reply With Quote
Old 11/07/2018, 04:49 PM   #5
GangstaSunny.
Huge Clucker
 
GangstaSunny.'s Avatar
 
Join Date: Apr 2010
Location: Hamburg - Germany
Posts: 244
Reputation: 41
Default Re: No reload gun

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;

GangstaSunny. is offline   Reply With Quote
Old 11/07/2018, 05:03 PM   #6
Jaua10
Huge Clucker
 
Join Date: Apr 2011
Posts: 310
Reputation: 13
Default Re: No reload gun

oh i got it, thanks alot bro!
Jaua10 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reload file.ini eLeCTroNNN Scripting Help 1 14/02/2015 01:39 PM
Help reload map. TVDYNAMO Scripting Help 4 05/11/2014 02:25 PM
Reload of Weapons!!! BiosMarcel Scripting Help 1 30/09/2012 03:50 PM
Reload .sav captainjohn Server Support 3 26/02/2011 08:11 PM


All times are GMT. The time now is 03:48 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.