Ivo1313 Posted January 15, 2020 Share Posted January 15, 2020 Hello guys, im scripting a menu for buying car fixes, it's working just well but everytime i hit the buy button, the game registers my click as 2+ clicks, what i can do about it? Here is the function: (this one is triggered by a client event) function arrumar(player) if getPlayerMoney(client) >= 1500 then local theVehicle = getPedOccupiedVehicle(client) if theVehicle and getVehicleController (theVehicle) == client then fixVehicle(theVehicle) takePlayerMoney(client, 1500) outputChatBox("Um mecanico arrumou seu carro para você!", client, 0,255,0) else outputChatBox("Você não está em um veículo!!", client, 255,0,0) end else outputChatBox("Você não tem dinheiro suficiente para esse serviço", client, 255,0,0) end end addEvent("arrumar", true) addEventHandler("arrumar", root, arrumar) Link to comment
#~Scared Posted January 16, 2020 Share Posted January 16, 2020 16 hours ago, Ivo1313 said: Hello guys, im scripting a menu for buying car fixes, it's working just well but everytime i hit the buy button, the game registers my click as 2+ clicks, what i can do about it? Here is the function: (this one is triggered by a client event) function arrumar(player) if getPlayerMoney(client) >= 1500 then local theVehicle = getPedOccupiedVehicle(client) if theVehicle and getVehicleController (theVehicle) == client then fixVehicle(theVehicle) takePlayerMoney(client, 1500) outputChatBox("Um mecanico arrumou seu carro para você!", client, 0,255,0) else outputChatBox("Você não está em um veículo!!", client, 255,0,0) end else outputChatBox("Você não tem dinheiro suficiente para esse serviço", client, 255,0,0) end end addEvent("arrumar", true) addEventHandler("arrumar", root, arrumar) show your client side code Link to comment
Moderators Patrick Posted January 16, 2020 Moderators Share Posted January 16, 2020 It is possible because the event triggered on button press and release. Trigger event only on button release. addEventHandler("onClientClick", root, function(button, state) if button == "left" then -- if clicked with left button if state == "up" then -- if button released -- trigger end end end) 1 Link to comment
Moderators IIYAMA Posted January 16, 2020 Moderators Share Posted January 16, 2020 17 hours ago, Ivo1313 said: what i can do about it? Not create and attach the eventHandler to a new function. Use global named functions that can be attached and detached when it is no longer required. You currently created something you might consider similar to a memory leak. 1 Link to comment
Ivo1313 Posted January 18, 2020 Author Share Posted January 18, 2020 On 16/01/2020 at 12:26, stPatrick said: It is possible because the event triggered on button press and release. Trigger event only on button release. addEventHandler("onClientClick", root, function(button, state) if button == "left" then -- if clicked with left button if state == "up" then -- if button released -- trigger end end end) Hey, thx, this worked for me Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now