Jump to content

Problem with tables


Recommended Posts

Posted

Hello,

I be busy with my class selection system.

And i use tables/arrays for it, but it gives me every time an error:

local classes = { 
'police' = { 
  

There is everywhere i get the error of, it says that he misses a closing '}' char

The script:

http://paste.ubuntu.com/22093/

Alexander.

Why looking here, while my post is up there /\ :)

Posted

I think it's the way you're declaring the array indicies. Try it like this instead:

  
local classes = { 
    civilians       = { 
        title       = 'Street people', 
        team        = 'civilian', 
        message = 'Living people on the streets,\nThey do just normal!' 
    }, 
    ... 
  

You can then access like:

  
local p = classes["civilians"] 
  

OR

  
local p = classes.civilians 
  

Posted

I'd like to advise you to use XML. It's not too hard, and it's a LOT easier to change and customize later on.

Do NOT PM ME for help unless invited. - New MTA Script Editor

Scripting help "etiquette": understandable language, relevant code (ALL code if unsure), [Lua] tags, error messages with line numbers. Super simple stuff.

Posted

I'm going to have to disagree, i've recently written a script and it was a toss up between xml or lua tables, and it turns out that tables were by far the best to use. Once you realise the power of tables XML becomes as insignificant as Brophy's sexual advances.

2hplsom.png

Posted

Use XML if you wish the data to be persistent or editable by administrators, otherwise use tables.

Posted

in my way i prefer tables, i had created first this system with xml but it wasn't working.

And now, i've got the best system of the whole mta community :P

Why looking here, while my post is up there /\ :)

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