Jump to content

Creating an array


Ride1234

Recommended Posts

I have a variable, its value gets from gui menu, and assigns to all players on the server, but I want that each player have his own value of this variable. Tell me please how to create a simple array in Lua, how to assign a varible to it, and how to use it in 'if...then' constructions.

p.s. sorry for bad english.

Link to comment

karlis, thank you.

I have a code:

local sVar1 = { }
local sVar2 = { }
local sVar3 = { }
...
sVar1[source] = 1
sVar2[source] = 2
sVar3[source] = 3
...
function MyFunc( source, sVar1[source], sVar2[source] , sVar3[source] )
...
end

But, when I try to compile it, i get:

mymode.lua:62: ')' expected near '['

62 line in mode, and 9 line here(function MyFunc)

What is wrong? How to create a function with array in argument?

Link to comment
i think soruce is not registered there, use this, but anyway i didnt test it

did u make source before making

svar[source]=... ?

function MyFunc( source, var1, var2 , var3 )
 sVar1[source],sVar2[source],sVar3[source]=var1,var2,var3
 ...

Thank you, I solve it by the same way...:)

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