Jump to content

Table locations


Msypon

Recommended Posts

locations = { 
[1]= { startX=529, startY=-1884, startZ=3 , endX=612, endY=-1884, endZ=3 }, --ls 
[2]= { startX=-2920, startY=68, startZ=1,endX=-2913, endY=159, endZ=3 } --sf 
} 
  
  
function createRandomObject(tableNumber) 
local startX,startY,startZ = locations[tableNumber].startX,locations[tableNumber].startY,locations[tableNumber].startZ 
local endX,endY,endZ = locations[tableNumber].endX,locations[tableNumber].endY,locations[tableNumber].endZ 
  
local realX, realY, realZ = math.random(startX,endX),math.random(startY,endY),math.random(startZ,endZ) 
  
createObject ( 980, realX, realY, realZ ) 
  
end 

Something like that ;p

Link to comment

Hi there , i'v fixed it so now it gonna create 2 object randomly from #locations once the resource starts.

replace ID in line 12 & 13 with the object model id , you can find it in map editor.

i believe this code is easier than denny's.

Good Luck :)

locations = { 
{ 529, -1884, 3 }, 
{ 612, -1884, 3 }, 
{ -2920, 68, 1 }, 
{ -2913, 159, 3 }, 
} 
  
  
function startDaTable () 
        random = math.random(#locations) 
        x, y, z = locations[random][1], pickupT[random][2], pickupT[random][3] 
        createObject ( ID, x, y, z) 
        createObject ( ID, x, y, z) 
end 
addEventHandler ("onResourceStart", root, startDaTable) 
  

Link to comment
  • Moderators

@Part,

Easier, doesn't mean it is better.

Btw you are creating objects randomly every time a resource starts, it doesn't even matter which one.

"Oh let we start(restart) admin then we got event more random objects!"

To be honest I don't know exactly how he wants it,

Link to comment
  • Moderators
local locations = { 
    { -- ls_beach 
        { x=529, y=-1884, z=3 }, 
        { x=612, y=-1884, z=3 } 
    }, 
    { -- sf_beach 
        { x=-2920, y=68, z=1 }, 
        { x=-2913, y=159, z=3 } 
    } 
} 
  
  
  
addEventHandler("onResourceStart", resourceRoot, 
function () 
    setTimer(function() 
        local randomResult = locations[math.random(1,#locations)] 
        for i=1,#randomResult do 
            local locationInfo = randomResult[i] 
            createObject ( 1337, locationInfo.x, locationInfo.y, locationInfo.z) 
        end 
    end,60000,1) 
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...