Jump to content

Medic problem


Wei

Recommended Posts

Posted
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

Posted (edited)
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
Posted

thanks. But it doens't work

1 question more

Is there anyway to remove debug.

Like I have jobs on event onPlayerDamage and it allways shows error when player is damaged...

Posted

Copy my code again, and no I don't think there is a way to remove debug, if you want to stop the debug messages showing to you, use /debugscript 0.

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

Posted

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 ) 

Posted

Again fail :mrgreen:

takePlayerMoney ( localPlayer, 100 ) 
givePlayerMoney ( theHealer, 200 ) 

takePlayerMoney, givePlayerMoney is not synced. You should trigger to server side and use this.

Posted

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 
) 

Posted

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 ) 

Guest Guest4401
Posted
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 ) 

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