Raised This Month: $ Target: $400
 0% 

Respawning player right after death


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Desikac
Senior Member
Join Date: Apr 2010
Location: Serbia
Old 06-16-2011 , 09:33   Respawning player right after death
Reply With Quote #1

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
Desikac is offline
Send a message via MSN to Desikac Send a message via Skype™ to Desikac
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-16-2011 , 10:07   Re: Respawning player right after death
Reply With Quote #2

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
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 06-16-2011 , 10:31   Re: Respawning player right after death
Reply With Quote #3

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)
__________________
You can do anything you set your mind to, man.

Devil259 is offline
Desikac
Senior Member
Join Date: Apr 2010
Location: Serbia
Old 06-16-2011 , 10:57   Re: Respawning player right after death
Reply With Quote #4

Thanks Exolent.

But now when the player is respawned, his corpse is removed from the game. How can I prevent that?
Desikac is offline
Send a message via MSN to Desikac Send a message via Skype™ to Desikac
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-16-2011 , 11:12   Re: Respawning player right after death
Reply With Quote #5

Quote:
Originally Posted by Desikac View Post
Thanks Exolent.

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.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-16-2011 , 12:08   Re: Respawning player right after death
Reply With Quote #6

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)
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-19-2011 , 17:19   Re: Respawning player right after death
Reply With Quote #7

Quote:
Originally Posted by Exolent[jNr] View Post
You have to make your own corpse entity and block the ClCorpse message.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Desikac
Senior Member
Join Date: Apr 2010
Location: Serbia
Old 06-16-2011 , 15:54   Re: Respawning player right after death
Reply With Quote #8

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

Desikac is offline
Send a message via MSN to Desikac Send a message via Skype™ to Desikac
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 06-17-2011 , 17:56   Re: Respawning player right after death
Reply With Quote #9

any help with this? i need it too :S
OvidiuS is offline
Send a message via Skype™ to OvidiuS
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-18-2011 , 00:40   Re: Respawning player right after death
Reply With Quote #10

Quote:
Originally Posted by OvidiuS View Post
any help with this? i need it too :S
With the corpse not disappearing?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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