Jump to content

Recommended Posts

Quick search revealed that prefabs/player_common.lua has

local function OnPlayerDeath(inst, data)...inst:ListenForEvent("death", OnPlayerDeath)
and components/health.lua has this:

self.inst:PushEvent("death", { cause = cause, afflicter = afflicter })
You might wanna experiment with passing some data to the event.
Link to comment
Share on other sites

local function OnPlayerDeath(inst, data)    if inst:HasTag("playerghost") then        --ghosts should not be able to die atm        return    end    inst:ClearBufferedAction()    inst.components.age:PauseAging()    inst.components.inventory:Close()    inst:PushEvent("ms_closepopups")    inst.deathcause = data ~= nil and data.cause or "unknown"    inst.deathpkname =        data ~= nil and        data.afflicter ~= nil and        data.afflicter:HasTag("player") and        data.afflicter:GetDisplayName() or nil    if not inst.ghostenabled then        if inst.deathcause ~= "file_load" then            inst.player_classified:AddMorgueRecord()            local announcement_string = GetNewDeathAnnouncementString(inst, inst.deathcause, inst.deathpkname)            if announcement_string ~= "" then               TheNet:Announce(announcement_string, inst.entity, false, "death")            end        end        --Early delete in case client disconnects before removal timeout        DeleteUserSession(inst)    endend

This is what I found in player_common.lua . I still doesn't understand how to make it work.

Edited by EmperorOfTheMankind
Link to comment
Share on other sites

 

If you take a look in eventannouncer.lua, the cause of death needs its own name, else it defaults to shenanigans.

STRINGS.NAMES.SOMETHING = "Something"owner:PushEvent("death", {cause = "something"})
[00:02:13]: [string "scripts/stategraphs/SGwilson.lua"]:1008: Left death state.LUA ERROR stack traceback:    =[C]:-1 in (global) assert (C) <-1--1>    scripts/stategraphs/SGwilson.lua:1008 in (field) onexit (Lua) <1006-1009>    scripts/stategraph.lua:460 in (method) GoToState (Lua) <448-509>    scripts/stategraphs/SGwilson.lua:430 in (field) fn (Lua) <388-434>    scripts/stategraph.lua:398 in (method) HandleEvents (Lua) <389-409>    scripts/stategraph.lua:143 in (method) Update (Lua) <107-146>    scripts/update.lua:209 in () ? (Lua) <150-223>

Nope, still error. Are you sure, that 

STRINGS.NAMES.SOMETHING = "Something"

"Something" and

{cause = "something"}

"something" shouldn't be both written from capital? Anyway it didn't work when I did the exact same words.

Edited by EmperorOfTheMankind
Link to comment
Share on other sites

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
 Share

×
×
  • Create New...