AGENT_STEELMEAT Posted February 26, 2011 Share Posted February 26, 2011 I want to read all the info from a table, and create the zones accordingly to allow for multiple zones. So far, it seems as if it is all being read, but nothing is happening. No errors, but no zones. Any ideas? --{x, y, width, height, red, green, blue, alpha, name, id} local zones = { {1684, -2008, 200, 200, 0, 255, 0, 0, "LSspawn", 1}, {0, 0, 200, 200, 0, 255, 0, 0, "test", 2} } function buildSafeZones() for theKey, theZone in ipairs(zones) do local x = zones[1] local y = zones[2] local width = zones[3] local height = zones[4] local red = zones[5] local green = zones[6] local blue = zones[7] local alpha = zones[8] local name = zones[9] local id = zones[10] colShape[id] = createColRectangle ( x, y, width, height ) radarArea[id] = createRadarArea (x, y, width, height, red, green, blue, alpha) setElementData(colShape[id],"type","safezone") setElementData(radarArea[id],"type","safezone") end end function cancelVehicleDamage() cancelEvent() end function greenzoneEnter ( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then if getElementData(source,"type") == "safezone" then --hidden to prevent piracy end end end addEventHandler ( "onColShapeHit", getRootElement(), greenzoneEnter ) function greenzoneExit ( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then if getElementData(source,"type") == "safezone" then --hidden to prevent piracy end end end addEventHandler ( "onColShapeLeave", getRootElement(), greenzoneExit ) Link to comment
TheGhost Posted February 26, 2011 Share Posted February 26, 2011 Do you have onResourceStart handled? Link to comment
Moderators Citizen Posted February 26, 2011 Moderators Share Posted February 26, 2011 I want to read all the info from a table, and create the zones accordingly to allow for multiple zones. So far, it seems as if it is all being read, but nothing is happening. No errors, but no zones. Any ideas? --{x, y, width, height, red, green, blue, alpha, name, id} local zones = { {1684, -2008, 200, 200, 0, 255, 0, 0, "LSspawn", 1}, {0, 0, 200, 200, 0, 255, 0, 0, "test", 2} } function buildSafeZones() for theKey, theZone in ipairs(zones) do local x = zones[1] local y = zones[2] local width = zones[3] local height = zones[4] local red = zones[5] local green = zones[6] local blue = zones[7] local alpha = zones[8] local name = zones[9] local id = zones[10] colShape[id] = createColRectangle ( x, y, width, height ) radarArea[id] = createRadarArea (x, y, width, height, red, green, blue, alpha) setElementData(colShape[id],"type","safezone") setElementData(radarArea[id],"type","safezone") end end function cancelVehicleDamage() cancelEvent() end function greenzoneEnter ( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then if getElementData(source,"type") == "safezone" then --hidden to prevent piracy end end end addEventHandler ( "onColShapeHit", getRootElement(), greenzoneEnter ) function greenzoneExit ( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then if getElementData(source,"type") == "safezone" then --hidden to prevent piracy end end end addEventHandler ( "onColShapeLeave", getRootElement(), greenzoneExit ) Maybe try this: --{x, y, width, height, red, green, blue, alpha, name, id} local zones = { {1684, -2008, 200, 200, 0, 255, 0, 0, "LSspawn", 1}, {0, 0, 200, 200, 0, 255, 0, 0, "test", 2} } function buildSafeZones() for theKey, theZone in ipairs(zones) do local x = zones[theKey][1] local y = zones[theKey][2] local width = zones[theKey][3] local height = zones[theKey][4] local red = zones[theKey][5] local green = zones[theKey][6] local blue = zones[theKey][7] local alpha = zones[theKey][8] local name = zones[theKey][9] local id = zones[theKey][10] colShape[id] = createColRectangle ( x, y, width, height ) radarArea[id] = createRadarArea (x, y, width, height, red, green, blue, alpha) setElementData(colShape[id],"type","safezone") setElementData(radarArea[id],"type","safezone") end end function cancelVehicleDamage() cancelEvent() end function greenzoneEnter ( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then if getElementData(source,"type") == "safezone" then --hidden to prevent piracy end end end addEventHandler ( "onColShapeHit", getRootElement(), greenzoneEnter ) function greenzoneExit ( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then if getElementData(source,"type") == "safezone" then --hidden to prevent piracy end end end addEventHandler ( "onColShapeLeave", getRootElement(), greenzoneExit ) To read in a table named zones, you have to respect the syntax: zones[line][column] It should be work now 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