Raised This Month: $51 Target: $400
 12% 

[Solved] Hide enemy players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lolz0r
Veteran Member
Join Date: Nov 2010
Location: Balgaria
Old 03-04-2012 , 11:05   [Solved] Hide enemy players
Reply With Quote #1

When a player writes /invis enemy players to be hidden and when it's written again to become visible once again.

Last edited by Lolz0r; 06-15-2012 at 12:28.
Lolz0r is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-04-2012 , 11:32   Re: [REQ] Hide enemy players after command
Reply With Quote #2

PHP Code:
// http://forums.alliedmods.net/showthread.php?t=179691

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

#define COLORCHAT
#if defined COLORCHAT
    #include <colorchat>
#endif

#pragma semicolon    1
#define Version        "1.0.2"

new const g_szPrefix[] = "AMXX";


new 
boolg_bInvisEnabled[33]

    , 
g_iInvisAmount
    
    
g_hAddToFullPack
    
    
g_pInvisMode
;


public 
plugin_init()
{
    
register_plugin("Invisible Players"Version"Drekes");
    
    
register_clcmd("say /invis""CmdInvis");
    
    
/*
        0 = All players
        1 = Teammates
        2 = Enemies
    */
    
g_pInvisMode register_cvar("inv_mode""0");
}


public 
CmdInvis(id)
{
    new 
szPlayers[20];
    switch(
get_pcvar_num(g_pInvisMode))
    {
        case 
0copy(szPlayerscharsmax(szPlayers), "All players");
        case 
1copy(szPlayerscharsmax(szPlayers), "Teammates");
        case 
2copy(szPlayerscharsmax(szPlayers), "Enemy players");
    }

    if(!
g_bInvisEnabled[id])
    {
        if(!
g_hAddToFullPack)
            
g_hAddToFullPack register_forward(FM_AddToFullPack"FwdAddToFullPack"1);
        
        Print(
id"%s are now invisible."szPlayers);
        
g_iInvisAmount++;
    }
    
    else
    {
        if(!--
g_iInvisAmount)
        {
            
unregister_forward(FM_AddToFullPackg_hAddToFullPack1);
            
g_hAddToFullPack 0;
        }

        Print(
id"%s are now visible."szPlayers);
    }
    
    
g_bInvisEnabled[id] = !g_bInvisEnabled[id];

    return 
PLUGIN_HANDLED;
}


public 
FwdAddToFullPack(hEsHandleeiEntiHostiHostflagsiPlayerpSet)
{
    if(
iPlayer && g_bInvisEnabled[iHost])
    {
        new 
iInvisMode get_pcvar_num(g_pInvisMode)
            , 
boolbAreTeamMates
        
;
        
        if(
iInvisMode)
        {
            if(
cs_get_user_team(iHost) == cs_get_user_team(iEnt))
                
bAreTeamMates true;
            
            else
                
bAreTeamMates false;
        }
    
        if(!
iInvisMode
        
|| iInvisMode == && bAreTeamMates
        
|| iInvisMode == && !bAreTeamMates)
        {
            
set_es(hEsHandleES_Origin, { 999999999.0999999999.0999999999.0 });
            
set_es(hEsHandleES_RenderModekRenderTransAlpha);
            
set_es(hEsHandleES_RenderAmt0);
        }
    }
    
    return 
FMRES_IGNORED;
}


Print(
id, const szMessage[], any:...)
{
    static 
szBuffer[192];
    
vformat(szBuffercharsmax(szBuffer), szMessage3);

    
#if defined COLORCHAT
        
ColorChat(idGREEN"[%s]^01 %s"g_szPrefixszBuffer);
    
#else
        
replace_all(szBuffercharsmax(szBuffer), "^01""");
        
replace_all(szBuffercharsmax(szBuffer), "^03""");
        
replace_all(szBuffercharsmax(szBuffer), "^04""");
        
        
client_print(idprint_chat"[%s] %s"g_szPrefixszBuffer);
    
#endif

__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 03-07-2012 at 15:03.
drekes is offline
Send a message via MSN to drekes
Lolz0r
Veteran Member
Join Date: Nov 2010
Location: Balgaria
Old 03-04-2012 , 16:11   Re: [REQ] Hide enemy players after command
Reply With Quote #3

Not working, message is displayed, but they not were hidden.
Lolz0r is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-04-2012 , 20:31   Re: [REQ] Hide enemy players after command
Reply With Quote #4

It works now.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Lolz0r
Veteran Member
Join Date: Nov 2010
Location: Balgaria
Old 03-06-2012 , 16:57   Re: [REQ] Hide enemy players after command
Reply With Quote #5

Yes, it's work, maybe could make a version for team players not enemy, and verison for all playes?

Last edited by Lolz0r; 03-06-2012 at 17:12.
Lolz0r is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-07-2012 , 07:21   Re: [REQ] Hide enemy players after command
Reply With Quote #6

Do you want that to be individual per player or with a cvar for all of them ?
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Lolz0r
Veteran Member
Join Date: Nov 2010
Location: Balgaria
Old 03-07-2012 , 09:45   Re: [REQ] Hide enemy players after command
Reply With Quote #7

Individuals versions for all players and team players hidden.
Lolz0r is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-07-2012 , 12:01   Re: [REQ] Hide enemy players after command
Reply With Quote #8

Edited code above.

You can change the way it works with this define:
Code:
/*	Hiding Options
	0 = All Players
	1 = Teammates
	2 = Enemy Players
*/
#define Hide_Option	0
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Lolz0r
Veteran Member
Join Date: Nov 2010
Location: Balgaria
Old 03-07-2012 , 14:38   Re: [REQ] Hide enemy players after command
Reply With Quote #9

Maybe could do with cvar?
Lolz0r is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-07-2012 , 14:59   Re: [REQ] Hide enemy players after command
Reply With Quote #10

PHP Code:
    static szPlayers[20];
    if(!
szPlayers[0])
#if Hide_Option == 0
        
copy(szPlayerscharsmax(szPlayers), "All players");
#endif
#if Hide_Option == 1
        
copy(szPlayerscharsmax(szPlayers), "Teammates");
#endif
#if Hide_Option == 2
        
copy(szPlayerscharsmax(szPlayers), "Enemy players");
#endif 
1. There's no point in making it static inside of a command handler since it isn't called often enough to need that.
2. You can just declare it as a constant (whether static or not) to save a native call.

Code:
#if Hide_Option == 1     new const szPlayers[] = "Teammates"; #else #if Hide_Option == 2     new const szPlayers[] = "Enemy players"; #else     new const szPlayers[] = "All players"; #endif // Hide_Option == 2 #endif // Hide_Option == 1
__________________
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 09:32.


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