Jump to content

help


Paplo

Recommended Posts

Posted
  
client 
  
Group = { 
{100000}, 
} 
addEventHandler("onClientGUIClick", guiRoot,  
    function() 
        if source == GUIEditor.staticimage[2] then 
            local money = 0  
            if source == GUIEditor.staticimage[2] then 
                money = Group[1][1] 
            end 
                if getPlayerMoney(localPlayer) >= tonumber ( money ) then 
                    triggerServerEvent('sound1',money) 
                        sound = playSound("1.mp3", false) 
                else 
                    outputChatBox(' You Not Have Money', 255, 0, 0) 
                end  
        end 
    end              
) 

  
Server 
  
addEvent("sound1", true) 
addEventHandler("sound1",getRootElement(), 
    function(money) 
        takePlayerMoney(source, tonumber( money ) ) 
        end 
) 

I need to make if the player click in the picture twice quickly

then Server that tells him to wait 60 seconds

How can I do this?

Posted

You can use a timer ( not efficient ) or you can use getTickCount.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
local lastTick = 0 -- Define a variable with the last tick count 
local toWait = 60000 -- Define a variable with the time needed to wait 
local Group = 
    { 
        { 100000 }, 
    } 
  
addEventHandler ( "onClientGUIClick", guiRoot, 
    function ( ) 
        if ( source == GUIEditor.staticimage[2] ) then 
            local money = 0  
            if ( source == GUIEditor.staticimage[2] ) then 
                money = Group[1][1] 
            end 
            if ( getTickCount ( ) - lastTick >= toWait ) then -- Calculate how long it passed since last used and compare with required time to wait. 
                if ( getPlayerMoney ( ) >= tonumber ( money ) ) then 
                    triggerServerEvent ( 'sound1', money ) 
                    sound = playSound ( "1.mp3", false ) 
                    lastTick = getTickCount ( ) 
                else 
                    outputChatBox ( 'You Not Have Money', 255, 0, 0 ) 
                end 
            else 
                outputChatBox ( "You must wait 60 seconds to use it again!", 255, 0, 0 ) 
            end 
        end 
    end             
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
local lastTick = 0 -- Define a variable with the last tick count 
local toWait = 60000 -- Define a variable with the time needed to wait 
local Group = 
    { 
        { 100000 }, 
    } 
  
addEventHandler ( "onClientGUIClick", guiRoot, 
    function ( ) 
        if ( source == GUIEditor.staticimage[2] ) then 
            local money = 0  
            if ( source == GUIEditor.staticimage[2] ) then 
                money = Group[1][1] 
            end 
            if ( getTickCount ( ) - lastTick >= toWait ) then -- Calculate how long it passed since last used and compare with required time to wait. 
                if ( getPlayerMoney ( ) >= tonumber ( money ) ) then 
                    triggerServerEvent ( 'sound1', money ) 
                    sound = playSound ( "1.mp3", false ) 
                    lastTick = getTickCount ( ) 
                else 
                    outputChatBox ( 'You Not Have Money', 255, 0, 0 ) 
                end 
            else 
                outputChatBox ( "You must wait 60 seconds to use it again!", 255, 0, 0 ) 
            end 
        end 
    end             
) 

Thank you

I'm very grateful to you

Have helped me

Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You want it global? then you must move the check server side.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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