Jump to content

Help with tables


nimrod

Recommended Posts

Hi i would like some help about table using. What i'm trying to do is to block the entry to a certain car model depending on the level needed to enter that specific model.(i use the level sys by castillo)

My script:

local cars = { 
[411] = 20, 
} 
function test (player,seat,jacked) 
local level = exports.exp_sys:getPlayerLevel ( player ) 
local model = getElementModel(source) 
if ( cars[getElementModel(source)] < level  ) then 
cancelEvent() 
outputChatBox ("[CORE] *You have to be at least level "..unpack(autos[getElementModel(source)]), player, 255, 100, 100, false) 
else 
outputChatBox ("[CORE] *Authorized Vehicle", player, 255, 100, 100, false) 
end 
end 
addEventHandler ( "onVehicleStartEnter", root, test ) 

Link to comment
outputChatBox ("[CORE] *You have to be at least level "..unpack(autos[getElementModel(source)]), player, 255, 100, 100, false) 

You are using "autos" table name, but your table name is "cars", change that line into:

outputChatBox ( "[CORE] *You have to be at least level ".. tostring ( cars [ model ] ), player, 255, 100, 100, false ) 

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