-.Paradox.- Posted January 26, 2015 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 ) If you're looking for a cheap paid scripter, don't hesitate to contact me. Great minds discuss ideas, Average minds discuss events and small minds discuss people.
John Smith Posted January 26, 2015 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 If you find my post useful or if it helped you, please like my post Ingame name: ZoeN
-.Paradox.- Posted January 26, 2015 Author Posted January 26, 2015 Thank you, Is there any way to fix that and make the custom damage occur? If you're looking for a cheap paid scripter, don't hesitate to contact me. Great minds discuss ideas, Average minds discuss events and small minds discuss people.
John Smith Posted January 26, 2015 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. If you find my post useful or if it helped you, please like my post Ingame name: ZoeN
-.Paradox.- Posted January 26, 2015 Author Posted January 26, 2015 Thanks dude, I appreciate. If you're looking for a cheap paid scripter, don't hesitate to contact me. Great minds discuss ideas, Average minds discuss events and small minds discuss people.
John Smith Posted January 26, 2015 Posted January 26, 2015 no problem. If you find my post useful or if it helped you, please like my post Ingame name: ZoeN
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