Got it fixed! Somehow i replaced your image draw with a button for test! Also dont forget to put your picture back on client side part.
Server side
function desligarGeradorS( player, generatorID )
local id = getElementData(markers[generatorID], "generatorID")
if id == generatorID then
setElementData(markers[generatorID], "state", false)
end
end
addEvent( "desligarGerador", true )
addEventHandler( "desligarGerador", root, desligarGeradorS )
function ligarGeradorS( player, generatorID )
local id = getElementData(markers[generatorID], "generatorID")
if id == generatorID then
setElementData(markers[generatorID], "state", true)
end
end
addEvent( "ligarGerador", true )
addEventHandler( "ligarGerador", root, ligarGeradorS )
Client Side
local data = {} -- or u name it the way u want
local screenW, screenH = guiGetScreenSize()
function AbrirGeradorM( generatorID, currentFuelLevel, fuelLevel, maxFuelLevel, state, x, y, z )
data["id"] = generatorID
data["currentFuelLevel"] = currentFuelLevel
data["fuelLevel"] = fuelLevel
data["maxFuelLevel"] = maxFuelLevel
data["state"] = state
data["x"] = x
data["y"] = y
data["z"] = z
setElementData( localPlayer, "AbrirGerador", true )
end
addEvent( "AbrirGerador", true )
addEventHandler( "AbrirGerador", root, AbrirGeradorM )
addEventHandler("onClientRender", root,
function()
if getElementData( localPlayer, "AbrirGerador" ) == true then
-- if a == 0 then
-- a = 1
local generatorID = data["id"]
local currentFuelLevel = data["currentFuelLevel"]
local fuelLevel = data["fuelLevel"]
local maxFuelLevel = data["maxFuelLevel"]
if fuelLevel then
-- showCursor(true,true)
-- test = guiCreateButton(310, 359, 98, 50, "test", false)
-- addEventHandler("onClientGUIClick",test,aaa,false) -- replace back with your picture i took here one random for testing
dxDrawImage(screenW * 0.4103, screenH * 0.4401, screenW * 0.0235, screenH * 0.2734, "cube.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
dxDrawText("Combustivel:", 412, 459, 548, 491, tocolor(255, 255, 255, 255), 1.00, "default", "right", "bottom", false, false, false, false, false)
--progress gasolina
local imageWidth = screenW * 0.0147
local maxHeight = screenH * 0.2617
local imageHeight = maxHeight * fuelLevel / maxFuelLevel
dxDrawImage(screenW * 0.4147, screenH * 0.4453 + maxHeight - imageHeight, imageWidth, imageHeight, "cube.png", 0, 0, 0, tocolor(195, 181, 32, 206), false)
if data["state"] == true then
r,g,b = 74, 255, 80
dxDrawText("Desligar", screenW * 0.3206, screenH * 0.6602, screenW * 0.3963, screenH * 0.7018, tocolor(255, 255, 255, 255), 1.00, "arial", "center", "center", false, false, false, false, false)
dxDrawImage(screenW * 0.3132, screenH * 0.6471, screenW * 0.0941, screenH * 0.0664, "cube.png", 0, 0, 0, tocolor(r, g, b, 217), false)
elseif data["state"] == false then
r,g,b = 147, 74, 60
dxDrawText("Ligar", screenW * 0.3206, screenH * 0.6602, screenW * 0.3963, screenH * 0.7018, tocolor(255, 255, 255, 255), 1.00, "arial", "center", "center", false, false, false, false, false)
dxDrawImage(screenW * 0.3132, screenH * 0.6471, screenW * 0.0941, screenH * 0.0664, "cube.png", 0, 0, 0, tocolor(r, g, b, 217), false)
end
end
end
end)
addEventHandler( "onClientClick", root,
function (button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedWorld)
if button == "left" then
if state == "down" then
if getElementData( localPlayer, "AbrirGerador" ) == true then
if isCursorOnElement(screenW * 0.3206, screenH * 0.6602, screenW * 0.3963, screenH * 0.7018) then
local state = data["state"]
local x = data["x"]
local y = data["y"]
local z = data["z"]
local id = data["id"]
if data["id"] and data["state"] == true then
triggerServerEvent( "desligarGerador", resourceRoot, localPlayer, data["id"] )
elseif data["id"] and data["state"] == false then
playSound3D( "start.mp3", x, y, z )
triggerServerEvent( "ligarGerador", resourceRoot, localPlayer, data["id"] )
end
end
end
end
end
end)