Jump to content

Are players able to have 250 health in MTA?


Recommended Posts

Posted

You can increase it over 100 by other means, I believe Solidsnake made a resource which does this very thing using element data. I'd recommend you look it up :)

Posted

You can make them more than 200 and 100

set element data to the player with the health or armor you want

on player damage check if the health data more that player health cancel the event

Something like that: (Haven't tested it)

function setElementHealth2(player,h) 
    assert(player and getElementType(player) == "player","Bad argument @ 'setElementHealth2'") 
    assert(h and type(h) == "number","Bad argument @ 'setElementHealth2'") 
    return setElementData(player,"health",h) -- set the element health data 
end 
  
function setElementArmor(player,a) 
    assert(player and getElementType(player) == "player","Bad argument @ 'setElementArmor'") 
    assert(a and type(a) == "number","Bad argument @ 'setElementArmor'") 
    return setElementData(player,"armor",a) -- set the element armor data 
end 
  
function getElementHealth2(player) 
    assert(player and getElementType(player) == "player","Bad argument @ 'getElementHealth2'") 
    return getElementData(player,"health") or 0 
end 
  
function getElementArmor(player) 
    assert(player and getElementType(player) == "player","Bad argument @ 'getElementArmor'") 
    return getElementData(player,"armor") or 0 
end 
  
addEventHandler("onClientPlayerDamage",root, 
function(_,_,_,loss) 
    if loss then 
        local armor = getElementArmor(source) 
        if armor > 0 then 
            if loss > armor then 
                setElementArmor(source,0) 
                setElementHealth(source,loss-armor) 
                cancelEvent() 
            else 
                setElementArmor(source,armor-loss) 
                cancelEvent() 
            end 
        else 
            local health = getElementHealth(source) 
            local health2 = getElementHealth2(source) 
            if health2 > health then 
                if loss > health2 then 
                    setElementHealth2(source,0) 
                    setElementHealth(source,loss-health2) 
                    cancelEvent() 
                else 
                    setElementHealth2(source,health2-loss) 
                    cancelEvent() 
                end 
            else 
                setElementHealth2(source,health2-loss) 
            end 
        end 
    end 
end 
) 

Posted

@Alw7sH it would be smarter to do the damage thing on server-side(to make it more secure, clients can fake/hack the element data from client side)

Posted

Then you need to trigger server side to decreases player health/armor and that's kinda wired players with bad connection gonna see the health updating abit slow

Posted
Then you need to trigger server side to decreases player health/armor and that's kinda wired players with bad connection gonna see the health updating abit slow

You're just asking server for 1 simple info from client, i don't know if this affects player's connection, but if it does even if its rly rly slow it would take like 0.0000000001% of it

Posted

If you're going to trigger the server every shot that has been done.. you're going to have a hard time. Imagine 500 players, shooting with miniguns at each other. And then look at your server load.. I would cancel all the damage done on the client side, and handle all the received damage at the server without calls. The server will always be right, your data will be set by the server and players won't be able to mess around with it.

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