Jump to content

Medic problem


Wei

Recommended Posts

function medicJob (theHealer, healerweapon, bodypart, loss) 
local theHealth = getElementHealth (source) 
local theSkin = getElementModel ( theHealer ) 
  if ( getPedWeapon( theHealer ) == 41 ) and ( loss > 1 ) and ( theHealth < 90 ) and ( theSkin == 274 ) then 
    setElementHealth ( source, 100 ) 
    takePlayerMoney ( source, 100 ) 
    givePlayerMoney ( theHealer, 200 ) 
    cancelEvent() 
 end 
end 
addEventHandler ("onPlayerDamage", getRootElement(), medicJob ) 

It auto heals me eaven if the healer is not player

Link to comment
function medicJob (theHealer, healerweapon, bodypart, loss) 
local theHealth = getElementHealth (source) 
local theSkin = getElementModel ( theHealer ) 
  if ( healerweapon == 41 ) and ( loss > 1 ) and ( theHealth < 90 ) and ( theSkin == 274 ) and theHealer ~= localPlayer and getElementType(theHealer) == "player" then 
    setElementHealth ( source, 100 ) 
    takePlayerMoney ( source, 100 ) 
    givePlayerMoney ( theHealer, 200 ) 
    cancelEvent() 
 end 
end 
addEventHandler ("onPlayerDamage", getRootElement(), medicJob ) 

Edited by Guest
Link to comment
function medicJob (theHealer, healerweapon, bodypart, loss) 
local theHealth = getElementHealth (source) 
local theSkin = getElementModel ( theHealer ) 
  if ( healerweapon == 41 ) and ( loss > 1 ) and ( theHealth < 90 ) and ( theSkin == 274 ) and theHealer ~= localPlayer and getElementType(theHealer) == "player" then 
    setElementHealth ( source, 100 ) 
    takePlayerMoney ( source, 100 ) 
    givePlayerMoney ( theHealer, 200 ) 
    cancelEvent() 
 end 
end 
addEventHandler ("onPlayerDamage", getRootElement(), medicJob ) 

Alpha onPlayerDamage event is not cancelled. localPlayer only in client side.

Link to comment

Damn, I should have noticed it's onPlayerDamage, my bad.

Here:

function medicJob (theHealer, healerweapon, bodypart, loss) 
local theHealth = getElementHealth (localPlayer) 
local theSkin = getElementModel ( theHealer ) 
  if ( healerweapon == 41 ) and ( loss > 1 ) and ( theHealth < 100 ) and ( theSkin == 274 ) and getElementType(theHealer) == "player" then 
    setElementHealth ( localPlayer, 100 ) 
    takePlayerMoney ( localPlayer, 100 ) 
    givePlayerMoney ( theHealer, 200 ) 
    cancelEvent() 
 end 
end 
addEventHandler ("onClientPlayerDamage", localPlayer, medicJob ) 

Link to comment

Client:

function medicJob (theHealer, healerweapon, bodypart, loss) 
local theHealth = getElementHealth (localPlayer) 
local theSkin = getElementModel ( theHealer ) 
  if ( healerweapon == 41 ) and ( loss > 1 ) and ( theHealth < 100 ) and ( theSkin == 274 ) and getElementType(theHealer) == "player" then 
    setElementHealth ( localPlayer, 100 ) 
    triggerServerEvent("awardMedic", localPlayer, theHealer) 
    cancelEvent() 
 end 
end 
addEventHandler ("onClientPlayerDamage", localPlayer, medicJob ) 

Server:

addEvent("awardMedic", true) 
addEventHandler("awardMedic", root, 
     function(healer) 
          givePlayerMoney(healer, 200) 
          takePlayerMoney(source, 100) 
     end 
) 

Link to comment

Ok. I have 1 question more why is the blip visible to all ?

function createRoute () 
    x, y, z = unpackTrucker () 
    truckerMarker = createMarker ( x, y, z, "cylinder", 1.5, 255, 0, 0, 85 ) 
    truckerBlip = createBlipAttachedTo( truckerMarker, 32 ) 
    addEventHandler ( "onClientMarkerHit", truckerMarker, funct ) 
end 
addEventHandler ( "onClientMarkerHit", trucker, createRoute ) 

Link to comment
Guest Guest4401
function createRoute (hitPlayer) 
    if hitPlayer and hitPlayer == localPlayer then 
        x, y, z = unpackTrucker () 
        truckerMarker = createMarker ( x, y, z, "cylinder", 1.5, 255, 0, 0, 85 ) 
        addEventHandler ( "onClientMarkerHit", truckerMarker, funct ) 
        truckerBlip = createBlipAttachedTo( truckerMarker, 32 ) 
    end 
end 
addEventHandler ( "onClientMarkerHit", trucker, createRoute ) 

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