Wei Posted May 26, 2012 Share Posted May 26, 2012 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
Alpha Posted May 26, 2012 Share Posted May 26, 2012 (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 May 26, 2012 by Guest Link to comment
Wei Posted May 26, 2012 Author Share Posted May 26, 2012 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... Link to comment
Alpha Posted May 26, 2012 Share Posted May 26, 2012 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. Link to comment
Kenix Posted May 26, 2012 Share Posted May 26, 2012 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
Alpha Posted May 26, 2012 Share Posted May 26, 2012 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
Kenix Posted May 26, 2012 Share Posted May 26, 2012 Again fail takePlayerMoney ( localPlayer, 100 ) givePlayerMoney ( theHealer, 200 ) takePlayerMoney, givePlayerMoney is not synced. You should trigger to server side and use this. Link to comment
Alpha Posted May 26, 2012 Share Posted May 26, 2012 Damn you. I think he can do that by himself. Link to comment
Kenix Posted May 26, 2012 Share Posted May 26, 2012 Anyway. You should write correct code. Link to comment
Alpha Posted May 26, 2012 Share Posted May 26, 2012 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
Wei Posted May 26, 2012 Author Share Posted May 26, 2012 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 Posted May 26, 2012 Share Posted May 26, 2012 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
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