Jump to content

[HELP] Tables


Recommended Posts

Hello,

I'm not experienced with tables I know a bit of them but they are really usefull,

i'm trying something but I don't know if this is correct.

Now I made my showroom vehicles like this;

function showroomAlpha () 
    alphaShowroom = createVehicle ( 602, -1946.2780761719, 272.6872253418, 35.063152313232, 0, 0, 90 ) 
    setVehicleLocked ( alphaShowroom, false ) 
    setVehicleDamageProof( alphaShowroom, true ) 
    setVehicleEngineState ( alphaShowroom, false ) 
    setVehicleFuelTankExplodable ( alphaShowroom, false ) 
    setVehicleColor ( alphaShowroom, 255, 255, 255 ) 
    setVehiclePlateText ( alphaShowroom, "Alpha" ) 
    setElementFrozen ( alphaShowroom, true ) 
    showRoomVehicles[alphaShowroom]=true 
end 
  
function showroomBanshee () 
    bansheeShowroom = createVehicle ( 429, -1946.2780761719, 268.6872253418, 35.063152313232, 0, 0, 90 ) 
    setVehicleLocked ( bansheeShowroom, false ) 
    setVehicleDamageProof( bansheeShowroom, true ) 
    setVehicleEngineState ( bansheeShowroom, false ) 
    setVehicleFuelTankExplodable ( bansheeShowroom, false ) 
    setVehicleColor ( bansheeShowroom, 255, 255, 255 ) 
    setVehiclePlateText ( bansheeShowroom, "Banshee" ) 
    setElementFrozen ( bansheeShowroom, true ) 
    showRoomVehicles[bansheeShowroom]=true 
end 

But can I do something like this;

showroomVehicles = { 
{model1, x1, y1, z1, rx1, ry1, rz1}, -- This is filled in with the information of the alphaShowroom 
{model2, x2, y2, z2, rx2, ry2, rz2}, -- This with the info from the banshee 
} 
  
function showroomVehicles () 
    showroomVehicles = createVehicle ( model, x, y, z, rx, ry, rz ) 
    setVehicleLocked ( showroomVehicles , false ) 
    setVehicleDamageProof( showroomVehicles , true ) 
    setVehicleEngineState ( showroomVehicles , false ) 
    setVehicleFuelTankExplodable ( showroomVehicles , false ) 
    setVehicleColor ( showroomVehicles , 255, 255, 255 ) 
    setVehiclePlateText ( showroomVehicles , "Banshee" ) 
    setElementFrozen ( showroomVehicles , true ) 
    showRoomVehicles[showroomVehicles ]=true 
end 

Link to comment
local Vehicles = {} 
local showroomVehicles = { 
    {602, -1946.3, 272.7, 35, 0, 0, 90}, -- This is filled in with the information of the alphaShowroom 
    {429, -1946.3, 268.7, 35, 0, 0, 90} -- This with the info from the banshee 
} 
  
function () 
    local sv = showroomVehicles 
    for i=1,#sv do 
        vehicles[i] = createVehicle(sv[i][1], sv[i][2], sv[i][3], sv[i][4], sv[i][5], sv[i][6], sv[i][7]) 
        setVehicleLocked ( vehicles[i], false ) 
        setVehicleDamageProof( vehicles[i], true ) 
        setVehicleEngineState ( vehicles[i], false ) 
        setVehicleFuelTankExplodable ( vehicles[i], false ) 
        setVehicleColor ( vehicles[i], 255, 255, 255 ) 
        setVehiclePlateText ( vehicles[i], getVehicleName(vehicles[i]) ) 
        setElementFrozen ( vehicles[i], true ) 
    end 
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...