AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   [Solved] Hide enemy players (https://forums.alliedmods.net/showthread.php?t=179691)

Lolz0r 03-04-2012 11:05

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

drekes 03-04-2012 11:32

Re: [REQ] Hide enemy players after command
 
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



Lolz0r 03-04-2012 16:11

Re: [REQ] Hide enemy players after command
 
Not working, message is displayed, but they not were hidden.

drekes 03-04-2012 20:31

Re: [REQ] Hide enemy players after command
 
It works now.

Lolz0r 03-06-2012 16:57

Re: [REQ] Hide enemy players after command
 
Yes, it's work, maybe could make a version for team players not enemy, and verison for all playes?

drekes 03-07-2012 07:21

Re: [REQ] Hide enemy players after command
 
Do you want that to be individual per player or with a cvar for all of them ?

Lolz0r 03-07-2012 09:45

Re: [REQ] Hide enemy players after command
 
Individuals versions for all players and team players hidden. :)

drekes 03-07-2012 12:01

Re: [REQ] Hide enemy players after command
 
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


Lolz0r 03-07-2012 14:38

Re: [REQ] Hide enemy players after command
 
Maybe could do with cvar?

Exolent[jNr] 03-07-2012 14:59

Re: [REQ] Hide enemy players after command
 
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


All times are GMT -4. The time now is 14:17.

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