Jump to content

Seemingly Simple GUI Question [Solved]


Recommended Posts

Hello!

I've got this code:

client.lua

  
-- GUI Init Stuff 
GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Grid = {} 
  
GUIEditor_Window[1] = guiCreateWindow(289,156,220,324,"Objects",false) 
GUIEditor_Grid[1] = guiCreateGridList(9,26,202,253,false,GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
GUIEditor_Button[1] = guiCreateButton(16,289,187,26,"Create Object",false,GUIEditor_Window[1]) 
  
showCursor( false ) 
guiSetVisible ( GUIEditor_Window[1], false ) 
guiSetInputEnabled(false) 
  
-- Fills the Gridlist with Objects 
function fillList() 
    local searchMax = 0 
    local node = xmlLoadFile("conf/objects.xml") 
    local id = 0 
    local name = 0 
    guiGridListClear( GUIEditor_Grid[1] ) 
    local column = guiGridListAddColumn(GUIEditor_Grid[1],"Objects", 1) 
    if node then 
        while ( true ) do 
            local object = xmlFindChild ( node, "object", searchMax ) 
            if ( not object ) then break end 
            id = tonumber ( xmlNodeGetAttribute ( object, "id" ) ) 
            name = xmlNodeGetAttribute ( object, "name" ) 
            guiGridListSetItemText ( GUIEditor_Grid[1], searchMax, column, name, false, false ) 
            guiGridListSetItemData ( GUIEditor_Grid[1], searchMax, column, id ) 
            searchMax = searchMax + 1 
        end 
    else 
        outputChatBox("Resource 'objects' Error: 0x000001") 
    end 
    xmlUnloadFile( node ) 
end 
addCommandHandler("fillHerUp", fillList) 
fillList() 
  
-- Shows or Hides the GUI 
function toggleGUI( key, keyState ) 
    if guiGetVisible ( GUIEditor_Window[1] ) then 
        showCursor( false ) 
        guiSetVisible ( GUIEditor_Window[1], false ) 
        guiSetInputEnabled(false) 
    else 
        showCursor( true ) 
        guiSetVisible ( GUIEditor_Window[1], true ) 
        guiSetInputEnabled(true) 
    end 
end 
addCommandHandler( "obj", toggleGUI ) 
bindKey( "o", "down", "obj" ) 
  
function makeObj( button ) 
    if button == "left" then 
        local row, col = guiGridListGetSelectedItem ( GUIEditor_Grid[1] ) 
        local objModel = guiGridListGetItemData ( GUIEditor_Grid[1], row, col ) 
        triggerServerEvent("onObjectMake", objModel, getLocalPlayer() ) 
    end 
end 
addEventHandler ( "onClientGUIClick", GUIEditor_Button[1], makeObj, false ) 
  

But everytime I run it, it returns the error message ( outputChatBox("Resource 'objects' Error: 0x000001") ).

So I'm guessing it doesn't load the XML file. I have set the paths correctly, with "objects.xml" being in the "conf" folder.

Help is appreciated.

Nevermind - Solved!

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