Desaster Posted November 9, 2013 Posted November 9, 2013 (edited) how to create blips and to remove them with the same function Edited November 12, 2013 by Guest
Castillo Posted November 9, 2013 Posted November 9, 2013 Check if the blip exists, if so, remove it, else, create it.
Desaster Posted November 9, 2013 Author Posted November 9, 2013 (edited) I did so but the problem was I think bad element pointer idk why function showblips() for ID in pairs(bankMarkers) do if not (blip) then x, y, z = bankMarkers[ID][1], bankMarkers[ID][2], bankMarkers[ID][3] blip = createBlip ( x, y, z, 52, 2, 255, 0, 0, 255, 0, 200 ) else destroyElement(ID) end end end addCommandHandler("showatm", showblips) Edited November 10, 2013 by Guest
tosfera Posted November 9, 2013 Posted November 9, 2013 Try this; local blips = {}; addCommandHandler ( "showatm", function () for index, blip in ipairs ( bankMarkers ) do if not ( #blips > 0 ) then table.insert ( blips, { blipid, bankMarkers[1], bankMarkers[2], bankMarkers[3] }; else destroyElement ( blips ); end end for i, b in ipairs ( blips ) do createBlip ( b[1], b[2], b[3], b[4] ); end end );
tosfera Posted November 10, 2013 Posted November 10, 2013 You want them when the resource starts or with a command, or when an event get triggered?
Desaster Posted November 10, 2013 Author Posted November 10, 2013 I want them just with the same command put them or remove them depents on their stat example of my table : local bankMarkers = { {562.79998779297, -1254.5999755859, 16.89999961853, 284}, {1001.700012207, -929.40002441406, 41.799999237061, 278.74658203125}, }
xXMADEXx Posted November 10, 2013 Posted November 10, 2013 Well, this is kind of a weird way of doing it but im sure it would work. [[NOT TESTED]] local bankMarkers = { {562.79998779297, -1254.5999755859, 16.89999961853, 284, false}, {1001.700012207, -929.40002441406, 41.799999237061, 278.74658203125, false} } local blips = { } function executeCheck ( ) for i, v in ipairs ( bankMarkers ) do local str = table.concat ( { v[1], v[2], v[3], v[4] }, "," ) if ( v[5] ) then bankMarkers[i][5] = false if ( isElement ( blips[str] ) ) then destroyElement ( blips[str] ) end else bankMarkers[i][5] = true if ( not isElement ( blips[str] ) ) then blip[str] = createBlip ( v[1], v[2], v[3] ) end end end end
Desaster Posted November 11, 2013 Author Posted November 11, 2013 your one xXMADEXx create 1 blips every time i type /showatm and another one if I re-type it I want just with /showatm to crate all blips and to remove them after
Sasu Posted November 12, 2013 Posted November 12, 2013 Try this: local bankMarkers = { {562.79998779297, -1254.5999755859, 16.89999961853, 284, false}, {1001.700012207, -929.40002441406, 41.799999237061, 278.74658203125, false} } local blips = { } local isViewingBlip = {} function executeCheck ( source ) if isViewingBlip[source] then for i,v in ipairs(blips[source]) do if isElement(v) then destroyElement(v) end end blips[source] = {} isViewingBlip[source] = false else if not blips[source] then blips[source] = {} end for i,v in ipairs(bankMarkers) do local id,x,y,z = unpack(v) local b = createBlip(id, x, y, z) table.insert(blips[source], b) end isViewingBlip[source] = true end end addCommandHandler("showatm", executeCheck)
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