AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Respawning player right after death (https://forums.alliedmods.net/showthread.php?t=159369)

Desikac 06-16-2011 09:33

Respawning player right after death
 
How can I respawn a player 1 second after death?

PHP Code:

public death() {
    new 
attacker read_data(1);
    new 
victim read_data(2);
    new 
headshot read_data(3)
    new 
weapon[11]
    
read_data(4weapon11)
    
    if(
equal(weapon"grenade"))
        return 
PLUGIN_CONTINUE
       
    
if(attacker == victim)
        return 
PLUGIN_CONTINUE
     
    
if(headshot)
        return 
PLUGIN_CONTINUE
    
    
new origin[3]
    
get_user_origin(victimorigin0//remember the position
    
if(random_num(1,10) == 2) { //10% chance
        
set_task(0.9"lstchn"victimorigin3)
    }
    
    return 
PLUGIN_CONTINUE
    
}

public 
lstchn(victimorigin[3]) {
    
spawn(victim)


The code above gives me the error: [FUN] Entity out of range (4804).
Tried ExecuteHamB(Ham_CS_RoundRespawn,victim), same error.
Also tried http://forums.alliedmods.net/showpos...4&postcount=19 and I get another error: [FAKEMETA] Invalid entity

Exolent[jNr] 06-16-2011 10:07

Re: Respawning player right after death
 
1. You mixed the params in the header of your task handler.

PHP Code:

public lstchn(origin[3], victim) { 

2. Don't use spawn(). Use
PHP Code:

ExecuteHamB(Ham_CS_RoundRespawnid

or
PHP Code:

set_pev(idpev_deadflagDEAD_RESPAWNABLE)
dllfunc(DLLFunc_Thinkid


Devil259 06-16-2011 10:31

Re: Respawning player right after death
 
1. Hook Ham_Killed or DeathMsg event.
2. set_task( ) with parameter the victim and time 1.0
3. ExecuteHamB( Ham_CS_RoundRespawn , victim ) (don't forget to check if the player isn't alive)

Desikac 06-16-2011 10:57

Re: Respawning player right after death
 
Thanks Exolent. :D

But now when the player is respawned, his corpse is removed from the game. How can I prevent that?

Exolent[jNr] 06-16-2011 11:12

Re: Respawning player right after death
 
Quote:

Originally Posted by Desikac (Post 1489393)
Thanks Exolent. :D

But now when the player is respawned, his corpse is removed from the game. How can I prevent that?

You have to make your own corpse entity and block the ClCorpse message.

ConnorMcLeod 06-16-2011 12:08

Re: Respawning player right after death
 
PHP Code:

/*    Formatright © 2010, ConnorMcLeod

    This plugin is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this plugin; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <amxmodx>

#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.0.2"
#define PLUGIN "Respawn After Death" // "Kz Respawn"

#define XO_PLAYER                5
#define m_iMenuCode                205
// #define m_iSpawnTimes            365

#define Menu_ChooseAppearance    3
#define cs_get_user_menu(%0)    get_pdata_int(%0, m_iMenuCode, XO_PLAYER)

new bool:g_bRoundEnd

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")

    
RegisterHam(Ham_Killed"player""Ham_CBasePlayer_Killed_Post"1)

    
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0")
    
register_logevent("Logevent_Round_End"2"1=Round_End")

//    register_clcmd("joinclass", "ClCmd_CoudBeChoosingAppearance")
//    register_clcmd("menuselect", "ClCmd_CoudBeChoosingAppearance")

    
set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET)
}

public 
Event_HLTV_New_Round()
{
    
g_bRoundEnd false
}

public 
Logevent_Round_End()
{
    
g_bRoundEnd true
}

/*public ClCmd_CoudBeChoosingAppearance( id )
{
    if( !g_bRoundEnd && cs_get_user_menu(id) == Menu_ChooseAppearance )
    {
        set_pdata_int(id, m_iSpawnTimes, 0, XO_PLAYER) // this method only works on maps that don't have objectives
    }
}*/

public Ham_CBasePlayer_Killed_Postid )
{
    if( !
g_bRoundEnd && cs_get_user_menu(id) != Menu_ChooseAppearance )
    {
        
set_pev(idpev_deadflagDEAD_RESPAWNABLE)
    }



Desikac 06-16-2011 15:54

Re: Respawning player right after death
 
I've tried making a new corpse in the ClCorpse event but it still gets removed from the game. Guess it just edits the original model...
PHP Code:

public msgClCorpse()
{
    new 
model[33], corpse[33]
    
get_msg_arg_string(1model32)
    
get_corpse_model(modelcorpse32)
    
    new 
Float:modelOrigin[3]
    
modelOrigin[0] = float(get_msg_arg_int(2) / 128)
    
modelOrigin[1] = float(get_msg_arg_int(3) / 128)
    
modelOrigin[2] = float(get_msg_arg_int(4) / 128
    
    new 
Float:modelAngel[3]
    
modelAngel[0] = get_msg_arg_float(5)
    
modelAngel[1] = get_msg_arg_float(6)
    
modelAngel[2] = get_msg_arg_float(7)
    
    new 
entCorpse create_entity("info_target")
    if(
entCorpse 0)
    {
        
entity_set_string(entCorpseEV_SZ_classname"clcorpse")
        
entity_set_string(entCorpseEV_SZ_modelcorpse)
        
entity_set_int(entCorpseEV_INT_solidSOLID_TRIGGER)
        
entity_set_int(entCorpseEV_INT_movetypeMOVETYPE_TOSS)
        
entity_set_int(entCorpseEV_INT_sequenceget_msg_arg_int(9))
        
entity_set_vector(entCorpseEV_VEC_originmodelOrigin)
        
entity_set_vector(entCorpseEV_VEC_anglesmodelAngel)
    }
    return 
PLUGIN_HANDLED



OvidiuS 06-17-2011 17:56

Re: Respawning player right after death
 
any help with this? i need it too :S

Exolent[jNr] 06-18-2011 00:40

Re: Respawning player right after death
 
Quote:

Originally Posted by OvidiuS (Post 1490378)
any help with this? i need it too :S

With the corpse not disappearing?

DjOptimuS 06-18-2011 02:46

Re: Respawning player right after death
 
You will have a map full of dead bodies, and if you have a respawn server remember that the entity limit is set to 512 if i remember corectly, not really a good ideea to keep the bodies on the map. My opinion at least.


All times are GMT -4. The time now is 23:31.

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