Jump to content

Recommended Posts

few days ago i created a script in which when i do /getnrg i get nrg and when i do /getfcr i get fcr

then i though of creating a gui

pic of the gui

http://i.imgur.com/tr2aKBy.png

code:

  
GUIEditor = { 
    button = {}, 
    window = {}, 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(222, 217, 378, 192, "get bike", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetProperty(GUIEditor.window[1], "CaptionColour", "FFFA1818") 
  
        GUIEditor.button[1] = guiCreateButton(57, 88, 109, 57, "GET NRG", false, GUIEditor.window[1]) 
        GUIEditor.button[2] = guiCreateButton(224, 93, 126, 52, "GET FCR", false, GUIEditor.window[1]) 
        GUIEditor.label[1] = guiCreateLabel(87, 4, 206, 15, "", false, GUIEditor.window[1])     
    end 
) 

my problem is that how do i link those command to those buttons?

like when i click on get nrg button the server automatically does /getnrg and give me nrg

Link to comment

i got another problem can anyone help ??

my bind key is not working for the gui

here is my code

  
  
  
GUIEditor = { 
    button = {}, 
    window = {}, 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(222, 217, 378, 192, "get bike", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetProperty(GUIEditor.window[1], "CaptionColour", "FFFA1818") 
  
        GUIEditor.button[1] = guiCreateButton(57, 88, 109, 57, "GET NRG", false, GUIEditor.window[1]) 
        GUIEditor.button[2] = guiCreateButton(224, 93, 126, 52, "GET FCR", false, GUIEditor.window[1]) 
        GUIEditor.label[1] = guiCreateLabel(87, 4, 206, 15, "", false, GUIEditor.window[1])     
      
    end 
) 
  
bindKey("F2","down", 
            function () 
                 
                guiSetText(GUIEditor.label[1],tostring(getElementData(localPlayer,"window[1]"))) 
                if visbWndw then 
                    guiSetVisible(GUIEditor.window[1],false) 
                    showCursor(false) 
                else 
                    guiSetVisible(GUIEditor.window[1],true) 
                    showCursor(true) 
                end 
                visbWndw = not visbWndw 
            end) 
    end 
) 

can any find why it's not working ?

Edited by Guest
Link to comment
addEvent('startdraw',true) 
addEvent('stopdraw',true) 
local screenx,screeny = guiGetScreenSize() 
  
GUIEditor = { 
    button = {}, 
    window = {}, 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(222, 217, 378, 192, "get bike", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetProperty(GUIEditor.window[1], "CaptionColour", "FFFA1818") 
        GUIEditor.button[1] = guiCreateButton(57, 88, 109, 57, "GET NRG", false, GUIEditor.window[1]) 
        GUIEditor.button[2] = guiCreateButton(224, 93, 126, 52, "GET FCR", false, GUIEditor.window[1]) 
        GUIEditor.label[1] = guiCreateLabel(87, 4, 206, 15, "", false, GUIEditor.window[1])      
    end 
) 
  
bindKey ( "F2", "down", 
    function ( ) 
        local state = ( not guiGetVisible ( GUIEditor.window[1] ) ) 
        guiSetVisible ( GUIEditor.window[1], state ) 
        showCursor ( state ) 
    end 
) 

Link to comment

can you fix this i just made for linking the button to the command, sorry if i'm asking too many question , i am not that good lua scripter.

addEventHandler ( "onClientGUIClick", GUIEditor.button[1], getnrggui, false ) 
  
  
  function getnrggui () 
    executeCommandHandler("getnrg",playersource) 
end 

the commands are in server side so not sure if it will work

Link to comment

new code

  
addEvent('startdraw',true) 
addEvent('stopdraw',true) 
local screenx,screeny = guiGetScreenSize() 
  
GUIEditor = { 
    button = {}, 
    window = {}, 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(222, 217, 378, 192, "get bike", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetProperty(GUIEditor.window[1], "CaptionColour", "FFFA1818") 
        GUIEditor.button[1] = guiCreateButton(57, 88, 109, 57, "GET NRG", false, GUIEditor.window[1]) 
        GUIEditor.button[2] = guiCreateButton(224, 93, 126, 52, "GET FCR", false, GUIEditor.window[1]) 
        GUIEditor.label[1] = guiCreateLabel(87, 4, 206, 15, "", false, GUIEditor.window[1])     
    end 
addEventHandler ( "onClientGUIClick", GUIEditor.button[1], getnrggui, false ) 
end 
) 
  
bindKey ( "F2", "down", 
    function ( ) 
        local state = ( not guiGetVisible ( GUIEditor.window[1] ) ) 
        guiSetVisible ( GUIEditor.window[1], state ) 
        showCursor ( state ) 
    end 
) 
  
function getnrggui () 
    triggerServerEvent ( "getbike", localPlayer ) 
end) 

not working

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