diabeloo Posted September 30, 2013 Share Posted September 30, 2013 Hey its me again , i have a problem on a multigamemode script . the problem is simple 2 rooms work on that mgm and always when i join on other 3 rooms in debugscript 3 there is a error : " ...\client.lua:298: bad argument #1 to 'ipairs' (table expected ,got nil ) " and here is the part of script ( the error is on 17. line ) : addEvent("onServerSendMapTable",true) addEventHandler("onServerSendMapTable",root, function(map,rt,w,res,files,size,pos) if map == false then waiting = true; return; else waiting = false; end realtime = rt weather = w triggerServerEvent("onClientWantsKTime",g_Me) local timer = 50 if g_Map and (#g_Map >= 1) then unloadMap() end for k,v in ipairs(map) do local element = v[1] local ne = false if element == "object" then ne = createObject(v[2],v[3],v[4],v[5],v[6],v[7],v[8]) setElementInterior(ne,v[9]) setElementAlpha(ne,v[11]) setObjectScale(ne,v[12]) if v[10] == "false" then setElementCollisionsEnabled(ne,false) end elseif element == "marker" then ne = createMarker(v[2],v[3],v[4],v[5],v[6],v[7]) if v[8] then setElementInterior(ne,v[8]) end local r,g,b = hex2rgb(v[7]:sub(1,7)) setMarkerColor(ne,r,g,b,240) setElementID(ne,v[9]) elseif element == "racepickup" then ne = createObject(g_ModelForPickupType[v[2] ], v[4], v[5], v[6],v[7],v[8],v[9]) local ob = createColSphere(v[4],v[5],v[6], 3.5) setElementData(ob,"type",v[2]) setElementData(ob,"veh",v[3]) g_Pickups[#g_Pickups+1] = ob g_Pickups2[#g_Pickups2+1] = ne elseif element == "vehicle" then ne = createVehicle(v[2],v[3],v[4],v[5],v[6],v[7],v[8]) setElementFrozen(ne,true) setElementCollisionsEnabled(ne,false); elseif element == "script" then exports["vip_load"]:downloadfiles(files,res,size) exports["vip_load"]:loadScript(v[2],res,getElementData(g_Me,"Map")) elseif element == "spawnpoint" then g_Spawns[#g_Spawns+1] = {v[2],v[3],v[4],v[5],v[6],v[7],v[8]} end if ne ~= false then g_Map[#g_Map+1] = ne end end local room = getElementData(g_Me,"room"); if room == 1 or room == 4 or room == 5 or room == 6 then for k,v in ipairs(getElementsByType("player")) do local room2 = getElementData(v,"room"); local veh = getPedOccupiedVehicle(v); if (room2 == room) and veh then if room == 4 or room == 5 or room == 6 then if getElementData(v,"State") == "Alive" then setCameraTarget(v); break; end else setCameraTarget(v); break; end end end end can someone help me to fix that error ? Link to comment
Discord Moderators Zango Posted September 30, 2013 Discord Moderators Share Posted September 30, 2013 From the snippet you posted, I can't tell you why your table "map" is nil. In the beginning of your function, you check to see whether "map" is 'false'. 'false' and 'nil' are different. Depending on your code (context this is used in), you could simply extend the check: function(map,rt,w,res,files,size,pos) if (not map) then waiting = true; return; else Link to comment
diabeloo Posted September 30, 2013 Author Share Posted September 30, 2013 so what part would u need to see to tell why its nil? Link to comment
BieHDC Posted October 1, 2013 Share Posted October 1, 2013 best would be the full script Link to comment
Moderators IIYAMA Posted October 1, 2013 Moderators Share Posted October 1, 2013 simply the one that sends the map. 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