Jump to content

Recommended Posts

basically i want to make it so an event is pushed when the character dies, this event will resurrect the player after 15 seconds, to give the player time to move away from place of death.

 

i want to learn how to do this and if it is possible at all.

 

The reason i want to make a character autorevive is to have him available to my friends who are newer to the game and dont like having to wait for a revive or having to walk to spawn (we play on endless)

@sasukefan01234, Use a scheduled task:

-- Will apply to every playerAddPlayerPostInit(function(inst)    if GLOBAL.TheNet:GetIsServer() then -- only host must run this        inst:ListenForEvent("death", function() -- when players dies            inst:DoTaskInTime(15, function() -- you can change the time (now 15 seconds)                inst:PushEvent("respawnfromghost") -- push resurrection event after 15 seconds            end)        end)    endend)
  • Health 1

And if you want to change the generic "was resurrected by shenanigans!" message, you can use:

inst:PushEvent("respawnfromghost", {source={name="your favorite reason"}})

For me, this makes the message "rezecib was resurrected by your favorite reason."

thank you for your responses guys, that was fast, but i have a question...

 

Where am i supposed to add that function?

I only want that event pushed when a certain character dies (EX. when anyone using willow dies wait 15 seconds and revive only willow. If any other player dies using any other character that isn't willow he cant push this event to get respawned and will have to be revived using official methods.) 

 

How can i make this a perk on a custom character (the one they will be using)?

bump
 Do not bump your posts.

 

AddPlayerPostInit is a modmain thing, but that would make this happen for every character. I think you want it just for your character, so you can just pull out the inner portion of that and put it in your character's master_postinit:

inst:ListenForEvent("death", function() -- when players dies    inst:DoTaskInTime(15, function() -- you can change the time (now 15 seconds)        inst:PushEvent("respawnfromghost", {source={name="reason"}}) -- push resurrection event after 15 seconds    end)end)

You won't need the GetIsServer part if you put it there, because the master_postinit only runs on the server, anyway.

 Do not bump your posts.

 

AddPlayerPostInit is a modmain thing, but that would make this happen for every character. I think you want it just for your character, so you can just pull out the inner portion of that and put it in your character's master_postinit:

inst:ListenForEvent("death", function() -- when players dies    inst:DoTaskInTime(15, function() -- you can change the time (now 15 seconds)        inst:PushEvent("respawnfromghost", {source={name="reason"}}) -- push resurrection event after 15 seconds    end)end)

You won't need the GetIsServer part if you put it there, because the master_postinit only runs on the server, anyway.

 

 

Now I've tried imputing this into a custom character I've been making for hours onw, and still can't get it to work... can anyone show me exactly how to enter this into the master_postinit?

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
×
  • Create New...