Raised This Month: $ Target: $400
 0% 

Invisible spectator send command into client console


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
oglop
Member
Join Date: Jul 2010
Location: Czech Republic
Old 06-02-2011 , 07:00   Invisible spectator send command into client console
Reply With Quote #1

Hello, I'm using this plugin Invisible spectator and there is a command you have to type to become "invisible" amx_spectate.
And it's not comforable, I think there could be a way to make it automatic.
I mean, when you join as spectator(ADMIN_KICK) the amx_spectate will be written in console.

Thank you.

PHP Code:
/* http://forums.alliedmods.net/showthread.php?p=551999#post551999
*
* Changelog
* added cvar amx_inv_dead_percent <value>
*
*/

#include <amxmodx>
#include <fakemeta>

#if AMXX_VERSION_NUM < 180
    #define charsmax(%1)    sizeof(%1) - 1
#endif

#define MAX_PLAYERS    32

#define DEAD_FLAG   (1<<0)

#define OFFSET_TEAM     114

enum {
     
CS_TEAM_UNASSIGNED,
     
CS_TEAM_T,
     
CS_TEAM_CT,
     
CS_TEAM_SPECTATOR
}

new 
bool:g_roundend
new pcvar_percent
new g_invisible[MAX_PLAYERS+1][2]
new 
gmsgScoreAttribgmsgTeamInfo

public plugin_init() {
    
register_plugin("Invisible Spectator""0.2""ConnorMcLeod")

    
pcvar_percent register_cvar("amx_inv_dead_percent""40")

    
register_clcmd("amx_spectate""make_invis")

    
gmsgScoreAttrib get_user_msgid("ScoreAttrib")
    
gmsgTeamInfo get_user_msgid("TeamInfo")

    
register_messagegmsgScoreAttrib"msg_ScoreAttrib")
    
register_messagegmsgTeamInfo"msg_TeamInfo")

    
register_event("HLTV""eNewRound""a""1=0""2=0")
    
register_logevent("eRoundEnd"2"1=Round_End")
    
register_event("ResetHUD""eResetHUD""be")
    
register_event("DeathMsg""eDeathMsg""a")
}

public 
make_invis(id) {
    if( !(
get_user_flags(id) & ADMIN_RCON) )
        return 
PLUGIN_CONTINUE

    
if(g_invisible[id][0])
    {
        
client_print(idprint_console"You're not invisible anymore")
        
g_invisible[id][0] = 0
        
return PLUGIN_HANDLED
    
}
        
    if( 
is_user_alive(id) )
    {
        
client_print(idprint_console"You have to be dead first to be an invisible spectator !")
        return 
PLUGIN_HANDLED
    
}

    
g_invisible[id][0] = 1
    client_print
(idprint_console"You're now an invisible spectator")

    new 
team get_pdata_int(idOFFSET_TEAM)
    if( 
CS_TEAM_T <= team <= CS_TEAM_CT )
    {
        
g_invisible[id][1] = team
        set_pdata_int
(idOFFSET_TEAMCS_TEAM_SPECTATOR)
    }
    else
    {
        new 
players[MAX_PLAYERS], tnumctnum
        get_players
(playerstnum"e""TERRORIST")
        
get_players(playersctnum"e""CT")
        
g_invisible[id][1] = ctnum tnum 2
    
}

    
send_ScoreAttrib(id0)

    new 
teamname[12]
    switch( 
g_invisible[id][1] )
    {
        case 
1:formatex(teamnamecharsmax(teamname), "TERRORIST")
        case 
2:formatex(teamnamecharsmax(teamname), "CT")
    }
    
send_TeamInfo(idteamname)

    return 
PLUGIN_HANDLED
}

