Apo Posted December 8, 2016 Share Posted December 8, 2016 hi guys my problem all radar and all closhap when I am writing the command /show i need only delete the hillarea and hillRadar for when turfcol = true hillArea = { {1436.6826171875, -2940.1494140625, 13.546875, 500,500,500}, {1436.6826171875, -2640.1494140625, 13.546875, 500,500,500}, {1436.6826171875, -2340.1494140625, 13.546875, 500,500,500}, {1436.6826171875, -640.1494140625, 13.546875, 500,500,500} } hillRadar = { {1262.2802734375, -2769.48828125, 300, 300, 171, 175, 174, 80}, {1262.2802734375, -2469.48828125, 300, 300, 92, 46, 2, 80}, {2762.2802734375, -2169.48828125, 200, 300, 255, 0, 143, 80} } turfCol = nil hillRadars = nil function maketurf (thePlayer) if turfcol == nil and hillRadars == nil then for i,v2 in ipairs(hillArea) do turfCol = createColCuboid(unpack(v2)) end for i,v1 in ipairs(hillRadar) do hill = createRadarArea(unpack(v1)) end turfCol = true hillRadars = true else local allturfs = getElementsByType("radararea") local allcols = getElementsByType("colshape") for i, v2 in ipairs(allturfs) do destroyElement(v2) end for i, v1 in ipairs(allcols) do destroyElement(v1) end turfCol = nil hillRadars = nil end end addCommandHandler("show", maketurf) Link to comment
LoPollo Posted December 8, 2016 Share Posted December 8, 2016 (edited) 10 hours old... no replies. So i ask: can you explain better? i did not understand what's the problem. Also indent the code to make it more readable: it's annoying reading an end followed by a instruction that is more at right, like if it was an if or a loop Spoiler hillArea = { {1436.6826171875, -2940.1494140625, 13.546875, 500,500,500}, {1436.6826171875, -2640.1494140625, 13.546875, 500,500,500}, {1436.6826171875, -2340.1494140625, 13.546875, 500,500,500}, {1436.6826171875, -640.1494140625, 13.546875, 500,500,500} } hillRadar = { {1262.2802734375, -2769.48828125, 300, 300, 171, 175, 174, 80}, {1262.2802734375, -2469.48828125, 300, 300, 92, 46, 2, 80}, {2762.2802734375, -2169.48828125, 200, 300, 255, 0, 143, 80} } turfCol = nil hillRadars = nil function maketurf (thePlayer) if turfcol == nil and hillRadars == nil then for i,v2 in ipairs(hillArea) do turfCol = createColCuboid(unpack(v2)) end for i,v1 in ipairs(hillRadar) do hill = createRadarArea(unpack(v1)) end turfCol = true hillRadars = true else local allturfs = getElementsByType("radararea") local allcols = getElementsByType("colshape") for i, v2 in ipairs(allturfs) do destroyElement(v2) end for i, v1 in ipairs(allcols) do destroyElement(v1) end turfCol = nil hillRadars = nil end end addCommandHandler("show", maketurf) Edited December 8, 2016 by LoPollo Link to comment
MR.S3D Posted December 9, 2016 Share Posted December 9, 2016 hillArea = { {1436.6826171875, -2940.1494140625, 13.546875, 500,500,500}, {1436.6826171875, -2640.1494140625, 13.546875, 500,500,500}, {1436.6826171875, -2340.1494140625, 13.546875, 500,500,500}, {1436.6826171875, -640.1494140625, 13.546875, 500,500,500} } hillRadar = { {1262.2802734375, -2769.48828125, 300, 300, 171, 175, 174, 80}, {1262.2802734375, -2469.48828125, 300, 300, 92, 46, 2, 80}, {2762.2802734375, -2169.48828125, 200, 300, 255, 0, 143, 80} } local turfcol_ = nil function maketurf (thePlayer) if turfcol_ == nil then --- create local turfCol for i,v2 in ipairs(hillArea) do turfCol = createColCuboid(unpack(v2)) end local hill for i,v1 in ipairs(hillRadar) do hill = createRadarArea(unpack(v1)) end turfcol_ = true else --- destroy local allturfs = getElementsByType("radararea") local allcols = getElementsByType("colshape") for i, v2 in ipairs(allturfs) do destroyElement(v2) end for i, v1 in ipairs(allcols) do destroyElement(v1) end turfcol_ = nil end end addCommandHandler("show", maketurf) Link to comment
LoPollo Posted December 9, 2016 Share Posted December 9, 2016 Still you don't expalin what the problem is. Also the declarement and assignment of turfCol and hill is useless. And with the following instruction you retrieve ALL the radarareas/colshapes, not only what you created with this script. local allturfs = getElementsByType("radararea") local allcols = getElementsByType("colshape") Explain more what your problem is Link to comment
MR.S3D Posted December 9, 2016 Share Posted December 9, 2016 (edited) when you use turfCol and create new with turfCol and fist one was nil example for your problem: s3d = nil -- variable s3d = 'hello' -- variable s3d = 'hi' -- variable outputChatBox(s3d) -- in chat : hi -- because the last one variable cancel all variables with same name... You must use tables.. and if you need destroyElement in your this resource only use: local allturfs = getElementsByType("radararea",resourceRoot) local allcols = getElementsByType("colshape",resourceRoot) Edited December 9, 2016 by MR.S3D 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