h1ama3d Posted March 10, 2011 Share Posted March 10, 2011 Hello .. I want help please .. I found this code .. In Wikipedia .. function addHelmetOnEnter ( thePlayer, seat, jacked ) if ( getElementModel ( source ) == 522 ) then -- if its a nrg addPedClothes ( thePlayer, "moto", "moto", 16 ) -- add the helmet end end addEventHandler ( "onVehicleEnter", getRootElement(), addHelmetOnEnter ) function removeHelmetOnExit ( thePlayer, seat, jacked ) if ( getElementModel ( source ) == 522 ) then -- if its a nrg removePedClothes ( thePlayer, 16 ) -- remove the helmet end end addEventHandler ( "onVehicleExit", getRootElement(), removeHelmetOnExit ) But I want add a variable .. To be code on all bikes But it did not work .. This is the code : bikes = { "522" , "481" , "581" , "462" , "521" , "463" , "523" , "461" , "448" , "468" , "586" , "471" , "509" , "510" } function addHelmetOnEnter ( thePlayer, seat, jacked ) if ( getElementModel ( source ) == bikes ) then -- if its a Bike addPedClothes ( thePlayer, "moto", "moto", 16 ) -- add the helmet end end addEventHandler ( "onVehicleEnter", getRootElement(), addHelmetOnEnter ) function removeHelmetOnExit ( thePlayer, seat, jacked ) if ( getElementModel ( source ) == bikes ) then -- if its a Bike removePedClothes ( thePlayer, 16 ) -- remove the helmet end end addEventHandler ( "onVehicleExit", getRootElement(), removeHelmetOnExit ) Sorry I am a noob >< Please I want help .. Link to comment
InDev Posted March 10, 2011 Share Posted March 10, 2011 Well, when you have this code you can do something like this with your table: bikes = { "522" , "481" , "581" , "462" , "521" , "463" , "523" , "461" , "448" , "468" , "586" , "471" , "509" , "510" } function isABike( modelID ) for k,i in ipairs( bikes )do -- go through the table if( tonumber( modelID ) == tonumber( i ) )then -- if the modelID is equal to the table value return true end end return false end function addHelmetOnEnter ( thePlayer, seat, jacked ) if ( isABike( getElementModel ( source ) ) ) then -- if its a bike addPedClothes ( thePlayer, "moto", "moto", 16 ) -- add the helmet end end addEventHandler ( "onVehicleEnter", getRootElement(), addHelmetOnEnter ) function removeHelmetOnExit ( thePlayer, seat, jacked ) if ( isABike( getElementModel ( source ) ) ) then -- if its a bike removePedClothes ( thePlayer, 16 ) -- remove the helmet end end addEventHandler ( "onVehicleExit", getRootElement(), removeHelmetOnExit ) Link to comment
h1ama3d Posted March 10, 2011 Author Share Posted March 10, 2011 Oh .. that is working .. thank you famas .. 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