Feche1320 Posted January 2, 2011 Share Posted January 2, 2011 Hey, Im making a userpanel, and I need to get all current server maps, so people can buy them, any ideas? Thanks Link to comment
Castillo Posted January 2, 2011 Share Posted January 2, 2011 i guess you have a grid list, right? then you have to trigger an event when you open the panel/change tab: server side: function mapsList() local resourceTable = getResources() for resourceKey, resourceValue in ipairs(resourceTable) do local name = getResourceName(resourceValue) local type = getResourceInfo ( resourceValue, "type" ) local game = getResourceInfo ( resourceValue, "gamemodes" ) if type == "map" and game == "race" then triggerClientEvent ( "sendMaps", getRootElement(), name) else cancelEvent() end end end addEvent("getMaps", true) addEventHandler("getMaps", getRootElement(), mapsList) then you will send them to client side: addEvent("sendMaps", true) addEventHandler("sendMaps", getRootElement(), function (name) local row = guiGridListAddRow(buyMapGrid) guiGridListSetItemText ( buyMapGrid, row, 1, name, false, false ) end) Link to comment
Feche1320 Posted January 2, 2011 Author Share Posted January 2, 2011 I'm gonna try it, thanks Edit: Only retrieves the map name that I'm playing Link to comment
Callum Posted January 2, 2011 Share Posted January 2, 2011 server side (modified Castillo's): function mapsList() for k, v in ipairs(getResources()) do if getResourceInfo(v,"type") == "map" then triggerClientEvent("sendMaps",getRootElement(),getResourceName(v)) end end end addEvent("getMaps", true) addEventHandler("getMaps",getRootElement(),mapsList) @Castillo: I wouldn't use 'type' as a variable, since it's a built-in lua function. Link to comment
Castillo Posted January 2, 2011 Share Posted January 2, 2011 Callum, i use "type" in many scripts and never had any problem with it. Link to comment
Aibo Posted January 2, 2011 Share Posted January 2, 2011 is it really necessary trigger an event for EVERY map? why dont just send a table with all the maps? Link to comment
Feche1320 Posted January 2, 2011 Author Share Posted January 2, 2011 Done, thanks guys. 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