Hell-Mate Posted March 4, 2014 Posted March 4, 2014 Hello community ,, how to disable weapon damage to only one player or only one Data ? im scripting a medic job and i want this help to complete it.
Castillo Posted March 4, 2014 Posted March 4, 2014 He wants to disable the damage, not disable being able to fire/punch. @FaDy: Cancel the "onClientPlayerDamage" event.
Hell-Mate Posted March 4, 2014 Author Posted March 4, 2014 He wants to disable the damage, not disable being able to fire/punch.@FaDy: Cancel the "onClientPlayerDamage" event. well, im using onPlayerDamage on the medic function so if i canceled the damage so the medic function will not work. so which event should i use instead of onPlayerDamage ?
Castillo Posted March 4, 2014 Posted March 4, 2014 You can use onClientPlayerDamage, cancel the damage and trigger a server side event using triggerServerEvent to heal the player.
Hell-Mate Posted March 4, 2014 Author Posted March 4, 2014 You can use onClientPlayerDamage, cancel the damage and trigger a server side event using triggerServerEvent to heal the player. i did all what you said but something wrong , here is the script > --Server local skin = {[275] = true} addEvent ( "MedicHeal", true ) function fady (attacker, attackerweapon, bodypart, loss) playerHealth = getElementHealth (source) sourceMoney = getPlayerMoney (source) if not skin[getElementModel(attacker)] then return end if ( playerHealth < 199 ) and ( sourceMoney < 30 ) then cancelEvent () else if (attackerweapon == 41) and (loss > 1) and ( playerHealth < 199 ) and ( sourceMoney > 30 ) then setElementHealth ( source, playerHealth+15 ) givePlayerMoney ( attacker, 2*playerHealth ) setElementData ( attacker, "medic", true ) takePlayerMoney ( source, 2*playerHealth ) end end end addEventHandler ( "MedicHeal", getRootElement(), fady ) --Client function fady (attacker, weapon, bodypart) medicskin = getElementModel ( attacker, 275 ) if ( weapon == 41 ) and ( medicskin == true ) then cancelEvent () triggerServerEvent ( "MedicHeal", localPlayer ) else -- end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), fady )
Castillo Posted March 4, 2014 Posted March 4, 2014 You aren't passing the attacker element on triggerServerEvent.
Hell-Mate Posted March 4, 2014 Author Posted March 4, 2014 You aren't passing the attacker element on triggerServerEvent. triggerServerEvent ( "MedicHeal", attacker ) ??? i think the problem is in the server side ..
WhoAmI Posted March 4, 2014 Posted March 4, 2014 local skin = getElementModel ( attacker ) if ( weapon == 41 and skin == 275 ) then cancelEvent ( ) triggerServerEvent ( "MedicHeal", localPlayer, attacker, weapon, bodypart ) Should be like this.
Castillo Posted March 4, 2014 Posted March 4, 2014 -- client side: local skin = { [ 275 ] = true } function fady ( attacker, weapon, bodypart, loss ) if ( isElement ( attacker ) and getElementType ( attacker ) == "player" ) then if ( weapon == 41 ) and ( skin [ getElementModel ( attacker ) ] ) and ( loss > 1 ) then cancelEvent ( ) triggerServerEvent ( "MedicHeal", localPlayer, attacker ) end end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), fady ) -- server side: function fady ( attacker ) local playerHealth = getElementHealth ( source ) local sourceMoney = getPlayerMoney ( source ) if ( playerHealth < 199 ) and ( sourceMoney >= 30 ) then setElementHealth ( source, ( playerHealth + 15 ) ) givePlayerMoney ( attacker, ( 2 * playerHealth ) ) setElementData ( attacker, "medic", true ) takePlayerMoney ( source, ( 2 * playerHealth ) ) end end addEvent ( "MedicHeal", true ) addEventHandler ( "MedicHeal", getRootElement(), fady )
Hell-Mate Posted March 4, 2014 Author Posted March 4, 2014 --Tested --Now its not canceling damage and i must punch with spraycan to heal, i cant heal with spraying --No debug errors/warnings
WhoAmI Posted March 4, 2014 Posted March 4, 2014 What about root in 2nd argument of onClientPlayerDamage event?
Hell-Mate Posted March 4, 2014 Author Posted March 4, 2014 What about root in 2nd argument of onClientPlayerDamage event? same
myonlake Posted March 4, 2014 Posted March 4, 2014 Remove the loss part from the if statement. Spraycan might have a loss of equal to or less than 1.0, which I am also quite sure of.
Hell-Mate Posted March 4, 2014 Author Posted March 4, 2014 Remove the loss part from the if statement. Spraycan might have a loss of equal to or less than 1.0, which I am also quite sure of. Worked Thanks
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