Jump to content

Ambulance


beatles1

Recommended Posts

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

-- 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

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

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...