Raised This Month: $ Target: $400
 0% 

tag mismatch 213


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
killergirl
Senior Member
Join Date: Jul 2010
Old 12-28-2010 , 16:36   Re: tag mismatch 213
Reply With Quote #8

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

#include <amxmodx>
#include <fakemeta>
#include <cstrike>

#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")
    
register_clcmd("amx_spectator""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_KICK) )
        return 
PLUGIN_CONTINUE
    
    
//aaa
    
    
if(!(cs_get_user_team(id) == CS_TEAM_SPECTATOR))
    {
        
client_print(idprint_console"You need to be spectator to use the command!")
        return 
PLUGIN_HANDLED
    
}
    else
    {
    
    if(
g_invisible[id][0])
    {
        
client_print(idprint_console"You are visible!")
        
g_invisible[id][0] = 0
        
return PLUGIN_HANDLED
    
}
        
    if( 
is_user_alive(id) )
    {
        
client_print(idprint_console"You need to be dead to use the command!")
        return 
PLUGIN_HANDLED
    
}

    
g_invisible[id][0] = 1
    client_print
(idprint_console"You become invisible!")

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

killergirl is offline
 



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 02:13.


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