Boris_Nemtsov Posted June 2, 2015 Posted June 2, 2015 Hi. I'm curious whether there is a certain "max limit" to how much players can have in MTA. https://wiki.multitheftauto.com/wiki/SetElementHealth I assume I can get 250 health or 300 if I want. Right?
Boris_Nemtsov Posted June 2, 2015 Author Posted June 2, 2015 Damn it. And I see here: https://wiki.multitheftauto.com/wiki/SetPedArmor That the max armor is 100. That's too bad.
Dealman Posted June 2, 2015 Posted June 2, 2015 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
ALw7sH Posted June 2, 2015 Posted June 2, 2015 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 )
SunArrow Posted June 2, 2015 Posted June 2, 2015 @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)
SunArrow Posted June 2, 2015 Posted June 2, 2015 Cancel the event on client, but read and write element data on server side
ALw7sH Posted June 2, 2015 Posted June 2, 2015 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
SunArrow Posted June 2, 2015 Posted June 2, 2015 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
Enargy, Posted June 3, 2015 Posted June 3, 2015 It should work fine. https://community.multitheftauto.com/in ... ls&id=5195
tosfera Posted June 4, 2015 Posted June 4, 2015 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.
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