Jump to content

Auto Spam


Recommended Posts

Hello

 

i want to create Objects
But in an organized way

maybe

 

Creation = 10
X Change = 5
Y Change = 6

when Creation = 10

then Automatically Create 10 Objects
When Create 10 Objects

The difference between each Object 1 and Object 2  = ' 5 x '

And in Y ' 6 y '

 

 

Thanks !
 

Link to post
  • Moderators

Something like:

local creation  = 10
local x_change  = 5
local y_change  = 6

local object_id = 955
local start_x, start_y, start_z = 0, 0, 3

for i = 1, creation do
    createObject(object_id, start_x + i*x_change, start_y + i*y_change, start_z)
end

 

Link to post
9 minutes ago, Patrick said:

Something like:


local creation  = 10
local x_change  = 5
local y_change  = 6

local object_id = 955
local start_x, start_y, start_z = 0, 0, 3

for i = 1, creation do
    createObject(object_id, start_x + i*x_change, start_y + i*y_change, start_z)
end

 

thx its work good

can i make name for it ?
maybe object and it number

Link to post
  • Moderators
5 hours ago, Monument said:

thx its work good

can i make name for it ?
maybe object and it number

I don't understand.

Link to post
9 hours ago, Patrick said:

I don't understand.

the script make 10 object right ?

for example i want getElementPosition

to object number 2
but i can't because the element without name

i try to do that

Object[i] = createObject(..................)
-- i = number from 1 to 10 In the example above
getElementPosition(Object[2])

 

Link to post
  • Moderators
5 hours ago, Monument said:

the script make 10 object right ?

for example i want getElementPosition

to object number 2
but i can't because the element without name

i try to do that




Object[i] = createObject(..................)
-- i = number from 1 to 10 In the example above
getElementPosition(Object[2])

 

local creation  = 10
local x_change  = 5
local y_change  = 6

local object_id = 955
local start_x, start_y, start_z = 0, 0, 3

local objects   = {}

for i = 1, creation do
    objects[i] = createObject(object_id, start_x + i*x_change, start_y + i*y_change, start_z)
end

function getPositionOf(index)
    return (index and objects[index]) and getElementPosition(objects[index]) or false
end

local x, y, z = getPositionOf(2)
iprint(x, y, z)

 

Here are some excellent resources to learn the basics of Lua scripting:

- https://wiki.multitheftauto.com/wiki/Main_Page
- https://wiki.multitheftauto.com/wiki/Scripting_Introduction
- https://www.lua.org/manual/5.1/
- https://wiki.multitheftauto.com/wiki/Category:Tutorials
- https://forum.mtasa.com/topic/34453-manuals

- https://forum.mtasa.com/topic/64228-the-ultimate-lua-tutorial/
- https://forum.mtasa.com/topic/121619-lua-for-absolute-beginners
- https://forum.mtasa.com/topic/95654-tut-debugging/
- https://forum.mtasa.com/topic/114541-tut-events/
- https://forum.mtasa.com/topic/117472-tut-scaling-dx/

Videos: https://www.youtube.com/watch?v=Goqj5knKLQM&list=PLY2OlbN3OoCgTGO7kzQfIKPj4tJbYOgSR

Link to post

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