Jump to content

Pls help


Scripting

Recommended Posts

Hi people

This code for Take A SuperBullets in weapon,

but my problem,i want set the player can rebuy Super Bullets after it end

can help and thx

Client-Side

if ( source ==  weapButton9 ) then  
local PlayerMoney = getPlayerMoney(source) 
if  ( PlayerMoney>=10000 ) then 
  
addEventHandler ( "onClientPlayerWeaponFire",getLocalPlayer(), weaponfireds ) 
function weaponfireds (weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) 
  
if ( weapon == 31) then 
triggerServerEvent ("bulletboom" ,getLocalPlayer(), hitX, hitY, hitZ ) 
end 
setTimer(function () removeEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), weaponfireds) outputChatBox("Super Bullets Has  End",255,255,0) end,60000,1, true) 
end 
  
end 

Link to comment

Client

local timer 
  
function weaponfireds( weapon ) 
    if weapon == 31 then 
        triggerServerEvent ( "bulletboom" ,source, hitX, hitY, hitZ ) 
    end  
end 
  
addCommandHandler( 'buysuperbullet', 
    function( ) 
        local PlayerMoney = getPlayerMoney( localPlayer ) 
        if PlayerMoney >= 10000 then 
            addEventHandler ( "onClientPlayerWeaponFire",localPlayer, weaponfireds ) 
            outputChatBox( "You buy super bullets.",255,255,0 ) 
            if isTimer( timer ) then 
                killTimer( timer ) 
            end 
            timer = setTimer( 
                function( ) 
                    outputChatBox( "Super Bullets Has  End",255,255,0 ) 
                    removeEventHandler ( "onClientPlayerWeaponFire",localPlayer, weaponfireds ) 
                end, 
            60000, 
            1 )  
        end 
    end 
)    

cmd /buysuperbullet

Change how you should.

And if you need remove event handler you need use like this:

  
function someEvent( ) 
    -- some code. 
end 
addEventHandler( 'someEvent',root,someEvent )    
  
  
removeEventHandler( 'someEvent',root,someEvent ) 
  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...