Hell-Mate Posted March 4, 2014 Share 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. Link to comment
WhoAmI Posted March 4, 2014 Share Posted March 4, 2014 toggleControl ( source, "fire", false ) Link to comment
Castillo Posted March 4, 2014 Share Posted March 4, 2014 He wants to disable the damage, not disable being able to fire/punch. @FaDy: Cancel the "onClientPlayerDamage" event. Link to comment
Hell-Mate Posted March 4, 2014 Author Share 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 ? Link to comment
Castillo Posted March 4, 2014 Share Posted March 4, 2014 You can use onClientPlayerDamage, cancel the damage and trigger a server side event using triggerServerEvent to heal the player. Link to comment
Hell-Mate Posted March 4, 2014 Author Share 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 ) Link to comment
Castillo Posted March 4, 2014 Share Posted March 4, 2014 You aren't passing the attacker element on triggerServerEvent. Link to comment
Hell-Mate Posted March 4, 2014 Author Share 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 .. Link to comment
WhoAmI Posted March 4, 2014 Share 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. Link to comment
Castillo Posted March 4, 2014 Share 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 ) Link to comment
Hell-Mate Posted March 4, 2014 Author Share 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 Link to comment
WhoAmI Posted March 4, 2014 Share Posted March 4, 2014 What about root in 2nd argument of onClientPlayerDamage event? Link to comment
Hell-Mate Posted March 4, 2014 Author Share Posted March 4, 2014 What about root in 2nd argument of onClientPlayerDamage event? same Link to comment
myonlake Posted March 4, 2014 Share 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. Link to comment
Hell-Mate Posted March 4, 2014 Author Share 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 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