beatles1 Posted November 28, 2011 Share Posted November 28, 2011 Hi, Today I had a go at making a script that would give a player full health if they entered an ambulance and give the driver $500 if there was one and they where in the right skin. I found that this was a bit beyond my skill level so I would be grateful of some help. I can see how to use getElementModel to check every time someone enters a vehicle if its an ambulance but then how would I check for the drivers skin and give the driver money as well as the passenger health? Any help would be appreciated. Thanks in advance. Link to comment
Castillo Posted November 28, 2011 Share Posted November 28, 2011 -- server side: function onAmbulanceEnter(thePlayer, seat, jacked) if (getElementModel(source) == 416) then if (seat == 0) then return end local driver = getVehicleController(source) if (not driver) then return end if (getElementModel(driver) ~= 0) then return end -- Change '0' to the Medic skin ID. if (getElementHealth(thePlayer) >= 100) then return end setElementHealth(thePlayer, 100) givePlayerMoney(driver, 500) end end addEventHandler ( "onVehicleEnter", root, onAmbulanceEnter ) Should work. Link to comment
beatles1 Posted November 28, 2011 Author Share Posted November 28, 2011 Thanks that works great. Got a real mind block though. If I wanted to have more than 1 medic skin then what would I use as I obviously cant use or? Thanks again that's been a real help. Link to comment
Castillo Posted November 28, 2011 Share Posted November 28, 2011 You could use 'or', but would be easier to make a table . local medicSkins = { [0] = true, [299] = true } function onAmbulanceEnter(thePlayer, seat, jacked) if (getElementModel(source) == 416) then if (seat == 0) then return end local driver = getVehicleController(source) if (not driver) then return end if (not medicSkins[getElementModel(driver)]) then return end -- This will check if the player SKIN is on medicSkins table. if (getElementHealth(thePlayer) >= 100) then return end setElementHealth(thePlayer, 100) givePlayerMoney(driver, 500) end end addEventHandler ( "onVehicleEnter", root, onAmbulanceEnter ) Should work. 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