Raised This Month: $ Target: $400
 0% 

Hide Plugin automatic unhide


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hyeNa
New Member
Join Date: Oct 2013
Old 10-04-2013 , 16:25   Hide Plugin automatic unhide
Reply With Quote #1

Hiya.
I've got a question/request:

Is it possible to implement an automatic unhide function into this hide plugin?

PHP Code:
#include <sourcemod> 
#include <sdktools> 
#include <sdkhooks> 

#define PLUGIN_VERSION "1.0.0" 

public Plugin:myinfo =  

    
name "Simple Hide Command"
    
author "exvel"
    
description "Hides all players on the server for only one user who typed !hide"
    
version PLUGIN_VERSION
    
url "www.sourcemod.net" 


new 
bool:g_bHide[MAXPLAYERS+1] = {false,...}; 

public 
OnPluginStart() 

    
RegConsoleCmd("hide"Command_Hide); 
    
RegConsoleCmd("unhide"Command_Unhide); 


public 
Action:Command_Hide(clientargs

    
g_bHide[client] = true
    return 
Plugin_Handled


public 
Action:Command_Unhide(clientargs

    
g_bHide[client] = false
    return 
Plugin_Handled


public 
OnClientPutInServer(client

    
g_bHide[client] = false
    
SDKHook(clientSDKHook_SetTransmitHook_SetTransmit); 


public 
Action:Hook_SetTransmit(entityclient

    if (
client != entity && (entity <= MaxClients) && g_bHide[client]) 
        return 
Plugin_Handled
     
    return 
Plugin_Continue

Because when you have !hide enabled and switch to spectator, it gets really buggy until you !unhide.
Thank you in advance

Last edited by hyeNa; 10-04-2013 at 16:26.
hyeNa is offline
Glite
Senior Member
Join Date: Sep 2011
Location: Ukraine
Old 10-04-2013 , 18:10   Re: Hide Plugin automatic unhide
Reply With Quote #2

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdkhooks>

new bool:g_hide[MAXPLAYERS+1];
new 
g_iWeaponOwner[2048];
new 
g_bLateLoad;

public 
Plugin:myinfo =
{
    
name "Hide Players",
    
author "0wn3r",
    
description "Adds commands to show/hide other players.",
    
version "1.0",
    
url ""
};

public 
OnPluginStart()
{  
    
RegConsoleCmd("sm_hide"HideCommand);

    if (
g_bLateLoad)
    {
        for (new 
1<= MaxClientsi++)
        {
            if (
IsClientConnected(i) && IsClientInGame(i))
            {
                
OnClientPutInServer(i);
            }
        }
    }
}

public 
APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max)
{
    
g_bLateLoad late;
    return 
APLRes_Success;
}


public 
OnClientPutInServer(client)

    
g_hide[client] = false
    
SDKHook(clientSDKHook_SetTransmitHook_SetTransmit);
    
SDKHook(clientSDKHook_WeaponEquipHook_WeaponEquip);
    
SDKHook(clientSDKHook_WeaponDropHook_WeaponDrop);
}

public 
OnClientDisconnect_Post(client)
{
    
g_hide[client] = false;
    
SDKUnhook(clientSDKHook_SetTransmitHook_SetTransmit);
    
SDKUnhook(clientSDKHook_WeaponEquipHook_WeaponEquip);
    
SDKUnhook(clientSDKHook_WeaponDropHook_WeaponDrop);

}

public 
OnEntityCreated(entity, const String:classname[])
{
    if (
entity MaxClients && entity 2048)
    {
        
g_iWeaponOwner[entity] = 0;
    }
}

public 
OnEntityDestroyed(entity)
{
    if (
entity MaxClients && entity 2048)
    {
        
g_iWeaponOwner[entity] = 0;
    }
}

public 
Hook_WeaponEquip(clientweapon)
{
    if (
weapon MaxClients && weapon 2048)
    {
        
g_iWeaponOwner[weapon] = client;
        
SDKHook(weaponSDKHook_SetTransmitHook_SetTransmitWeapon);
    }
}

public 
Hook_WeaponDrop(clientweapon)
{
    if (
weapon MaxClients && weapon 2048)
    {
        
g_iWeaponOwner[weapon] = 0;
        
SDKUnhook(weaponSDKHook_SetTransmitHook_SetTransmitWeapon);
    }
}

public 
Action:Hook_SetTransmit(entityclient

    return (
g_hide[client] && IsPlayerAlive(client) && client != entity && (entity <= MaxClients)) ? Plugin_Handled Plugin_Continue;
}

public 
Action:Hook_SetTransmitWeapon(entityclient

    return (
g_hide[client] && IsPlayerAlive(client) && g_iWeaponOwner[entity] && g_iWeaponOwner[entity] != client) ? Plugin_Handled Plugin_Continue;
}

public 
Action:HideCommand(clientargs)
{
    
g_hide[client] = !g_hide[client];
    
    return 
Plugin_Handled;

Alive check and weapons hide.

Last edited by Glite; 10-04-2013 at 18:11.
Glite is offline
hyeNa
New Member
Join Date: Oct 2013
Old 10-06-2013 , 04:19   Re: Hide Plugin automatic unhide
Reply With Quote #3

Thank you very much. It works like a charm. Is it possible to add a echo/message that says that players are now hidden?

Quick edit: Is there a server cvar or plugin that disables the annoying 'Only 1 team change allowed'? I tried mp_teamoverride and other team limiting stuff, but it's not working. :/

Last edited by hyeNa; 10-06-2013 at 04:31.
hyeNa is offline
Glite
Senior Member
Join Date: Sep 2011
Location: Ukraine
Old 10-06-2013 , 08:23   Re: Hide Plugin automatic unhide
Reply With Quote #4

PHP Code:
public Action:HideCommand(clientargs)
{
    
g_hide[client] = !g_hide[client];
    if(
g_hide[client])
    {
        
PrintToChat(client"People are now hidden.");
    }
    else
    {
        
PrintToChat(client"People are now visible.");
    }
    
    return 
Plugin_Handled;

Glite is offline
hyeNa
New Member
Join Date: Oct 2013
Old 10-06-2013 , 11:26   Re: Hide Plugin automatic unhide
Reply With Quote #5

Thank you very much again. Works perfectly.
hyeNa 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 23:33.


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