Jump to content

Работа медиком(Чуть-чуть помощи)


Recommended Posts

Итак,Я сделал работу врачом,НО-

Лечит и отнимает(Прибавляет) деньги без конца(Даже если ХП полное)

Вот код:

  
function Medic (attacker, attackerweapon, bodypart, loss) 
 health = getElementHealth (source) 
  local MedicTeam = createTeam ( "Medic", 200, 0, 100 ) 
  if (attackerweapon == 41) and (loss > 1) and ( health < 100 ) and MedicTeam 
 then 
setElementHealth( source, getElementHealth(source) + 10 ) 
    takePlayerMoney (source, 10) 
    givePlayerMoney (attacker, 10) 
  end 
end 
addEventHandler ("onPlayerDamage", getRootElement(), Medic ) 
  
  

Проверку команды делать функцией:

  

Link to comment

попробуй

function Medic (attacker, attackerweapon, bodypart, loss) 
 health = getElementHealth (source) 
  local MedicTeam = createTeam ( "Medic", 200, 0, 100 ) 
  if (attackerweapon == 41) and (loss > 1) and ( health < 100 ) and MedicTeam 
 then 
setElementHealth( source, getElementHealth(source) + 10 ) 
    takePlayerMoney (source, 10) 
    givePlayerMoney (attacker, 10) 
elseif (attackerweapon == 41) and (loss > 1) and ( health > 100 ) and MedicTeam 
 then 
    takePlayerMoney (source, 0) 
    givePlayerMoney (attacker, 0) 
  end 
end 
addEventHandler ("onPlayerDamage", getRootElement(), Medic ) 

Link to comment

Клиент

  
addEventHandler( 'onClientPlayerDamage',localPlayer, 
    function( attacker, weapon, bodypart, loss ) 
        local health = getElementHealth( source ) 
        local team = getPlayerTeam( attacker ) 
        if team then 
            if attacker and attacker ~= source and weapon == 41 and getTeamName( team ) == 'Medic' and health < 100 then 
                if getPlayerMoney( ) >= 10 then 
                    cancelEvent( ) 
                end 
            end 
        end 
    end 
) 

Сервер

createTeam ( "Medic", 200, 0, 100 ) 
  
addEventHandler( 'onPlayerDamage',root, 
    function( attacker, weapon, bodypart, loss ) 
        local health = getElementHealth( source ) 
        local team = getPlayerTeam( attacker ) 
        if team then 
            if attacker and attacker ~= source and weapon == 41 and getTeamName( team ) == 'Medic' and health < 100 then 
                local money = getPlayerMoney( source )  
                if money >= 10 then 
                    givePlayerMoney( attacker,10 ) 
                    takePlayerMoney( source,10 ) 
                    setElementHealth( source,getElementHealth( source ) + 10 ) 
                end 
            end 
        end  
    end 
) 

Обновил.

Link to comment

Сервер

createTeam ( "Medic", 200, 0, 100 ) 
  
addEventHandler( 'onPlayerDamage',root, 
    function( attacker, weapon, bodypart, loss ) 
        local health = getElementHealth( source ) 
        if isElement( attacker ) and attacker ~= source and weapon == 41 and health < 100 then 
            local team = getPlayerTeam( attacker ) 
            if team then 
                if getTeamName( team ) == 'Medic' then 
                    local money = getPlayerMoney( source )  
                    if money >= 10 then 
                        givePlayerMoney( attacker,10 ) 
                        takePlayerMoney( source,10 ) 
                        setElementHealth( source,getElementHealth( source ) + 10 ) 
                    end 
                end  
            end  
        end  
    end 
) 

Клиент

addEventHandler( 'onClientPlayerDamage',localPlayer, 
    function( attacker, weapon, bodypart, loss ) 
        local health = getElementHealth( source ) 
        if isElement( attacker ) and attacker ~= source and weapon == 41 and health < 100 then 
            local team = getPlayerTeam( attacker ) 
            if team then 
                if getTeamName( team ) == 'Medic' then 
                    if getPlayerMoney( ) >= 10 then 
                        cancelEvent( ) 
                    end 
                end  
            end 
        end 
    end 
) 

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