justn Posted March 15, 2014 Share Posted March 15, 2014 (edited) So this is a medic job im making, but, when the player gets 'theWeapon' and if he hits player i want it instead of the opposite player's health getting lower, it will get higher :3 server.lua function gotTheJob () setElementModel(source,275) setPlayerTeam(source, medic) theWeapon = giveWeapon ( source, 14 ) end addEvent("gotJob",true) addEventHandler ( "gotJob", getRootElement(), gotTheJob ) client.lua addEventHandler("onClientGUIClick",Medic_Window, function(b,thePlayer) if b == "left" then if source == Medic_GetJob then exports["TopBarChat"]:sendClientMessage("You are now a medic !",0, 125, 255, true) triggerServerEvent ( "gotJob", localPlayer) guiSetVisible(Medic_Window,false) guiSetVisible(Medic_GetJob,false) Medic_QuitJob = guiCreateButton(49, 228, 163, 36, "Quit Job", false, Medic_Window) showCursor(false) end end end) Edited March 15, 2014 by Guest Link to comment
Dealman Posted March 15, 2014 Share Posted March 15, 2014 You'll need to use an event such as onPlayerDamage. You then check what kind of weapon was used, if the weapon was ID 14 - then get the source's health using getElementHealth, then use setElementHealth. Something like this. (Server-Side, Untested); function healPlayerOnHit_Handler(theAttacker, theWeapon, theBodyPart, theLoss) if(getElementType(theAttacker) == "player") then if(theWeapon == 14) then cancelEvent() local targetCurrentHealth = getElementHealth(source) local newHealth = targetCurrentHealth+5 -- Replace 5 with the amount the player should be healed. setElementHealth(source, newHealth) end end end addEventHandler("onPlayerDamage", getRootElement(), healPlayerOnHit_Handler) 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