-.Paradox.- Posted January 26, 2015 Share Posted January 26, 2015 Hi, I was trying to make my own damage system but for unknown reason i get this message in debug which i don't understand. Damage/client.lua:8: C Stack overflow Here's the code: loss = { [33] = 25, [34] = 50, } function triggerCustomDamage ( attacker, weapon, bodypart, loss ) if attacker and source then cancelEvent() triggerEvent("onClientPedDamage", source, attacker, getPedWeapon(attacker), bodypart, loss[getPedWeapon(attacker)], true) end end addEventHandler ( "onClientPedDamage", getRootElement(), triggerCustomDamage ) Link to comment
John Smith Posted January 26, 2015 Share Posted January 26, 2015 (edited) it's obvious and logical. ped gets damage upon event - inside that event you trigger ped damage event again which does that thing over and over again resulting in infinite loop(c stack overflow) edit: if you want directly to use custom damage in that event, on damage use setElementHealth(source,getElementHealth(source)+loss) -- return it to previous state setElementHealth(source,getElementHealth(source) - loss[getPedWeapon(killer)]) -- set health damage to your custom defined one Edited January 26, 2015 by Guest Link to comment
-.Paradox.- Posted January 26, 2015 Author Share Posted January 26, 2015 Thank you, Is there any way to fix that and make the custom damage occur? Link to comment
John Smith Posted January 26, 2015 Share Posted January 26, 2015 i've edited my above post edit: oh also i suggest you to rename your 'loss' table to something else to avoid conflicts with 'loss' variable in onClientPedDamage event. Link to comment
-.Paradox.- Posted January 26, 2015 Author Share Posted January 26, 2015 Thanks dude, I appreciate. 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