Jump to content

ajuda painel em .gui


Recommended Posts

preciso de uma ajuda eu fiz um painel em .gui pra quando eu apertar o botão ele setar uma skin em mim mais não vai , e eu queria trocar pra ser por bindkey inves de comando alguem poderia me ajudar? 

local janela = guiCreateWindow(0.27, 0.29, 0.54, 0.34, "", true)
guiWindowSetSizable(janela, false)
guiSetVisible(janela, false)

local button = guiCreateButton(0.02, 0.37, 0.44, 0.37, "Skin 1", true, janela)
guiSetFont(button, "clear-normal")
guiSetProperty(button, "NormalTextColour", "FFAAAAAA")
guiSetVisible(button, false)

local button1 = guiCreateButton(0.54, 0.38, 0.44, 0.37, "Skin 2", true, janela)
guiSetFont(button1, "clear-normal")
guiSetProperty(button1, "NormalTextColour", "FFAAAAAA")
guiSetVisible(button1, false)

local button2 = guiCreateButton(0.73, 0.13, 0.25, 0.14, "inicial", true, janela)
guiSetProperty(button2, "NormalTextColour", "FFAAAAAA")
guiSetVisible(button2, false)

local label = guiCreateLabel(0.09, 0.14, 0.61, 0.09, "pegue a skin do time que vc começou a jogar >", true, janela) 
guiSetVisible(label, false)   

local visible = false
addCommandHandler("painel", function()
    if visible == false then
        guiSetVisible(janela, true)
        guiSetVisible(button, true)
        guiSetVisible(button1, true)
        guiSetVisible(button2, true)
        guiSetVisible(label, true)
        visible = true
        showCursor(true)
    else
        guiSetVisible(janela, false)
        guiSetVisible(button, false)
        guiSetVisible(button1, false)
        guiSetVisible(button2, false)
        guiSetVisible(label, false)
        visible = false
        showCursor(false)
    end
end)

addEventHandler("onClientGUIClick", button, function (button, state)
    if button == "left" and state == "up" then
        triggerServerEvent("DarSkin", localPlayer, 294) 
    end
end)

addEventHandler("onClientGUIClick", button1, function (button, state)
    if button == "left" and state == "up" then
        triggerServerEvent("DarSkin1", localPlayer, 30) 
    end
end)

addEventHandler("onClientGUIClick", button2, function (button, state)
    if button == "left" and state == "up" then
        triggerServerEvent("DarSkin2", localPlayer, 21) 
    end
end)
addEvent("DarSkin", true)
addEventHandler("DarSkin", root, function(294)
    if skinID and tonumber(294) then
        setPedSkin(source, tonumber(294))
    end
end)

addEvent("DarSkin", true)
addEventHandler("DarSkin", root, function(30)
    if skinID and tonumber(30) then
        setPedSkin(source, tonumber(30))
    end
end)

addEvent("DarSkin", true)
addEventHandler("DarSkin", root, function(21)
    if skinID and tonumber(21) then
        setPedSkin(source, tonumber(21))
    end
end)

alguem conseguei ajeiitar e colocar para abrir por tecla??

 

Link to comment
  • Scripting Moderators

Hi, welcome to the forums! 👋

Your topic has been moved to the Portuguese scripting section so you can get better assistance in your native language.
In the future, always make sure you're using English when posting outside this language-specific section.

Link to comment
  • Other Languages Moderators

@laxante009 ele só está avisando que moveu este tópico para a seção Portuguesa, pois você postou inicialmente na seção errada.

Agora o tópico já está na seção correta, não precisa responder ele. Apenas tome cuidado para postar na área correta nas próximas vezes.


Sobre sua dúvida.

Você adicionou 3x o evento "DarSkin" no server, em vez de adicionar o "DarSkin1" e o "DarSkin2".

Outro problema é que você errou ao colocar um valor no lugar de uma variável ali no evento. Além de uma série de erros de lógica e otimização.

server-side:

addEvent("DarSkin", true)
addEventHandler("DarSkin", root, function(skinID) -- skinID recebe o valor que foi passado depois do localPlayer lá no triggerServerEvent.
    if skinID and tonumber(skinID) then
        setPedSkin(source, tonumber(skinID)) -- source é o que foi passado como segundo argumento lá no triggerServerEvent.
    end
end)

client-side:

local janela = guiCreateWindow(0.27, 0.29, 0.54, 0.34, "", true)
guiWindowSetSizable(janela, false)
guiSetVisible(janela, false)

local button = guiCreateButton(0.02, 0.37, 0.44, 0.37, "Skin 1", true, janela)
guiSetFont(button, "clear-normal")
guiSetProperty(button, "NormalTextColour", "FFAAAAAA")
guiSetVisible(button, false)

local button1 = guiCreateButton(0.54, 0.38, 0.44, 0.37, "Skin 2", true, janela)
guiSetFont(button1, "clear-normal")
guiSetProperty(button1, "NormalTextColour", "FFAAAAAA")
guiSetVisible(button1, false)

local button2 = guiCreateButton(0.73, 0.13, 0.25, 0.14, "inicial", true, janela)
guiSetProperty(button2, "NormalTextColour", "FFAAAAAA")
guiSetVisible(button2, false)

local label = guiCreateLabel(0.09, 0.14, 0.61, 0.09, "pegue a skin do time que vc começou a jogar >", true, janela) 
guiSetVisible(label, false)   

local visible = false
addCommandHandler("painel", function()
    if visible == false then
        guiSetVisible(janela, true)
        guiSetVisible(button, true)
        guiSetVisible(button1, true)
        guiSetVisible(button2, true)
        guiSetVisible(label, true)
        visible = true
        showCursor(true)
    else
        guiSetVisible(janela, false)
        guiSetVisible(button, false)
        guiSetVisible(button1, false)
        guiSetVisible(button2, false)
        guiSetVisible(label, false)
        visible = false
        showCursor(false)
    end
end)

addEventHandler("onClientGUIClick", guiRoot, function (btn, state) -- btn para não dar conflito com o guiElement chamado button.
    if btn == "left" and state == "up" then
        if source == button then -- Se o elemento que foi clicado for o button, então:
            triggerServerEvent("DarSkin", localPlayer, 294)
        elseif source == button1 then -- Senão se o elemento que foi clicado for o button1, então:
            triggerServerEvent("DarSkin", localPlayer, 30)
        elseif source == button2 then -- Senão se o elemento que foi clicado for o button2, então:
            triggerServerEvent("DarSkin", localPlayer, 21)
        end
    end
end)

 

Edited by Lord Henry
  • Thanks 1
Link to comment

não deu certo , voce corrigiu os erros de logica que você falou? e por que eu não sei de praticamente nada sobre isso eu so fiz me baseando por um tutorial , e tem como vc fazer tudo colocar os ids das skin para cada botão por que eu não tenho segurança pra mecher nisso

 

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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