Zcraks Posted May 16, 2019 Share Posted May 16, 2019 Hi, sry for my Eng lng. I have one problem in my script. I want the marker to be created sequentially, but not random. local tbl = { {1954, -1241.29, 20.3828}, {1898.87, -1205.36, 20.3984}, {1892.98, -1159.29, 25.3828}, {1988.98, -1162.29, 21.3828}, {2041.87, -1208.36, 25.3984}, {2038.98, -1240.29, 25.3828}, } local bsNumber = {} function creteMarker (ID) --rnd = math.random(1,#tbl) ID = 1 marker = createMarker(tbl[ID][1], tbl[ID][2],tbl[ID][3],"checkpoint",3,0,255,0,180) blip = createBlipAttachedTo( marker, 0, 2, 255, 255, 0, 255 ) end addEvent("super", true) addEventHandler ( "super", root, creteMarker) function testJob(e) if isElement(e) then destroyElement(source) destroyElement(blip ) creteMarker () givePlayerMoney(e, 5) end end addEventHandler("onMarkerHit",root,testJob) Link to comment
Scripting Moderators ds1-e Posted May 16, 2019 Scripting Moderators Share Posted May 16, 2019 9 minutes ago, Zcraks said: Hi, sry for my Eng lng. I have one problem in my script. I want the marker to be created sequentially, but not random. local tbl = { {1954, -1241.29, 20.3828}, {1898.87, -1205.36, 20.3984}, {1892.98, -1159.29, 25.3828}, {1988.98, -1162.29, 21.3828}, {2041.87, -1208.36, 25.3984}, {2038.98, -1240.29, 25.3828}, } local bsNumber = {} function creteMarker (ID) --rnd = math.random(1,#tbl) ID = 1 marker = createMarker(tbl[ID][1], tbl[ID][2],tbl[ID][3],"checkpoint",3,0,255,0,180) blip = createBlipAttachedTo( marker, 0, 2, 255, 255, 0, 255 ) end addEvent("super", true) addEventHandler ( "super", root, creteMarker) function testJob(e) if isElement(e) then destroyElement(source) destroyElement(blip ) creteMarker () givePlayerMoney(e, 5) end end addEventHandler("onMarkerHit",root,testJob) Use int loop. for i = 1, #tbl do local x, y, z = tbl[i][1], tbl[i][2], tbl[i][3] local marker = createMarker(x, y, z, "checkpoint", 3, 0, 255, 0, 180) -- and add missing code end 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