Jump to content

[HELP] Disable weapon damage


Recommended Posts

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 :S, 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

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

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