Jump to content

table in work


Zcraks

Recommended Posts

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...