Jump to content

setTimer Function !


Al3grab

Recommended Posts

Hi.

i made Super Bullets in shop ,, when the player buy it he have Explosive Bullets .. now the super bullets work .. but i want to put a time that super bullets end .. i tried ' setTimer ' function but didnt work ' maybe i didnt made it right ' .. so i need help in this :)

the code [ client-side ]

  
    local PlayerMoney = getPlayerMoney() 
    if ( PlayerMoney > 10000 ) then 
        takePlayerMoney(10000) 
        outputChatBox("You Bought Super Bullets By 10000$",source,255,255,0) 
        function superBullet(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) 
            if ( weapon ==  24) then  
            createExplosion(hitX, hitY, hitZ, 6, true, false, true)  
            end 
            if ( weapon ==  23) then  
            createExplosion(hitX, hitY, hitZ, 6, true, false, true)  
            end 
            if ( weapon ==  22) then  
            createExplosion(hitX, hitY, hitZ, 6, true, false, true)  
            end  
            if ( weapon ==  31) then  
            createExplosion(hitX, hitY, hitZ, 6, true, false, true)  
            end 
            if ( weapon ==  30) then  
            createExplosion(hitX, hitY, hitZ, 6, true, false, true)  
            end 
            if ( weapon ==  32) then  
            createExplosion(hitX, hitY, hitZ, 6, true, false, true)  
            end 
            if ( weapon ==  29) then  
            createExplosion(hitX, hitY, hitZ, 6, true, false, true)  
            end 
            if ( weapon ==  28) then  
            createExplosion(hitX, hitY, hitZ, 6, true, false, true)  
            end 
            if ( weapon ==  33) then  
            createExplosion(hitX, hitY, hitZ, 6, true, false, true)  
            end 
            if ( weapon ==  34) then  
            createExplosion(hitX, hitY, hitZ, 6, true, false, true)  
            end 
            if ( weapon ==  25) then  
            createExplosion(hitX, hitY, hitZ, 6, true, false, true)  
            end 
        end 
            addEventHandler("onClientPlayerWeaponFire", root, superBullet)   
    else 
        outputChatBox("You Dont Have Enough Money 10000$",source,255,0,0) 
    end 
  

p.s : " Don't give me a fish, teach me how to Catch it ! :D "

Link to comment

Hellllooooooooo

1º Use tigger

Client:

local PlayerMoney = getPlayerMoney()

if ( PlayerMoney > 10000 ) then

takePlayerMoney(10000)

outputChatBox("You Bought Super Bullets By 10000$",source,255,255,0)

function superBullet(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement)

if ( weapon == 24) then

tiggerServerEvent(source,"bum",source)

end

if ( weapon == 23) then

createExplosion(hitX, hitY, hitZ, 6, true, false, true)

end

if ( weapon == 22) then

createExplosion(hitX, hitY, hitZ, 6, true, false, true)

end

if ( weapon == 31) then

createExplosion(hitX, hitY, hitZ, 6, true, false, true)

end

if ( weapon == 30) then

createExplosion(hitX, hitY, hitZ, 6, true, false, true)

end

if ( weapon == 32) then

createExplosion(hitX, hitY, hitZ, 6, true, false, true)

end

if ( weapon == 29) then

createExplosion(hitX, hitY, hitZ, 6, true, false, true)

end

if ( weapon == 28) then

createExplosion(hitX, hitY, hitZ, 6, true, false, true)

end

if ( weapon == 33) then

createExplosion(hitX, hitY, hitZ, 6, true, false, true)

end

if ( weapon == 34) then

createExplosion(hitX, hitY, hitZ, 6, true, false, true)

end

if ( weapon == 25) then

createExplosion(hitX, hitY, hitZ, 6, true, false, true)

end

end

addEventHandler("onClientPlayerWeaponFire", root, superBullet)

else

outputChatBox("You Dont Have Enough Money 10000$",source,255,0,0)

end

Server:

function bulletbum(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement)

setTimer(createExplosion,2000,1,hitX, hitY, hitZ, 6, true, false, true)

end

addEvent("bum",true)

addEventHandler("bum",getRootElement(),bulletbum)

It should work

I wont give all the code cuz like how u said Don't give me a fish, teach me how to Catch it !

Link to comment

Hi ,

after i did some search in the forum ,i made a code and now it works :D , the code do : set Timer to remove Event Handler of the superBullets wich is "onClientWeaponFire" ,, the code :

  
setTimer(function () removeEventHandler("onClientPlayerWeaponFire", root, superBullet) outputChatBox("Super Bullets Has End",255,255,0) end,20000,1, true) 
  

20000 = 20 sec ' for test '

thanks ' Try ' for helping .. but ur fish didnt worked : p :D

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...