novo Posted December 17, 2011 Share Posted December 17, 2011 Hi all. I made a shop for buy map, but it's not working. EDIT: There is an error: Bad argument "#1" to "ipairs" (table expected, got bolean) Here is my code: Client-Side: -------------------------- MAP SHOP --------------------------------- mapTab = guiCreateTab("Maps",GUIEditor_TabPanel[1]) mapList = guiCreateGridList(4,5,554,166,false,mapTab) guiGridListSetSelectionMode(mapList,2) buyMap = guiCreateButton(4,173,187,41,"Buy map",false,mapTab) rateMap = guiCreateButton(196,173,121,41,"Rate this map",false,mapTab) rateValue = guiCreateEdit(318,172,51,42,"",false,mapTab) reportMap = guiCreateButton(371,172,186,42,"Report this map",false,mapTab) authorMapColumn = guiGridListAddColumn( mapList, "Author", 0.2 ) mapMapColumn = guiGridListAddColumn( mapList, "Name", 0.5 ) guiGridListSetSortingEnabled ( mapMapColumn, false ) guiGridListAutoSizeColumn( list_avatar, authorMapColumn) triggerServerEvent('getMaps', getRootElement()) addEvent('sendMaps', true) addEventHandler('sendMaps', getRootElement(), function(name, author) local row = guiGridListAddRow(mapList) guiGridListSetItemText(mapList, row, 1, name, false, false) guiGridListSetItemText ( mapList, row, authorMapColumn, author, false, false ) guiGridListSetItemText ( mapList, row, mapMapColumn, name, false, false ) end ) addEventHandler('onClientGUIClick', buyMap, function() local row, mapMapColumn = guiGridListGetSelectedItem(mapList) local map = guiGridListGetItemText(mapList, row, mapMapColumn) triggerServerEvent("buyMapFromPanel", getLocalPlayer(), map) end , false) Server-side: -------------- MAP -------------------- function mapsList() local resourceTable = getResources() for resourceKey, resourceValue in ipairs(resourceTable) do local name = getResourceInfo(resourceValue, 'name') local type = getResourceInfo(resourceValue, 'type') local game = getResourceInfo(resourceValue, 'gamemodes') local author = getResourceInfo(resourceValue, 'author') if type == 'map' and game == 'race' then triggerClientEvent('sendMaps', getRootElement(), name, author) else cancelEvent() end end end addEvent('getMaps', true) addEventHandler('getMaps', getRootElement(), mapsList) addEvent('buyMapFromPanel', true) function buyMFP(mapname) if g_ForcedNextMap then outputChatBox('#575757[shop]#c8c8c8Next map is '..getMapName(g_ForcedNextMap),source,255,255,0, true) return end local query = #{mapname}>0 and table.concat({mapname},' ') or nil if not query then if g_ForcedNextMap then outputChatBox('#575757[shop]#c8c8c8Next map is '..getMapName(g_ForcedNextMap),source,255,255,0, true) else outputChatBox('#575757[shop]#c8c8c8Next map is not set',source,255,255,0, true) end return end local map, errormsg = findMap(query) if not map then outputChatBox(errormsg, source) return end if lastmap_B == map then outputChatBox('#575757[shop]#c8c8c8That map has been palyed too much recently !',source,255,255,0, true) else g_ForcedNextMap = map local nameAh = getPlayerName(source) local nameAhB = string.gsub(nameAh, "#%x%x%x%x%x%x", "") outputChatBox('#575757[shop]#c8c8c8'..nameAhB..' bought map '..getMapName(g_ForcedNextMap)..' for $3500.',getRootElement(),255,255,0, true) givePlayerMoney(source, -3500) setElementData(source, 'Money', getPlayerMoney(source)) lastmap_B = g_ForcedNextMap end end addEventHandler('buyMapFromPanel', getRootElement(), buyMFP) Please help <3 Thanks. Link to comment
novo Posted December 17, 2011 Author Share Posted December 17, 2011 Sorry for double post but i really need help. HELP ME <3 Link to comment
Castillo Posted December 17, 2011 Share Posted December 17, 2011 -- client side: -------------------------- MAP SHOP --------------------------------- mapTab = guiCreateTab("Maps",GUIEditor_TabPanel[1]) mapList = guiCreateGridList(4,5,554,166,false,mapTab) guiGridListSetSelectionMode(mapList,2) buyMap = guiCreateButton(4,173,187,41,"Buy map",false,mapTab) rateMap = guiCreateButton(196,173,121,41,"Rate this map",false,mapTab) rateValue = guiCreateEdit(318,172,51,42,"",false,mapTab) reportMap = guiCreateButton(371,172,186,42,"Report this map",false,mapTab) authorMapColumn = guiGridListAddColumn( mapList, "Author", 0.2 ) mapMapColumn = guiGridListAddColumn( mapList, "Name", 0.5 ) guiGridListSetSortingEnabled ( mapMapColumn, false ) guiGridListAutoSizeColumn( list_avatar, authorMapColumn) triggerServerEvent('getMaps', localPlayer) addEvent('sendMaps', true) addEventHandler('sendMaps', getRootElement(), function(maps) for index, map in ipairs(maps) do local row = guiGridListAddRow(mapList) guiGridListSetItemText(mapList, row, 1, name, false, false) guiGridListSetItemText ( mapList, row, authorMapColumn, map.author, false, false ) guiGridListSetItemText ( mapList, row, mapMapColumn, map.name, false, false ) end end ) addEventHandler('onClientGUIClick', buyMap, function() local row, mapMapColumn = guiGridListGetSelectedItem(mapList) local map = guiGridListGetItemText(mapList, row, mapMapColumn) triggerServerEvent("buyMapFromPanel", getLocalPlayer(), map) end ,false) -- server side: function mapsList() local tempTable = {} for resourceKey, resourceValue in ipairs(getResources()) do local name = getResourceInfo(resourceValue, 'name') local type = getResourceInfo(resourceValue, 'type') local game = getResourceInfo(resourceValue, 'gamemodes') local author = getResourceInfo(resourceValue, 'author') if (type == 'map' and game == 'race') then table.insert(tempTable, {author=author, name=name}) end end triggerClientEvent(source, 'sendMaps', source, tempTable) end addEvent('getMaps', true) addEventHandler('getMaps', getRootElement(), mapsList) function buyMFP(mapname) if g_ForcedNextMap then outputChatBox('#575757[shop]#c8c8c8Next map is '..getMapName(g_ForcedNextMap),source,255,255,0, true) return end local query = #{mapname}>0 and table.concat({mapname},' ') or nil if not query then if g_ForcedNextMap then outputChatBox('#575757[shop]#c8c8c8Next map is '..getMapName(g_ForcedNextMap),source,255,255,0, true) else outputChatBox('#575757[shop]#c8c8c8Next map is not set',source,255,255,0, true) end return end local map, errormsg = findMap(query) if not map then outputChatBox(errormsg, source) return end if lastmap_B == map then outputChatBox('#575757[shop]#c8c8c8That map has been palyed too much recently !',source,255,255,0, true) else g_ForcedNextMap = map local nameAh = getPlayerName(source) local nameAhB = string.gsub(nameAh, "#%x%x%x%x%x%x", "") outputChatBox('#575757[shop]#c8c8c8'..nameAhB..' bought map '..getMapName(g_ForcedNextMap)..' for $3500.',getRootElement(),255,255,0, true) givePlayerMoney(source, -3500) setElementData(source, 'Money', getPlayerMoney(source)) lastmap_B = g_ForcedNextMap end end addEvent('buyMapFromPanel', true) addEventHandler('buyMapFromPanel', getRootElement(), buyMFP) Link to comment
novo Posted December 17, 2011 Author Share Posted December 17, 2011 When i open tab for map list, i cant see maps D: Plz help <3 Link to comment
Castillo Posted December 17, 2011 Share Posted December 17, 2011 Any errors? did you set the client side as type="client" in meta.xml? and server side as type="server". Link to comment
novo Posted December 17, 2011 Author Share Posted December 17, 2011 It's on a full panel, when i press "F7" the panel opens. Then, i have a tab called "Maps" where i see the list of maps, and they aren't showing. Ofc, server=server - client=client. Come to my server and check it: 109.70.148.17:22021 Bye <3 Link to comment
Castillo Posted December 17, 2011 Share Posted December 17, 2011 No errors shown on debug..? Link to comment
novo Posted December 17, 2011 Author Share Posted December 17, 2011 There is an error: Bad argument "#1" to "ipairs" (table expected, got bolean) Link to comment
novo Posted December 18, 2011 Author Share Posted December 18, 2011 Sorry for double post. Now my server is v. 1.2, on the userpanel now the maps are showing. But same error: There is an error: Bad argument "#1" to "ipairs" (table expected, got bolean) Link to comment
Castillo Posted December 18, 2011 Share Posted December 18, 2011 That doesn't make any sense, getResources() returns a table, not a boolean. 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