Wrench 2000 Posted June 3, 2017 Share Posted June 3, 2017 i got this warning, and error: "rC.lua:40: bad argument @ 'dxDrawImageSection' [Expected material at argument 9, got nil]" - This is the warning msg.. "sC.lua:6: attempt to index global 'WorldRadar' (a nil value)" - This is the error msg.... And code(s): rC.lua:40: - dxDrawImageSection(WorldRadar["monX"], WorldRadar["monY"], WorldRadar["width"], WorldRadar["height"], mapX + 50, mapY + 60, WorldRadar["width"]/zoom, WorldRadar["height"]/zoom, WorldRadar["Map"], 0, 0, 0, tocolor(255, 255, 255, 255)) --- and the sC:lua:6: - Map = {} Map["F11"] = false function Map.start() MiniMap.start() WorldRadar.start() end Map.start() function Map.draw() if Map["F11"] then return end MiniMap.draw() end addEventHandler("onClientRender", root, Map.draw) function Map.stop() end What wrong? How to fix this problems? Thanks the help! Link to comment
Moderators IIYAMA Posted June 3, 2017 Moderators Share Posted June 3, 2017 (edited) WorldRadar Doesn't contain a value. (which should contain a table) You can check if WorldRadar does have a positive value, by writing it like this: if WorldRadar then -- code that uses WorldRadar end This will stop the errors/warnings, but doesn't guarantee that the script will operate as pleased. So make sure that: WorldRadar does contain a valid value. Edited June 3, 2017 by IIYAMA Link to comment
Wrench 2000 Posted June 3, 2017 Author Share Posted June 3, 2017 6 minutes ago, IIYAMA said: WorldRadar Doesn't contain a value. (which should contain a table) You can check if WorldRadar does have a positive value, by writing it like this: if WorldRadar then -- code that uses WorldRadar end This will stop the errors/warnings, but doesn't guarantee that the script will operate as pleased. So make sure that: WorldRadar does exist. the WorldRadar exist in a another file WorldRadar = {} WorldRadar["width"] = sX - 20 WorldRadar["height"] = sY - 20 WorldRadar["monX"] = math.floor(sX/2 - WorldRadar["width"]/2) WorldRadar["monY"] = math.floor(sY/2 - WorldRadar["height"]/2) WorldRadar.show = false then why not working? Link to comment
Moderators IIYAMA Posted June 3, 2017 Moderators Share Posted June 3, 2017 (edited) Most likely it is because this file loads later than the file that is already using WorldRadar. In short: You can't use something which hasn't been loaded yet. To solve that problem, you can execute code after ALL the code has been loaded using the event: 'onClientResourceStart'. It is clientside right? (for serverside use onResourceStart) function Map.start() MiniMap.start() WorldRadar.start() end addEventHandler("onClientResourceStart", resourceRoot, function () Map.start() end) Edited June 3, 2017 by IIYAMA 1 Link to comment
Wrench 2000 Posted June 3, 2017 Author Share Posted June 3, 2017 4 minutes ago, IIYAMA said: Most likely it is because this file loads later than the file that is already using WorldRadar. In short: You can't use something which hasn't been loaded yet. To solve that problem, you can execute code after ALL the code has been loaded using the event: 'onClientResourceStart'. It is clientside right? (for serverside use onResourceStart) function Map.start() MiniMap.start() WorldRadar.start() end addEventHandler("onClientResourceStart", resourceRoot, function () Map.start() end) now i got this error: "attempt to index global 'Map' (a nil value)" dxDrawImageSection(WorldRadar["monX"], WorldRadar["monY"], WorldRadar["width"], WorldRadar["height"], mapX + 50, mapY + 60, WorldRadar["width"]/zoom, WorldRadar["height"]/zoom, WorldRadar["Map"], 0, 0, 0, tocolor(255, 255, 255, 255)) function WorldRadar.start() WorldRadar["Map"] = dxCreateTexture( "map.png") dxSetTextureEdge(WorldRadar["Map"], "border", tocolor(75,144,223)) end what wrong in this? Link to comment
Moderators IIYAMA Posted June 3, 2017 Moderators Share Posted June 3, 2017 I do not see the variable >Map< in this code. You sure this is the right code that contains this error? Link to comment
Wrench 2000 Posted June 3, 2017 Author Share Posted June 3, 2017 (edited) 11 minutes ago, IIYAMA said: I do not see the variable >Map< in this code. You sure this is the right code that contains this error? Lol, now working thank you!:D Edited June 3, 2017 by Wrench 2000 solved 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