Jump to content

How to check a vehicle's ID against a table.


Recommended Posts

I am (heavily) editing a pay'n'spray script, and want to check that a car is not of a certain model. I was hoping I could check it against a table, but I can't seem to come up with the proper syntax. Any help would be appreciated.

Here is the code I need help with:

  
--the table 
local notAllowed = {509, 481, 510, 485, 574, 420, 552, 416, 433, 490, 528, 407, 544, 523, 470, 598, 596, 597, 599, 432, 601, 428, 532, 578, 486, 406] 
  
--then, after the source is for sure a car with a ped in it, check it with: 
if (getElementModel(hitElement) ~= --what goes here? lol 
--if it is, continue. if not, output a message to the chatbox. 
  

Link to comment
if notAllowed[getElementModel(hitElement)] then 
    outputChatBox ( "That vehicle is not allowed!" ) 
end 

That should it be.

nope, because right now id's are values, not keys, like notAllowed[1] = 509.

  
local notAllowed = { [509] = true, [481] = true } -- etc 
  
if notAllowed[getElementModel(hitElement)] then 
    outputChatBox ( "That vehicle is not allowed!" ) 
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...