public 
eDeathMsg() {
    if(
g_roundend)
        return

    new 
players[MAX_PLAYERS], deadinumplayerFloat:percent get_pcvar_float(pcvar_percent) / 100.0
    get_players
(playersdead"bh")
    
get_players(playersinum"h")

    if( 
float(dead) / float(inum) < percent
        return

    for(new 
iinumi++)
    {
        
player players[i]
        if( 
g_invisible[player][0] )
            
send_ScoreAttrib(playerDEAD_FLAG)
    }
}

public 
eNewRound() {
    
g_roundend false
    
new players[MAX_PLAYERS], inumplayer
    get_players
(playersinum)
    for(new 
iinumi++)
    {
        
player players[i]
        if( 
g_invisible[player][0] )
            
send_ScoreAttrib(player0)
    }
}

public 
eRoundEnd() {
    
g_roundend true
    
new players[MAX_PLAYERS], inumplayer
    get_players
(playersinum)
    for(new 
iinumi++)
    {
        
player players[i]
        if( 
g_invisible[player][0] )
            
send_ScoreAttrib(playerDEAD_FLAG)
    }
}

public 
eResetHUD(id) {
    if( 
g_invisible[id][0] )
        
g_invisible[id][0] = 0
}

// Doesn't seem to work so set flag to 0 at NewRound event.
public msg_ScoreAttrib(msg_typemsg_desttarget) {
    if(!
g_invisible[get_msg_arg_int(1)][0])
        return 
PLUGIN_CONTINUE

    
new flags get_msg_arg_int(2)
    if(
flags DEAD_FLAG)
        
set_msg_arg_int(20flags & ~DEAD_FLAG)

    return 
PLUGIN_CONTINUE 
}

public 
msg_TeamInfo(msg_typemsg_desttarget) {
    new 
id get_msg_arg_int(1)
    if(!
g_invisible[id][0])
        return 
PLUGIN_CONTINUE

    
new teamname[12]
    
get_msg_arg_string(2teamnamecharsmax(teamname))
    if( 
g_invisible[id][1] == CS_TEAM_T && strcmp(teamname"TERRORIST") != )
        
set_msg_arg_string(2"TERRORIST")
    else if( 
g_invisible[id][1] == CS_TEAM_CT && strcmp(teamname"CT") != )
        
set_msg_arg_string(2"CT")

    return 
PLUGIN_CONTINUE
}

send_ScoreAttrib(idflags)
{
    
message_begin(MSG_ALLgmsgScoreAttrib_0)
    
write_byte(id)
    
write_byte(flags)
    
message_end()
}

send_TeamInfo(idteamname[])
{
    
message_begin(MSG_ALLgmsgTeamInfo_0)
    
write_byte(id)
    
write_string(teamname)
    
message_end()

oglop is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 06-02-2011 , 07:10   Re: Invisible spectator send command into client console
Reply With Quote #2

Try this:

PHP Code:
/* http://forums.alliedmods.net/showthread.php?p=551999#post551999
*
* Changelog
* added cvar amx_inv_dead_percent <value>
*
*/

#include <amxmodx>
#include <fakemeta>

#if AMXX_VERSION_NUM < 180
    #define charsmax(%1)    sizeof(%1) - 1
#endif

#define MAX_PLAYERS    32

#define DEAD_FLAG   (1<<0)

#define OFFSET_TEAM     114

enum {
     
CS_TEAM_UNASSIGNED,
     
CS_TEAM_T,
     
CS_TEAM_CT,
     
CS_TEAM_SPECTATOR
}

new 
bool:g_roundend
new pcvar_percent
new g_invisible[MAX_PLAYERS+1][2]
new 
gmsgScoreAttribgmsgTeamInfo

public plugin_init() {
    
register_plugin("Invisible Spectator""0.2""ConnorMcLeod")

    
pcvar_percent register_cvar("amx_inv_dead_percent""40")

    
register_clcmd("amx_spectate""make_invis")

    
gmsgScoreAttrib get_user_msgid("ScoreAttrib")
    
gmsgTeamInfo get_user_msgid("TeamInfo")

    
register_messagegmsgScoreAttrib"msg_ScoreAttrib")
    
register_messagegmsgTeamInfo"msg_TeamInfo")

    
register_event("HLTV""eNewRound""a""1=0""2=0")
    
register_logevent("eRoundEnd"2"1=Round_End")
    
register_event("ResetHUD""eResetHUD""be")
    
register_event("DeathMsg""eDeathMsg""a")
    
register_event("TeamInfo""Event_TeamInfo""a")
}

public 
Event_TeamInfo()
{
    new 
id read_data(1)
    new 
szTeam[2]
    
    
read_data(2szTeamcharsmax(szTeam))

    switch(
szTeam[0])
    {
        case 
'S':
        {
            
make_invis(id)
            
// Player joined SPECTATOR team
        
}
         }
}

