Jump to content

C Stack overflow


-.Paradox.-

Recommended Posts

Posted

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.

Posted (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 by Guest

If you find my post useful or if it helped you, please like my post :)
Ingame name: ZoeN

560x95_FFFFFF_FF9900_000000_000000.png

Posted

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.

Posted

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

560x95_FFFFFF_FF9900_000000_000000.png

Posted

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.

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