ksTakor Posted April 8, 2015 Share Posted April 8, 2015 Hi, i am trying to learn tables but so far no success kk I wish to learn then I tried to pass this id's and the check if is one of then but i had no success if not getElementModel(veh) == 417 or getElementModel(veh) == 593 or getElementModel(veh) == 493 or getElementModel(veh) == 509 or getElementModel(veh) == 487 or getElementModel(veh) == 497 then Thanks in advanced and sorry for the english Link to comment
MTA Team botder Posted April 8, 2015 MTA Team Share Posted April 8, 2015 function containsNumber(what, ...) for index, value in pairs({...}) do if value == what then return true end end return false end if containsNumber(getElementModel(veh), 417, 593, 493, 509, 487, 497) then -- do something end Link to comment
ksTakor Posted April 8, 2015 Author Share Posted April 8, 2015 thanks Necktrox wow, this table is different from what i have seen, I only see tables more like that local VehiclesID = { {417}, {593}, {493}, {509}, {487}, {497} } how can i check for the id's in this type of table? I wish to learn this way too Link to comment
MTA Team botder Posted April 8, 2015 MTA Team Share Posted April 8, 2015 I showed you the (probably) easiest way. local models = { [417] = true, [593] = true, [493] = true, [509] = true, [487] = true, [497] = true } if models[getElementModel(veh)] then -- do something end local models = { 417, 593, 493, 509, 487, 497 } local vehmodel = getElementModel(veh) for index, model in pairs(models) do if vehmodel == model then -- do something break end end function hasModel(vehmodel) for index, model in pairs(models) do if vehmodel == model then return true end end return false end if hasModel(getElementModel(veh)) then -- do something end Link to comment
ksTakor Posted April 8, 2015 Author Share Posted April 8, 2015 Thanks man, that will help a lot Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now