Jump to content

enum (Pawn) to LUA [RESOLVED]


Recommended Posts

Posted (edited)

Hi,

Sorry for my English (I use Google translation)

I am again MTA: DM, after a few tests, I still can not put an "array".

In fact, I coded PAWN and I adapt my script LUA. I will show you the table PAWN:

enum vInfo 
{ 
      id, 
      Float:pos_x, 
      Float:pos_y, 
      Float:pos_z, 
      Float:pos_za, 
      color1, 
      color2, 
}; 
new VehicleInfo[700][infoVeh]; 

I would like to adapt it to LUA.

Thank you in advance for your reply.

Edited by Guest
Posted

i'm searching Despo, if someone know it pls post here!

Posted

I guess you could do something like this

InfoVeh = { id, pos_x, pos_y, pos_z, pos_za, color1, color2 } 
VehicleInfo = {} 
for i=1,700 do -- from VehicleInfo[1] to VehicleInfo[700] 
    VehicleInfo[i] = InfoVeh 
end 

And later set the value like this:

VehicleInfo[13].id = 12 

Posted

Okay, thank's a lot Siyo ^^.

I'll try it now.

EDIT: I've got an error, but I don't found it:

line 4: VehInfo = {Model, Float:Pos_X, Float:Pos_Y, Float:Pos_Z, Float:Pos_ZA, Couleur1, Couleur2, Proprio, NomVehicule, Vendu} 
VehicleInfo = {} 

[01:22:42] SCRIPT ERROR: ...Bureau/Nouveau dossier (2)/mods/deathmatch/resourcecache/broph/broph.lua:4: function arguments expected near ','
Posted

You do not have to use "Float:", Lua uses variables and stores in them all types of data, so you don't have to tell script that this is going to be floating point number. Though, you need to tell the script that a var is a table, as you did in line 1 and 2.

http://www.lua.org/manual/5.1/

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