AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Spawn a player during respawn timer (DOD) (https://forums.alliedmods.net/showthread.php?t=335772)

cmndrfello 01-02-2022 12:06

Spawn a player during respawn timer (DOD)
 
Hello, I've recently been trying to create a zombie plague style plugin for Day of Defeat.
I'm trying to make it so when an Allied player dies he will instantly be switched to Axis and respawn and moved to his last position.
But for some reason when I try to respawn the player after death it is unable to do it.

Even after creating a task with 'set_task' to try and respawn the player after the death animation it just won't work.

Is there a potential fix for this? Or would I have to settle for a timed respawn

Code:

public plugin_init()
{
RegisterHam(Ham_Killed, "player", "Ham_OnKilled_Post");
}

public Ham_OnKilled_Post(id, killer)
{
        new Float:value;
        new string[MAX_STRING];
       
        //pev_deadflag of 'id' is 0 (DEAD_NO)

        if( get_user_team(id) == TEAM_HUMANS ) {
                new deathpos[3];

                get_user_origin(id, deathpos);
                dod_set_user_team(id, 2, 0);
               
                set_pev(id, pev_deadflag, DEAD_RESPAWNABLE);
                //pev_deadflag of 'id' is 3 (DEAD_RESPAWNABLE)
                DispatchSpawn(id);

                set_user_origin(id, deathpos);
        }
}


CrazY. 01-02-2022 13:22

Re: Spawn a player during respawn timer (DOD)
 
Code:

public Ham_OnKilled_Post(id, killer)
{
        new Float:value;
        new string[MAX_STRING];
       
        //pev_deadflag of 'id' is 0 (DEAD_NO)

        if( get_user_team(id) == TEAM_HUMANS ) {
                new deathpos[3];

                get_user_origin(id, deathpos);
                dod_set_user_team(id, 2, 0);
                               
                //set_pev(id, pev_deadflag, DEAD_RESPAWNABLE);
                //pev_deadflag of 'id' is 3 (DEAD_RESPAWNABLE)
                //DispatchSpawn(id);

               
                ExecuteHamB(Ham_RoundRespawn, id)

                set_user_origin(id, deathpos);
        }
}


OciXCrom 01-02-2022 13:36

Re: Spawn a player during respawn timer (DOD)
 
Your forward is not in "post". RegisterHam's "post" argument defaults to 0 which means you're in "pre" because you did not specify the argument.

=>

Code:
RegisterHam(Ham_Killed, "player", "Ham_OnKilled_Post", 1);

cmndrfello 01-02-2022 13:36

Re: Spawn a player during respawn timer (DOD)
 
Quote:

Originally Posted by CrazY. (Post 2767462)
Code:

ExecuteHamB(Ham_RoundRespawn, id)

I assume you meant "Ham_DOD_RoundRespawn" and have tried that but it did not work... The team is switched but the player does not get respawned by the command only after the respawn timer ends like normally

Is there a flag a different flag that is blocking the spawn? because i haven't found anything related to this problem in Day of Defeat so i am stuck by not knowing why is the respawn restricted

cmndrfello 01-02-2022 13:48

Re: Spawn a player during respawn timer (DOD)
 
Quote:

Originally Posted by OciXCrom (Post 2767464)
Your forward is not in "post". RegisterHam's "post" argument defaults to 0 which means you're in "pre" because you did not specify the argument.

You are right! I have tried it now, but for some reason the player won't respawn, it only skips the death "cutscene"/animation and still waits for the respawn timer to end...

I tried with set_task but still it wont respawn the player...
Code:

public Ham_OnKilled_Post(id, killer)
{
        new Float:value;
        new string[MAX_STRING];

        if( get_user_team(id) == TEAM_HUMANS ) {
                new deathpos[3];

                get_user_origin(id, deathpos);
                dod_set_user_team(id, TEAM_ZOMBIE, 0);

                ExecuteHamB(Ham_DOD_RoundRespawn, id);
                set_task(0.5, "Revive", id);
               
                set_user_origin(id, deathpos);
        }
}

public Revive(id){
        ExecuteHamB(Ham_DOD_RoundRespawn, id)
}


Natsheh 01-02-2022 16:15

Re: Spawn a player during respawn timer (DOD)
 
Try Ham_Spawn and remove the task.

fysiks 01-02-2022 19:04

Re: Spawn a player during respawn timer (DOD)
 
Quote:

Originally Posted by Natsheh (Post 2767472)
Try Ham_Spawn and remove the task.

I just tested this and it doesn't work.

@cmndrfello, there is a plugin by dodsynthetic that implements and instant spawn using Fakemeta on dodplugins.net. I'm not sure if it works anymore though since I've never used it.

cmndrfello 01-04-2022 00:07

Re: Spawn a player during respawn timer (DOD)
 
Quote:

Originally Posted by fysiks (Post 2767485)
@cmndrfello, there is a plugin by dodsynthetic that implements and instant spawn using Fakemeta on dodplugins.net. I'm not sure if it works anymore though since I've never used it.

It's exactly what I'm looking for but I can't seem to get it downloaded. You need a activated account and though I created one they don't send a activation email and so I'm stuck as I can't request another email

fysiks 01-04-2022 02:53

Re: Spawn a player during respawn timer (DOD)
 
1 Attachment(s)
Here ya go

cmndrfello 01-04-2022 10:05

Re: Spawn a player during respawn timer (DOD)
 
Quote:

Originally Posted by fysiks (Post 2767590)
Here ya go

Thank you! Looks interesting! I will take a look once I get the chance and will update about my findings


All times are GMT -4. The time now is 11:30.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.