AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help for AMX Respawn (https://forums.alliedmods.net/showthread.php?t=89283)

ds811888 04-04-2009 15:19

Need help for AMX Respawn
 
Code:

public death_msg()

 if(get_pcvar_num(cvar_zrespawn)) 
 {
  new vIndex = read_data(2)
  new svIndex[2]
  svIndex[0] = vIndex
  set_task(10.0,"respawn",0,svIndex,2)
}
 return PLUGIN_CONTINUE
}
public respawn(svIndex[])
{
 new vIndex = svIndex[0]
 if(get_user_team(vIndex) == 3 || is_user_alive(vIndex))
  return PLUGIN_CONTINUE
 spawn(vIndex)
 
 return PLUGIN_CONTINUE   
}
public plugin_init()
{
 register_event("DeathMsg","death_msg","a")
 cvar_zrespawn  = register_cvar("bh_respawn","1")
 
 return PLUGIN_CONTINUE
}

I have a bug when set "10"

set_task(10.0,"respawn",0,svIndex,2)

+karma

M1R0n,M' 04-04-2009 15:38

Re: Need help for AMX Respawn
 
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define OFFSET_TEAM 114 
#define fm_get_user_team(%1) ( get_pdata_int ( %1, OFFSET_TEAM ) )

#define PLUGIN "Respawn"
#define VERSION "1.0"
#define AUTHOR "M1R0n,M'"

new g_Status;

public 
plugin_init()  
{      
       
register_plugin(PLUGIN,VERSION,AUTHOR)
            
       
g_Status register_cvar("amx_respawn","1"
     
       
RegisterHam(Ham_Killed"player""Killed_Player"1);
}

public 
Killed_Player(VictimKiller
{
    if(!
get_pcvar_num(g_Status))
        return;

    if(!
is_user_alive(Victim))
    {
        
set_task(10.0,"Respawn",Victim)
    }
}

public 
Respawn(id)
{
    if (
fm_get_user_team(id) == || fm_get_user_team(id) == 3)
                return;

    
ExecuteHamB(Ham_CS_RoundRespawn,id);


No tested.

ds811888 04-05-2009 00:57

Re: Need help for AMX Respawn
 
Quote:

Originally Posted by M1R0n,M' (Post 797372)
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
 
#define OFFSET_TEAM 114 
#define fm_get_user_team(%1) ( get_pdata_int ( %1, OFFSET_TEAM ) )
 
#define PLUGIN "Respawn"
#define VERSION "1.0"
#define AUTHOR "M1R0n,M'"
 
new g_Status;
 
public 
plugin_init()  
{      
       
register_plugin(PLUGIN,VERSION,AUTHOR)
 
       
g_Status register_cvar("amx_respawn","1"
 
       
RegisterHam(Ham_Killed"player""Killed_Player"1);
}
 
public 
Killed_Player(VictimKiller
{
    if(!
get_pcvar_num(g_Status))
        return;
 
    if(!
is_user_alive(Victim))
    {
        
set_task(10.0,"Respawn",Victim)
    }
}
 
public 
Respawn(id)
{
    if (
fm_get_user_team(id) == || fm_get_user_team(id) == 3)
                return;
 
    
ExecuteHamB(Ham_CS_RoundRespawn,id);


No tested.

Nice! +karma!

SnoW 04-05-2009 06:45

Re: Need help for AMX Respawn
 
Code:

#include <amxmodx>
#include <hamsandwich>
 
#define PLUGIN "Respawn"
#define VERSION "1.0"
#define AUTHOR "M1R0n,M'"
 
new g_Status;
 
public plugin_init() 
{     
register_plugin(PLUGIN,VERSION,AUTHOR)
 
g_Status = register_cvar("amx_respawn","1")
 
RegisterHam(Ham_Killed, "player", "Killed_Player", 1);
}
 
public Killed_Player(Victim, Killer)
{
  if(is_user_alive(Victim) && get_pcvar_num(g_Status))
    {
       
set_task(10.0,"Respawn",Victim
)

      return HAM_HANDLED;
  }

  return HAM_IGNORED;
}
 
public Respawn(id)
{
  static team; team = get_user_team(id);

  if(team == 1 || team == 2)
ExecuteHamB(Ham_CS_RoundRespawn,id);

  return;


xPaw 04-05-2009 07:01

Re: Need help for AMX Respawn
 
SnoW, how killed player can be alive? your code is wrong.

PHP Code:

#include <amxmodx>
#include <hamsandwich>

new gCvarEnabled;

public 
plugin_init() {
    
register_plugin"Auto Respawn""1.0""xPaw" );
    
    
gCvarEnabled register_cvar"amx_respawn""1" );
    
    
RegisterHamHam_Killed"player""fwdKilledPlayer");
}

public 
fwdKilledPlayeriVictimiKiller ) {
    if( 
get_pcvar_numgCvarEnabled ) ) {
        
set_task10.0"fnRespawn"iVictim );
        
        return 
HAM_IGNORED;
    }
    
    return 
HAM_IGNORED;
}

public 
fnRespawnid ) {
    static 
iTeam get_user_teamid );
    
    if( !
is_user_alive(id) && (iTeam == || iTeam == 2) )
        
ExecuteHamBHam_CS_RoundRespawnid );
    
    return 
PLUGIN_CONTINUE;



SnoW 04-05-2009 13:37

Re: Need help for AMX Respawn
 
Quote:

Originally Posted by xPaw (Post 797866)
SnoW, how killed player can be alive? your code is wrong.

Just optimized Miron's code and didn't look at the checks, so it left there.
Code:

    if( get_pcvar_num( gCvarEnabled ) ) {
       
set_task( 10.0, "fnRespawn", iVictim
);
       
        return
HAM_HANDLED
;
    }
   
    return
HAM_HANDLED;

Isn't readable. I don't see a reason why you changed my HAM_IGNORED, but anyway.

xPaw 04-05-2009 13:42

Re: Need help for AMX Respawn
 
whoops dunno where i got handled... fixd

ConnorMcLeod 04-05-2009 13:46

Re: Need help for AMX Respawn
 
http://forums.alliedmods.net/showthr...294#post678294


All times are GMT -4. The time now is 02:25.

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