Machine Posted August 14, 2012 Share Posted August 14, 2012 GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Window[1] = guiCreateWindow(270,216,449,476,"Maps Panel",false) guiWindowSetSizable(GUIEditor_Window[1],false) guiSetVisible( GUIEditor_Window[1], false ) showCursor ( false ) function showGUI ( ) guiSetVisible ( GUIEditor_Window[1], not guiGetVisible ( GUIEditor_Window[1] ) ) showCursor ( guiGetVisible ( GUIEditor_Window[1] ) ) end bindKey ( "F2","down", showGUI ) Link to comment
Machine Posted August 14, 2012 Author Share Posted August 14, 2012 it keep giving me error about GUIEditor_Window[1] nil value Link to comment
scratcher911 Posted August 14, 2012 Share Posted August 14, 2012 There isn't anything wrong with the code. Are you sure that is client side ? Show me your meta.xml Link to comment
Machine Posted August 14, 2012 Author Share Posted August 14, 2012 sorry my falt i made it server side hahaha! Link to comment
manve1 Posted August 14, 2012 Share Posted August 14, 2012 Everything to do with GUI's will be client side... Link to comment
Machine Posted August 14, 2012 Author Share Posted August 14, 2012 whats wrong in this code GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Grid = {} GUIEditor_Window[1] = guiCreateWindow(270,216,449,476,"Maps Panel",false) guiWindowSetSizable(GUIEditor_Window[1],false) GUIEditor_Grid[1] = guiCreateGridList(9,20,431,394,false,GUIEditor_Window[1]) for _, map in ipairs ( exports['mapmanager']:getMapsCompatibleWithGamemode ( 'race' ) ) do local row = guiGridListAddRow ( urGridList ) guiGridListSetItemText ( urGridList, row, 1, tostring ( getResourceInfo ( map, 'name' ) ), false, false ) end guiGridListSetSelectionMode(GUIEditor_Grid[1],2) GUIEditor_Button[1] = guiCreateButton(12,419,190,46,"Refresh Maps List",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(258,419,182,46,"Buy Map!",false,GUIEditor_Window[1]) guiSetVisible( GUIEditor_Window[1], false ) showCursor ( false ) function showGUI ( ) guiSetVisible ( GUIEditor_Window[1], not guiGetVisible ( GUIEditor_Window[1] ) ) showCursor ( guiGetVisible ( GUIEditor_Window[1] ) ) end bindKey ( "F2","down", showGUI ) Link to comment
INVINCIBLE Posted August 14, 2012 Share Posted August 14, 2012 -- client.lua --- Try this: GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Grid = {} GUIEditor_Window[1] = guiCreateWindow(270,216,449,476,"Panel",false) guiWindowSetSizable(GUIEditor_Window[1],false) GUIEditor_Grid[1] = guiCreateGridList(9,20,431,394,false,GUIEditor_Window[1]) guiGridListSetSelectionMode(GUIEditor_Grid[1],2) guiGridListAddColumn(GUIEditor_Grid[1],"maps",1.2) GUIEditor_Button[1] = guiCreateButton(12,419,190,46,"Refresh MapList",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(258,419,182,46,"Buy Map!",false,GUIEditor_Window[1]) guiSetVisible( GUIEditor_Window[1], false ) showCursor ( false ) function getMaps() setTimer(callServerFunction,500,1,"getServerMaps",getLocalPlayer()) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),getMaps) --maps tab function loadMaps(gamemodeMapTable, gamemode, map) guiGridListClear(GUIEditor_Grid[1]) if gamemodeMapTable then aGamemodeMapTable = gamemodeMapTable for id,gamemode in pairs (gamemodeMapTable) do if (gamemode.name == "Race") then for id,map in ipairs (gamemode.maps) do local row = guiGridListAddRow(GUIEditor_Grid[1]) guiGridListSetItemText ( GUIEditor_Grid[1], row, 1, map.name, false, false ) end end end end end function callClientFunction(funcname, ...) local arg = { ... } if (arg[1]) then for key, value in next, arg do arg[key] = tonumber(value) or value end end loadstring("return "..funcname)()(unpack(arg)) end addEvent("onServerCallsClientFunction", true) addEventHandler("onServerCallsClientFunction", resourceRoot, callClientFunction) -- -- Call server function -- function callServerFunction(funcname, ...) local arg = { ... } if (arg[1]) then for key, value in next, arg do if (type(value) == "number") then arg[key] = tostring(value) end end end triggerServerEvent("onClientCallsServerFunction", resourceRoot , funcname, unpack(arg)) end function oppenz() if guiGetVisible ( GUIEditor_Window[1] ) then guiSetVisible ( GUIEditor_Window[1], false ) showCursor(false) guiSetInputEnabled(false) else guiSetVisible ( GUIEditor_Window[1], true ) showCursor(true) guiSetInputEnabled(true) end end bindKey("F6","down",oppenz) server.lua Try this: function callServerFunction(funcname, ...) local arg = { ... } if (arg[1]) then for key, value in next, arg do arg[key] = tonumber(value) or value end end loadstring("return "..funcname)()(unpack(arg)) end addEvent("onClientCallsServerFunction", true) addEventHandler("onClientCallsServerFunction", getRootElement() , callServerFunction) function callClientFunction(client, funcname, ...) local arg = { ... } if (arg[1]) then for key, value in next, arg do if (type(value) == "number") then arg[key] = tostring(value) end end end triggerClientEvent(client, "onServerCallsClientFunction", getRootElement(), funcname, unpack(arg or {})) end function getServerMaps (loadList) local tableOut if loadList then tableOut = {} local gamemodes = {} gamemodes = call(getResourceFromName("mapmanager"), "getGamemodes") for id,gamemode in ipairs (gamemodes) do tableOut[id] = {} tableOut[id].name = getResourceInfo(gamemode, "name") or getResourceName(gamemode) tableOut[id].resname = getResourceName(gamemode) tableOut[id].maps = {} local maps = call(getResourceFromName("mapmanager"), "getMapsCompatibleWithGamemode" , gamemode) for _,map in ipairs (maps) do table.insert(tableOut[id]["maps"] ,{name = getResourceInfo(map, "name") or getResourceName(map), resname = getResourceName(map) }) end table.sort(tableOut[id]["maps"], sortCompareFunction) end table.sort((tableOut), sortCompareFunction) table.insert(tableOut, {name = "no gamemode", resname = "no gamemode", maps = {}}) local countGmodes = #tableOut local maps = call(getResourceFromName("mapmanager"), "getMapsCompatibleWithGamemode") for id,map in ipairs (maps) do table.insert(tableOut[countGmodes]["maps"] ,{name = getResourceInfo(map, "name") or getResourceName(map), resname = getResourceName(map) }) end table.sort(tableOut[countGmodes]["maps"], sortCompareFunction) end local map = call(getResourceFromName("mapmanager"), "getRunningGamemodeMap") local gamemode = call(getResourceFromName("mapmanager"), "getRunningGamemode") gamemode = gamemode and getResourceName(gamemode) or "N/A" map = map and getResourceName(map) or "N/A" callClientFunction(loadList,"loadMaps", tableOut, gamemode, map) end function sortCompareFunction(s1, s2) if type(s1) == "table" and type(s2) == "table" then s1, s2 = s1.name, s2.name end s1, s2 = s1:lower(), s2:lower() if s1 == s2 then return false end local byte1, byte2 = string.byte(s1:sub(1,1)), string.byte(s2:sub(1,1)) if not byte1 then return true elseif not byte2 then return false elseif byte1 < byte2 then return true elseif byte1 == byte2 then return sortCompareFunction(s1:sub(2), s2:sub(2)) else return false end end function callGetMaps() for i,player in ipairs(getElementsByType("player")) do triggerClientEvent(player,"getMaps") end end addCommandHandler("rebuildMaps",callGetMaps) i've tested,its work 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