carvalhosgamer Posted May 22, 2014 Share Posted May 22, 2014 Hello, Guys , somebody can help me with addEventHandler when thePlayer get in the car ,the handler "onVehicleEnter" start , like this: function inCar(thePlayer) -- Action 1 outputChatBox("Mesage!!!") end addEventHandler("onVehicleEnter" , getRootElement() , inCar) ok, that's work, but i want to make a diferent action, when the thePlayer get in the same car again! thanks! Link to comment
carvalhosgamer Posted May 22, 2014 Author Share Posted May 22, 2014 I'm tryng put this conditional in this block carUsed = {} function inCar(thePlayer) if (carUsed[thePlayer]) then outputChatBox("Mesage!!!") carUsed[thePlayer] = false else outputChatBox("Mesage 222") end end addEventHandler("onVehicleEnter" , getRootElement() , inCar) When the player return to car , nothing happens, if I put the variable casUsed = false, block for everybody. not just to player somebody??? thanks Link to comment
justn Posted May 22, 2014 Share Posted May 22, 2014 (edited) Sorry if i have misread your code, don't understand you that much When the player enters the vehicle, you can check if the vehicle has a element data. and if it does not, then you can set the element data and outputChatBox, and if it does have the element data, then you can do whatever you want. Edited May 22, 2014 by Guest Link to comment
gghvcffcv Posted May 22, 2014 Share Posted May 22, 2014 function inCar(source) if isPedInVehicle (source) then outputChatBox("Mesage!!!") end end addEventHandler("onVehicleEnter" , getRootElement() , inCar) Try this! Link to comment
#RooTs Posted May 22, 2014 Share Posted May 22, 2014 is it? addEventHandler("onClientVehicleEnter", getRootElement(),function() outputChatBox("You enter in vehicle") end) addEventHandler("onClientVehicleExit", getRootElement(),function() outputChatBox("You exit in vehicle") end) Look https://community.multitheftauto.com/ind ... ls&id=9022 Link to comment
carvalhosgamer Posted May 22, 2014 Author Share Posted May 22, 2014 is it? addEventHandler("onClientVehicleEnter", getRootElement(),function() outputChatBox("You enter in vehicle") end) addEventHandler("onClientVehicleExit", getRootElement(),function() outputChatBox("You exit in vehicle") end) Look https://community.multitheftauto.com/ind ... ls&id=9022 No, the handler "onCVehicleExit" do other things, I want to do diferent thngs' in "onVehicleEnter" thanks for help Link to comment
carvalhosgamer Posted May 22, 2014 Author Share Posted May 22, 2014 Sorry if i have misread your code, don't understand you that muchWhen the player enters the vehicle, you can check if the vehicle has a element data. and if it does not, then you can set the element data and outputChatBox, and if it does have the element data, then you can do whatever you want. no problem, i'll try thanks Link to comment
#RooTs Posted May 22, 2014 Share Posted May 22, 2014 if it is not, I do not know what you want .. explain in detail, please Link to comment
manawydan Posted May 22, 2014 Share Posted May 22, 2014 so this? local carUsedCount = {} function inCar(thePlayer) if (carUsedCount[source]) then carUsedCount[source] = carUsedCount[source] +1 else carUsedCount[source] = 1 end if (carUsedCount[source] == 1) then outputChatBox("First time to enter in this vehicle",thePlayer) end if (carUsedCount[source] == 2) then outputChatBox("Second time to enter in this vehicle",thePlayer) end end addEventHandler("onVehicleEnter" ,root, inCar) Link to comment
carvalhosgamer Posted May 22, 2014 Author Share Posted May 22, 2014 if it is not, I do not know what you want ..explain in detail, please ok, thePlayer enters the vehicle for the first time and start the "onVehicleEnter" with message: "The Player Enters the Car" so, thePlayer out the vehicle and start "onVehicleExit" with message: "The Player is outr" ok, same thePlayer enters the vehicle again for second time, with message: "The Player enters the Car Again" you know, diferent messages "onVehicleEnter" Thanks Link to comment
#RooTs Posted May 22, 2014 Share Posted May 22, 2014 serves this? so this? local carUsedCount = {} function inCar(thePlayer) if (carUsedCount[source]) then carUsedCount[source] = carUsedCount[source] +1 else carUsedCount[source] = 1 end if (carUsedCount[source] == 1) then outputChatBox("First time to enter in this vehicle",thePlayer) end if (carUsedCount[source] == 2) then outputChatBox("Second time to enter in this vehicle",thePlayer) end end addEventHandler("onVehicleEnter" ,root, inCar) Link to comment
carvalhosgamer Posted May 22, 2014 Author Share Posted May 22, 2014 so this? local carUsedCount = {} function inCar(thePlayer) if (carUsedCount[source]) then carUsedCount[source] = carUsedCount[source] +1 else carUsedCount[source] = 1 end if (carUsedCount[source] == 1) then outputChatBox("First time to enter in this vehicle",thePlayer) end if (carUsedCount[source] == 2) then outputChatBox("Second time to enter in this vehicle",thePlayer) end end addEventHandler("onVehicleEnter" ,root, inCar) owwww awesome!! Works perfectly thank you very much Link to comment
carvalhosgamer Posted May 22, 2014 Author Share Posted May 22, 2014 serves this?so this? local carUsedCount = {} function inCar(thePlayer) if (carUsedCount[source]) then carUsedCount[source] = carUsedCount[source] +1 else carUsedCount[source] = 1 end if (carUsedCount[source] == 1) then outputChatBox("First time to enter in this vehicle",thePlayer) end if (carUsedCount[source] == 2) then outputChatBox("Second time to enter in this vehicle",thePlayer) end end addEventHandler("onVehicleEnter" ,root, inCar) yes! thank you for your attention! Link to comment
#RooTs Posted May 22, 2014 Share Posted May 22, 2014 Add, message color Add, Nick name in ChatBox Server.lua local carUsedCount = {} function inCar(thePlayer) if (carUsedCount[source]) then carUsedCount[source] = carUsedCount[source] +1 else carUsedCount[source] = 1 end if (carUsedCount[source] == 1) then outputChatBox("#ffffff"..getPlayerName( thePlayer ):gsub('#%x%x%x%x%x%x', '').. " #ff0000First time to enter in this vehicle",thePlayer, 255, 200, 0, true) end if (carUsedCount[source] == 2) then outputChatBox("#ffffff"..getPlayerName( thePlayer ):gsub('#%x%x%x%x%x%x', '').. " #ff0000Second time to enter in this vehicle",thePlayer, 255, 200, 0, true) end if (carUsedCount[source] == 3) then outputChatBox("#ffffff"..getPlayerName( thePlayer ):gsub('#%x%x%x%x%x%x', '').. " #ff0000Tree time to enter in this vehicle",thePlayer, 255, 200, 0, true) end end addEventHandler("onVehicleEnter" ,root, inCar) Link to comment
carvalhosgamer Posted May 22, 2014 Author Share Posted May 22, 2014 Add, message colorAdd, Nick name in ChatBox Server.lua local carUsedCount = {} function inCar(thePlayer) if (carUsedCount[source]) then carUsedCount[source] = carUsedCount[source] +1 else carUsedCount[source] = 1 end if (carUsedCount[source] == 1) then outputChatBox("#ffffff"..getPlayerName( thePlayer ):gsub('#%x%x%x%x%x%x', '').. " #ff0000First time to enter in this vehicle",thePlayer, 255, 200, 0, true) end if (carUsedCount[source] == 2) then outputChatBox("#ffffff"..getPlayerName( thePlayer ):gsub('#%x%x%x%x%x%x', '').. " #ff0000Second time to enter in this vehicle",thePlayer, 255, 200, 0, true) end if (carUsedCount[source] == 3) then outputChatBox("#ffffff"..getPlayerName( thePlayer ):gsub('#%x%x%x%x%x%x', '').. " #ff0000Tree time to enter in this vehicle",thePlayer, 255, 200, 0, true) end end addEventHandler("onVehicleEnter" ,root, inCar) Great! Thank you very much. I'm using that, works perfectly Link to comment
#RooTs Posted May 22, 2014 Share Posted May 22, 2014 if you want something, call me by MP Link to comment
carvalhosgamer Posted May 22, 2014 Author Share Posted May 22, 2014 if you want something, call me by MP Sure!!, definitely! I Appreciate That! Thanks Link to comment
#RooTs Posted May 22, 2014 Share Posted May 22, 2014 I will soon add the name of the vehicle in Message ChatBox Link to comment
manawydan Posted May 22, 2014 Share Posted May 22, 2014 You're welcome. dont forget to "clean" table if vehicle explode. Link to comment
carvalhosgamer Posted May 25, 2014 Author Share Posted May 25, 2014 You're welcome. dont forget to "clean" table if vehicle explode. thank you man, but how i do that? clean table? Link to comment
Karuzo Posted May 25, 2014 Share Posted May 25, 2014 Just use the event onVehicleExplode and do carUsedCount = {} Link to comment
manawydan Posted May 26, 2014 Share Posted May 26, 2014 addEventHandler("onVehicleExplode",root, function() if(carUsedCount[source]) then carUsedCount[source] =nil end end) Link to comment
#RooTs Posted May 26, 2014 Share Posted May 26, 2014 (manawydan )THAT? local carUsedCount = {} function inCar(thePlayer) if (carUsedCount[source]) then carUsedCount[source] = carUsedCount[source] +1 else carUsedCount[source] = 1 end if (carUsedCount[source] == 1) then outputChatBox("#ffffff"..getPlayerName( thePlayer ):gsub('#%x%x%x%x%x%x', '').. " #ff0000First time to enter in this vehicle",thePlayer, 255, 200, 0, true) end if (carUsedCount[source] == 2) then outputChatBox("#ffffff"..getPlayerName( thePlayer ):gsub('#%x%x%x%x%x%x', '').. " #ff0000Second time to enter in this vehicle",thePlayer, 255, 200, 0, true) end if (carUsedCount[source] == 3) then outputChatBox("#ffffff"..getPlayerName( thePlayer ):gsub('#%x%x%x%x%x%x', '').. " #ff0000Tree time to enter in this vehicle",thePlayer, 255, 200, 0, true) end end addEventHandler("onVehicleEnter" ,root, inCar) -- that ? addEventHandler("onVehicleExplode",root, function() if(carUsedCount[source]) then carUsedCount[source] =nil end end) 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