public 
make_invis(id) {
    if( !(
get_user_flags(id) & ADMIN_RCON) )
        return 
PLUGIN_CONTINUE

    
if(g_invisible[id][0])
    {
        
client_print(idprint_console"You're not invisible anymore")
        
g_invisible[id][0] = 0
        
return PLUGIN_HANDLED
    
}
        
    if( 
is_user_alive(id) )
    {
        
client_print(idprint_console"You have to be dead first to be an invisible spectator !")
        return 
PLUGIN_HANDLED
    
}

    
g_invisible[id][0] = 1
    client_print
(idprint_console"You're now an invisible spectator")

    new 
team get_pdata_int(idOFFSET_TEAM)
    if( 
CS_TEAM_T <= team <= CS_TEAM_CT )
    {
        
g_invisible[id][1] = team
        set_pdata_int
(idOFFSET_TEAMCS_TEAM_SPECTATOR)
    }
    else
    {
        new 
players[MAX_PLAYERS], tnumctnum
        get_players
(playerstnum"e""TERRORIST")
        
get_players(playersctnum"e""CT")
        
g_invisible[id][1] = ctnum tnum 2
    
}

    
send_ScoreAttrib(id0)

    new 
teamname[12]
    switch( 
g_invisible[id][1] )
    {
        case 
1:formatex(teamnamecharsmax(teamname), "TERRORIST")
        case 
2:formatex(teamnamecharsmax(teamname), "CT")
    }
    
send_TeamInfo(idteamname)

    return 
PLUGIN_HANDLED
}

public 
eDeathMsg() {
    if(
g_roundend)
        return

    new 
players[MAX_PLAYERS], deadinumplayerFloat:percent get_pcvar_float(pcvar_percent) / 100.0
    get_players
(playersdead"bh")
    
get_players(playersinum"h")

    if( 
float(dead) / float(inum) < percent
        return

    for(new 
iinumi++)
    {
        
player players[i]
        if( 
g_invisible[player][0] )
            
send_ScoreAttrib(playerDEAD_FLAG)
    }
}

public 
eNewRound() {
    
g_roundend false
    
new players[MAX_PLAYERS], inumplayer
    get_players
(playersinum)
    for(new 
iinumi++)
    {
        
player players[i]
        if( 
g_invisible[player][0] )
            
send_ScoreAttrib(player0)
    }
}

public 
eRoundEnd() {
    
g_roundend true
    
new players[MAX_PLAYERS], inumplayer
    get_players
(playersinum)
    for(new 
iinumi++)
    {
        
player players[i]
        if( 
g_invisible[player][0] )
            
send_ScoreAttrib(playerDEAD_FLAG)
    }
}

public 
eResetHUD(id) {
    if( 
g_invisible[id][0] )
        
g_invisible[id][0] = 0
}

// Doesn't seem to work so set flag to 0 at NewRound event.
public msg_ScoreAttrib(msg_typemsg_desttarget) {
    if(!
g_invisible[get_msg_arg_int(1)][0])
        return 
PLUGIN_CONTINUE

    
new flags get_msg_arg_int(2)
    if(
flags DEAD_FLAG)
        
set_msg_arg_int(20flags & ~DEAD_FLAG)

    return 
PLUGIN_CONTINUE 
}

public 
msg_TeamInfo(msg_typemsg_desttarget) {
    new 
id get_msg_arg_int(1)
    if(!
g_invisible[id][0])
        return 
PLUGIN_CONTINUE

    
new teamname[12]
    
get_msg_arg_string(2teamnamecharsmax(teamname))
    if( 
g_invisible[id][1] == CS_TEAM_T && strcmp(teamname"TERRORIST") != )
        
set_msg_arg_string(2"TERRORIST")
    else if( 
g_invisible[id][1] == CS_TEAM_CT && strcmp(teamname"CT") != )
        
set_msg_arg_string(2"CT")

    return 
PLUGIN_CONTINUE
}

send_ScoreAttrib(idflags)
{
    
message_begin(MSG_ALLgmsgScoreAttrib_0)
    
write_byte(id)
    
write_byte(flags)
    
message_end()
}

send_TeamInfo(idteamname[])
{
    
message_begin(MSG_ALLgmsgTeamInfo_0)
    
write_byte(id)
    
write_string(teamname)
    
message_end()

__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
oglop
Member
Join Date: Jul 2010
Location: Czech Republic
Old 06-02-2011 , 08:01   Re: Invisible spectator send command into client console
Reply With Quote #3

Great thank you (I think this plugin can only show you as CT while invisibe, but never mind)
oglop 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 00:11.


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