Raised This Month: $ Target: $400
 0% 

Check if player WAS alive when he join spectator team


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mlk27
Veteran Member
Join Date: May 2008
Old 12-24-2008 , 21:42   Check if player WAS alive when he join spectator team
Reply With Quote #1

how do we check if a player join spectator when he was still alive? currently this what i have but the chat message doesnt seem to be printed when i use is_user_alive

Code:
public plugin_init()
{
	// bla bla....
       	register_event( "TeamInfo", "join_team", "a")
}

public join_team()
{
	new id = read_data(1)
	
	static user_team[32]
	read_data(2, user_team, 31);

	if(user_team[0] == 'S' && is_user_alive(id))
	         client_print(0, print_chat, "Someone entered Spectator"
}

Last edited by Mlk27; 01-07-2009 at 17:38.
Mlk27 is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 12-25-2008 , 06:36   Re: Check if player is alive when he join spectator team
Reply With Quote #2

Code:
set_task(0.5, "check_alive", id);
Code:
public check_alive(id)
{
      if(is_user_alive(id))
          //blablaa
}
SnoW is offline
Send a message via MSN to SnoW
Mlk27
Veteran Member
Join Date: May 2008
Old 12-25-2008 , 07:29   Re: Check if player is alive when he join spectator team
Reply With Quote #3

are there other ways beside using set_tsk with repeative flag?
Mlk27 is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 12-25-2008 , 08:52   Re: Check if player is alive when he join spectator team
Reply With Quote #4

Something like this:
PHP Code:
#include <amxmodx>

#define VERSION "1.0"

new bool:g_bAlive33 ];

public 
plugin_init()
{
    
register_plugin"Spectator Was Alive?"VERSION"Dores" );
    
    
register_event"DeathMsg""ev_Death""a" );
    
register_event"ResetHUD""ev_NotOnlyRespawnButThatsWhatINeed""b" );
    
register_event"TeamInfo""ev_TeamInfo""a" );
}

public 
ev_Death()
{
    
g_bAliveread_data) ] = false;
}

public 
ev_NotOnlyRespawnButThatsWhatINeedid )
{
    
g_bAlive bool:( is_user_aliveid ) );
}

public 
ev_TeamInfo()
{
    static 
id id read_data);
    
    static 
team15 ] ; read_data2teamcharsmaxteam ) );
    
    if( 
team] == 'S' && g_bAliveid ] )
    {
        
g_bAliveid ] = false;
        
client_print0print_chat"LoL Moved to Spectator team while being alive!" );
    }

Or instead of hooking ResetHUD use this:
PHP Code:
#include <fakemeta>

public plugin_init()
{
      
register_forwardFM_Spawn"Forward_Spawn");
}

// [...]
public Forward_Spawnent )
{
      static 
szClass32 ] ; peventpev_classnameszClasscharsmaxszClass ) );
      if( !
equalszClass"player" ) )
      {
            return;
      }
      
      
g_bAliveent ] = bool:( is_user_aliveent ) );
}

// Or this:
#include <hamsandwich>

public plugin_init()
{
      
RegisterHamHam_Spawn"player""Forward_PlayerSpawn");
}

public 
Forward_PlayerSpawnid )
{
      
g_bAliveid ] = bool:( is_user_aliveid ) );

__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ

Last edited by Dores; 12-25-2008 at 12:56.
Dores is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-25-2008 , 12:31   Re: Check if player is alive when he join spectator team
Reply With Quote #5

Quote:
Originally Posted by Dores View Post
PHP Code:
    register_event"ResetHUD""ev_Respawn""b" ); 
NO!

Even if it doesn't matter if it is used in this case, you shouldn't name the function "ev_Respawn".
That event is called more than just when a player spawns, and if a new scripter sees that, they will think it is the correct way to hook spawning.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 12-25-2008 , 12:51   Re: Check if player is alive when he join spectator team
Reply With Quote #6

Fixed?

EDIT:
Quote:
Originally Posted by Exolent[jNr] View Post
You could've used "ev_ResetHUD", but that's fine, too.
I know.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ

Last edited by Dores; 12-25-2008 at 12:57.
Dores is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-25-2008 , 12:52   Re: Check if player is alive when he join spectator team
Reply With Quote #7

You could've used "ev_ResetHUD", but that's fine, too.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Mlk27
Veteran Member
Join Date: May 2008
Old 12-25-2008 , 19:32   Re: Check if player is alive when he join spectator team
Reply With Quote #8

@Dores
thanks so much!

@Exolent
yea you are right about ResetHUD cause i've always thought this event is called only when players spawn. any idea why it's called resetHUD by the way? such a horrible name, people might have thought it's used when hud on screen are being reset.
Mlk27 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-25-2008 , 23:14   Re: Check if player is alive when he join spectator team
Reply With Quote #9

It is used when a player's HUD is reset.
The event is called when:
  • player spawns
  • player starts recording a demo
  • sv_restart is change to a value greater than 0
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Mlk27
Veteran Member
Join Date: May 2008
Old 01-07-2009 , 07:26   Re: Check if player is alive when he join spectator team
Reply With Quote #10

im starting to think that this isn't possible =\ when you join spec, you'll definately be killed so hooking DeathMsg event to check if player was still alive before he joins spectator is kinda pointless cause it will always return false there..

Code:
#include <amxmodx> #include <fakemeta> new bool:g_bAlive[33] public plugin_init() {     register_plugin("Bad Frag for Evader", "0.1", "Me")     register_event("TeamInfo", "Event_JoinTeam", "a")     register_event("DeathMsg", "Event_Death", "a")     register_event("ResetHUD", "Event_ResetHud", "b") } public client_disconnect(id) {     if(!is_user_bot(id))     {         g_bAlive[id] = false         log_to_file("evade.log", "client_disconnect: %s", g_bAlive[id] ? "true" : "false")     } } public Event_ResetHud(id) {     if(!is_user_bot(id))     {         g_bAlive[id] = bool:(is_user_alive(id))         log_to_file("evade.log", "Event_ResetHud: %s", g_bAlive[id] ? "true" : "false")     } } public Event_Death() {     new id = read_data(2)           if(!is_user_bot(id))     {         g_bAlive[id] = bool:(is_user_alive(id))         log_to_file("evade.log", "Event_Death: %s", g_bAlive[id] ? "true" : "false")     } } public Event_JoinTeam() {     new id = read_data(1)     static user_team[32]     read_data(2, user_team, charsmax(user_team))     if(user_team[0] == 'S' && g_bAlive[id])     {         g_bAlive[id] = false         log_to_file("evade.log", "Entered spec")     }     return PLUGIN_CONTINUE; }

evade.log
Code:
L 01/07/2009 - 01:21:29: Log file started (file "cstrike\addons\amxmodx\logs\evade.log") (game "cstrike") (amx "1.8.0.3660")
L 01/07/2009 - 01:21:29: Event_ResetHud: false
L 01/07/2009 - 01:21:32: Event_ResetHud: true
L 01/07/2009 - 01:21:40: Event_ResetHud: true
L 01/07/2009 - 01:21:54: Event_Death: false
L 01/07/2009 - 01:22:04: client_disconnect: false
any more ideas?

Last edited by Mlk27; 01-07-2009 at 07:29.
Mlk27 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 09:06.


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