AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Rewrite invisible_spectator from Reapi (https://forums.alliedmods.net/showthread.php?t=308228)

tarsisd2 06-11-2018 15:52

Rewrite invisible_spectator from Reapi
 
Hi. can any one make this plugin to work without reapi on normal HLDS server?
i tested it on my test server with reHLDS and it works great, when you type amx_spec, you become invisible, perfect on 5vs5 matches, when the normal plugin would see you like playing in ct ou t, this one becomes invisible!
but i need for my official servers that are running HLDS and i don't want to change it

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <reapi>

#pragma semicolon 1

#if REAPI_VERSION < 52121
    #error You must be update ReAPI to 5.2.0.121 or higher
#endif

// You can comment out something to take off the restriction.
#define LOCK_SAY                    // Don't allows invisible spectator say.
//#define AUTO_INVISIBLE_SPECTATOR    // When someone join to spectator it's make invisible automatically

new HookChain:g_hSV_WriteFullClientUpdate;
new 
bool:g_bPlayerInVisible[MAX_CLIENTS 1];

public 
plugin_init()
{
    
register_plugin("Invisible Spectator""1.0""ReHLDS Team");

    if (!
is_rehlds())
    {
        
pause("ad");
        
set_fail_state("This plugin is not available, ReHLDS required.");
        return;
    }

#if defined LOCK_SAY
    
register_clcmd("say""Host_Say");
    
register_clcmd("say_team""Host_Say");
#endif

#if defined AUTO_INVISIBLE_SPECTATOR
    
register_event("TeamInfo""Event_TeamInfo""a""2=TERRORIST""2=CT""2=SPECTATOR");
#else
    
register_event("TeamInfo""Event_TeamInfo""a""2=TERRORIST""2=CT");
    
register_clcmd("amx_spec""ClCmd_Spectate"ADMIN_KICK"Makes the spectator invisible.");
#endif

    
DisableHookChain((g_hSV_WriteFullClientUpdate RegisterHookChain(RH_SV_WriteFullClientUpdate"SV_WriteFullClientUpdate")));
}

public 
SV_WriteFullClientUpdate(const idbuffer, const receiver)
{
    if (
g_bPlayerInVisible[id])
    {
        
set_key_value(buffer"""");
        
//set_key_value(buffer, "name",  "");
        //set_key_value(buffer, "model", "");
        //set_key_value(buffer, "*sid",  "");
    
}
}

public 
client_putinserver(id)
{
    
g_bPlayerInVisible[id] = false;
}

public 
Event_TeamInfo()
{
    new 
id read_data(1);

#if defined AUTO_INVISIBLE_SPECTATOR
    
new bool:bState g_bPlayerInVisible[id];

    new 
szTeamName[2];
    
read_data(2szTeamNamecharsmax(szTeamName));
    switch (
szTeamName[0])
    {
        case 
'C''T':
        {
            
// Reset the invisible state
            
g_bPlayerInVisible[id] = false;
        }
        case 
'S':
        {
            
g_bPlayerInVisible[id] = true;
        }
    }

    if (
g_bPlayerInVisible[id] != bState)
    {
        if (!
TryDisableHookChain())
        {
            
// let's me enable to hookchain, true optimization
            
EnableHookChain(g_hSV_WriteFullClientUpdate);
        }
#else
    
if (g_bPlayerInVisible[id])
    {
        
// Reset the invisible state
        
g_bPlayerInVisible[id] = false;
#endif
        // Force update user info
        
rh_update_user_info(id);
    }
}

#if defined LOCK_SAY
public Host_Say(id)
{
    if (
g_bPlayerInVisible[id])
    {
        
client_print(idprint_chat"you are invisible, be quiet!");
        return 
PLUGIN_HANDLED;
    }

    return 
PLUGIN_CONTINUE;
}
#endif

#if !defined AUTO_INVISIBLE_SPECTATOR
public ClCmd_Spectate(idlevelcid)
{
    if (!
cmd_access(idlevelcid0))
        return 
PLUGIN_CONTINUE;

    
// Only spectator can be invisible
    
if (get_member(idm_iTeam) != TEAM_SPECTATOR)
    {
        
client_print(idprint_chat"Join spec to become invisible.");
        return 
PLUGIN_HANDLED;
    }

    
g_bPlayerInVisible[id] ^= true;
    
client_print(idprint_chat"you are now %s."g_bPlayerInVisible[id] ? "invisible" "visible");

    if (!
TryDisableHookChain())
    {
        
// let's me enable to hookchain, true optimization
        
EnableHookChain(g_hSV_WriteFullClientUpdate);
    }

    
rh_update_user_info(id);
    return 
PLUGIN_HANDLED;
}
#endif

stock bool:TryDisableHookChain()
{
    
// Make sure that there no one uses invisible spectator
    
new iPlayers[MAX_CLIENTS], iNumnCount;
    
get_players(iPlayersiNum"ch");
    for (new 
0iNum; ++i)
    {
        if (
g_bPlayerInVisible[iPlayers[i]])
            ++
nCount;
    }

    if (
nCount <= 0)
    {
        
DisableHookChain(g_hSV_WriteFullClientUpdate);
        return 
true;
    }

    return 
false;
}

#if defined client_disconnected
public client_disconnected(id)
#else
public client_disconnect(id)
#endif
{
    if (
g_bPlayerInVisible[id])
    {
        
g_bPlayerInVisible[id] = false;
        
TryDisableHookChain();
    }



instinctpt1 06-12-2018 00:57

Re: Rewrite invisible_spectator from Reapi
 
https://forums.alliedmods.net/showthread.php?p=551999

tarsisd2 06-12-2018 02:04

Re: Rewrite invisible_spectator from Reapi
 
Quote:

Originally Posted by instinctpt1 (Post 2596468)

the plugin i'm asking is different from the one you posted, i have that one too, the plugin that i posted is really invisible, you don't appear in any team, neither SPEC, CT or T, you are invisible, perfect for 5x5 servers, because if you use the standard plugin, ppl will know, since there will be 6x5 (1 more in a team)

do you get me?

WaLkMaN 06-13-2018 08:28

Re: Rewrite invisible_spectator from Reapi
 
Try with orpheu version https://forums.alliedmods.net/showpo...9&postcount=76

tarsisd2 06-13-2018 22:07

Re: Rewrite invisible_spectator from Reapi
 
Quote:

Originally Posted by WaLkMaN (Post 2596708)

thanks very much, i found on post 74 of that same page

i'm having problem compiling locally on both 1.8.3 and 1.8.2

i'm getting the error on line 13
error 001: expected token: ";", but found "const"
PHP Code:

const m_iTeam 114

but it seems fine, the ";" is there

full code
PHP Code:

#include < amxmodx >
#include < fakemeta >
#include < orpheu >
#include < orpheu_memory >

#pragma semicolon 1

#define PLUGIN "Invisible Spectator"
#define VERSION "0.3.1"

#define cm(%0)    ( sizeof(%0) - 1 )

const m_iTeam 114;
const 
TEAM_SPECTATOR 3;

new 
g_bPlayerVisible[33 char];

public 
plugin_init()
{
    
register_pluginPLUGINVERSION"ConnorMcLeod" );

    
register_clcmd("say""Host_Say"0);
    
register_clcmd("say_team""Host_Say"1);

    
register_event("TeamInfo""Event_TeamInfo""a""2=TERRORIST""2=CT");

    
OrpheuRegisterHookOrpheuGetFunction("SV_FullClientUpdate"), "OnSV_FullClientUpdate"OrpheuHookPre);

    
register_clcmd("amx_spec""ClCmd_Spectate"ADMIN_BAN);
}

// void SV_FullClientUpdate(client_t * client, sizebuf_t *buf)
public OrpheuHookReturn:OnSV_FullClientUpdateclient /*, buffer */ )
{
    new 
userid OrpheuMemoryGetAtAddress(client"userid");
    new 
id find_player("k"userid);

    if( !
g_bPlayerVisible{id} )
    {
        
Util_SVC_UPDATEUSERINFO(0idget_user_userid(id), "");
        return 
OrpheuSupercede;
    }

    return 
OrpheuIgnored;
}

public 
Host_Say(id)
{
    if( !
g_bPlayerVisible{id} )
    {
        
client_print(idprint_chat"Voce esta invisivel agora, fique quieto !!!");
        return 
PLUGIN_HANDLED_MAIN;
    }
    return 
PLUGIN_CONTINUE;
}

public 
client_putinserver(id)
{
    
g_bPlayerVisible{id} = true;
}

public 
client_connect(id)
{
    
g_bPlayerVisible{id} = true;
}

public 
client_disconnected(id)
{
    
g_bPlayerVisible{id} = true;
}

public 
ClCmd_Spectate(idlevel)
{
    if( 
get_user_flags(id) & level && !is_user_alive(id) && get_pdata_int(idm_iTeam) == TEAM_SPECTATOR )
    {
        if( (
g_bPlayerVisible{id} = !g_bPlayerVisible{id}) )
        {
            
client_print(idprint_chat"Voce esta visivel agora");
            
ResetUserModelInfo(id);
        }
        else
        {
            
client_print(idprint_chat"Voce esta visivel agora");
            
Util_SVC_UPDATEUSERINFO(0idget_user_userid(id), "");
        }
        
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;
}

ResetUserModelInfoid )
{
    static const 
model[] = "model";
    static 
value[200];
    
get_user_info(idmodelvaluecm(value));
    
set_user_info(idmodel"");
    
set_user_info(idmodelvalue);
}

Util_SVC_UPDATEUSERINFO(idclIdclUseridclUserInfo[])
{
    
message_begin(id MSG_ONE MSG_ALLSVC_UPDATEUSERINFO_id);
    
write_byte(clId-1);
    
write_long(clUserid);
    
write_string(clUserInfo);
    
write_long(0);
    
write_long(0);
    
write_long(0);
    
write_long(0);
    
message_end();
}

public 
Event_TeamInfo()
{
    new 
id read_data(1);
    if( !
g_bPlayerVisible{id} )
    {
        
g_bPlayerVisible{id} = true;
        
ResetUserModelInfo(id);
    }




All times are GMT -4. The time now is 02:25.

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