Et-win Posted June 2, 2014 Share Posted June 2, 2014 Hello, As you look to the title you know my question. Client: function requestServerMaps() triggerServerEvent("clientrequestservermaps", getLocalPlayer()) end addCommandHandler("testen", requestServerMaps) function nowdooutput(themaps) for l, k in ipairs(themaps) do outputChatBox(tostring(k)) end outputChatBox(tostring(themaps)) outputChatBox(tostring(themaps[1])) end addEvent("sendbackservermaps", true) addEventHandler("sendbackservermaps", getRootElement(), nowdooutput) Server: function getservermapsnow() themaps = exports.mapmanager:getMapsCompatibleWithGamemode(getResourceFromName("race")) for l, k in ipairs(themaps) do outputChatBox(tostring(k)) end triggerClientEvent(source, "sendbackservermaps", getRootElement(), themaps) end addEvent("clientrequestservermaps", true) addEventHandler("clientrequestservermaps", getRootElement(), getservermapsnow) (Script fastly made for testing, so sorry if it's a bit messy ) If I output it with "ipairs" in serverside, it does return every map that is on the server. If I do the same on clientside, the table is suddently empty. It DOES return the table, but still, it's empty. My question now is: How it can be empty? I remade a simple function (This one here above) to check or it was my first function's fault, but nope, my official function and this function both do the same. PS: I did try to trigger "lol = {"Hai", "Naab"}" towards client, this was successful. Link to comment
Moderators IIYAMA Posted June 3, 2014 Moderators Share Posted June 3, 2014 Probably because the resource element can't be send of to clients. You should only send the names. function getservermapsnow() local raceResource = getResourceFromName("race") if raceResource then local themaps = exports.mapmanager:getMapsCompatibleWithGamemode(raceResource) if themaps then local mapNames = {} for i=1,#themaps do local name = getResourceName(themaps[i]) if name then mapNames[#mapNames+1]= name end end if #mapNames > 0 then triggerClientEvent(source, "sendbackservermaps", root, mapNames) end end end end addEvent("clientrequestservermaps", true) addEventHandler("clientrequestservermaps", root, getservermapsnow) Link to comment
Et-win Posted June 3, 2014 Author Share Posted June 3, 2014 Probably because the resource element can't be send of to clients.You should only send the names. [stuff] Hello and thank you for the reply. Indeed this was the solution. I just totally forgot to only trigger the names, normally I did this before, but now I just forgot it. 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