Jump to content

C Stack overflow


-.Paradox.-

Recommended Posts

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

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