Raised This Month: $ Target: $400
 0% 

Transparent player models when approaching them.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 11-14-2015 , 00:36   Re: Transparent player models when approaching them.
Reply With Quote #7

Quote:
Originally Posted by SHUFEN.jp View Post
Of course If all players is transparent there is a problem for game balance.
So I tried this.
It is "SDKHook_SetTransmit" to become most important.

But I have tried many times, It did not work.
Maybe SourceMOD can not handle "SetTransmit" to only some players.
Need use MetaMOD?

Someone can help us anyway? Thx in advance.

Code:
#pragma semicolon 1
#include <sourcemod> 
#include <sdktools> 
#include <sdkhooks> 
#include <clientprefs>

#include <zombiereloaded>

public Plugin:myinfo =
{
	name = "ZR HIDE PLAYER CS:GO",
	author = "",
	description = "",
	version = "1.0",
	url = ""
};

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


Handle:SecondTimers[MAXPLAYERS+1];

Handle:HidePlayer = INVALID_HANDLE;
char g_hideplayer[MAXPLAYERS+1][8];


//Handle g_hPluginEnabled = INVALID_HANDLE;
//bool g_bPluginEnabled;


public OnPluginStart() 
{
	
	HidePlayer = RegClientCookie("zr hide player", "", CookieAccess_Private);
	
	HookEvent("round_end", EventRoundEnd);
	HookEvent("player_death", Event_OnPlayerDeath, EventHookMode_Pre);
	HookEvent("player_spawn", OnSpawn);
	RegConsoleCmd("sm_hide", Comando);
	RegConsoleCmd("sm_unhide", Comando2);
	
	HookConVarChange(FindConVar("sv_disable_immunity_alpha"), Changed);
	
	SetConVarInt(FindConVar("sv_disable_immunity_alpha"), 1);
	

}


public Changed(Handle:cvar, const String:oldValue[], const String:newValue[])
{
	SetConVarInt(cvar, 1);
}


public OnClientCookiesCached(client)
{
	GetClientCookie(client, HidePlayer, g_hideplayer[client], 8);
}


public Action:OnSpawn(Handle:event, const String:name[], bool:dontBroadcast) 
{
	int client = GetClientOfUserId(GetEventInt(event, "userid"));
	
	if(!ZR_IsClientHuman(client)) return;
	
	
	if(g_hideoptions[client] || (StrEqual(g_hideplayer[client], "true")))
	{
		FakeClientCommand(client, "say  /hide");
	}
}




public Action:Comando(client, args)
{
	
	//reghook[client] = false;
	
	
	if (SecondTimers[client] != INVALID_HANDLE)
	{
		PrintToChat(client, "\x04 \x03[HIDE] \x04You \x05already using \x04Hide Function, Type \x07!unhide \x04for Disable");
		return Plugin_Handled;
	}
	
	if(IsClientInGame(client) && IsPlayerAlive(client) && ZR_IsClientHuman(client))
	{
		g_hide[client] = true;
		g_hideoptions[client] = true;
		
		SecondTimers[client] = CreateTimer(1.5, Pasar, client, TIMER_REPEAT);
		
		FormatEx(g_hideplayer[client], 8, "true" ,g_hideplayer[client]);
		
		PrintToChat(client, "\x04 \x03[HIDE] %s" ,g_hide[client]?" \x04Hide Function is \x02Enabled\x04, Type \x07!unhide \x04for Disable":"\x06Hide Function is \x02Disabled\x06, Type \x07!hide \x06for Enable");
	}
	else
	{
		PrintToChat(client, "\x04 \x03[HIDE] \x04You can use \x07!hide \x04only at Human");
	}
	
	
	return Plugin_Handled;
}

public Action:Comando2(client, args)
{
	g_hide[client] = false;
	g_hideoptions[client] = false;
	
	if (SecondTimers[client] != INVALID_HANDLE)
		KillTimer(SecondTimers[client]);
	SecondTimers[client] = INVALID_HANDLE;	
	
	
	PrintToChat(client, "\x04 \x03[HIDE] \x06Hide Function is \x02Disabled\x06, Type \x07!hide \x06for Enable");
	FormatEx(g_hideplayer[client], 8, "false" ,g_hideplayer[client]);
	
	return Plugin_Handled;
}

public OnClientDisconnect(client)
{
	if(IsFakeClient(client))
		return;
	
	
	
	SetClientCookie(client, HidePlayer, g_hideplayer[client]);
	g_hideplayer[client] = "";
	
	
	
	if (SecondTimers[client] != INVALID_HANDLE)
		KillTimer(SecondTimers[client]);
	SecondTimers[client] = INVALID_HANDLE;
}

public Action:Event_OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
	int client = GetClientOfUserId(GetEventInt(event, "userid"));
	
	if (SecondTimers[client] != INVALID_HANDLE)
	{
		KillTimer(SecondTimers[client]);
		SecondTimers[client] = INVALID_HANDLE;
	}
	
	for(new i = 1; i <= MaxClients; i++)
	{
		g_hide[client] = false;
		g_bHide[client][i] = false;
	}
}

public ZR_OnClientInfected(client, attacker, bool:motherInfect, bool:respawnOverride, bool:respawn)
{
	if (SecondTimers[client] != INVALID_HANDLE)
	{
		KillTimer(SecondTimers[client]);
		SecondTimers[client] = INVALID_HANDLE;
	}
	
	for(new i = 1; i <= MaxClients; i++)
	{
		g_bHide[client][i] = false;
	}
	
	g_hide[client] = false;
}

public Action:Pasar(Handle:timer)
{
	for(int i = 1; i <= MaxClients; i++)
	{
		if(IsClientInGame(i) && IsPlayerAlive(i) && ZR_IsClientHuman(i))
			CheckClientOrg(i);
	}
}

CheckClientOrg(Client) 
{
	decl Float:MedicOrigin[3],Float:TargetOrigin[3], Float:Distance;
	GetClientAbsOrigin(Client, MedicOrigin);
	
	for (new X = 1; X <= MaxClients; X++)
	{
		if(X != Client && IsClientInGame(X) && IsPlayerAlive(X) && ZR_IsClientHuman(X))
		{
			GetClientAbsOrigin(X, TargetOrigin);
			Distance = GetVectorDistance(TargetOrigin,MedicOrigin);
			//PrintToChatAll("test")
			if(Distance <= 100.0)
				g_bHide[Client][X] = true;
			else
			g_bHide[Client][X] = false;
			
		}
	}
}

public OnClientPutInServer(client) 
{
	g_hideoptions[client] = false;
	SDKHook(client, SDKHook_SetTransmit, Hook_SetTransmit);
	
	
	
	
	for(new i = 1; i <= MaxClients; i++)
		g_bHide[client][i] = false; 
}



public Action:EventRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) 
{
	for(int client = 1; client <= MaxClients; client++)
	{
		if(IsClientInGame(client) && !IsFakeClient(client))
		{
			if (SecondTimers[client] != INVALID_HANDLE)
			{
				KillTimer(SecondTimers[client]);
			}
			SecondTimers[client] = INVALID_HANDLE;
		}
	}
}

AdjustAlpha(entity)
{
	SetEntityRenderMode (entity, RENDER_TRANSCOLOR);
	SetEntityRenderColor(entity, 255, 255, 255, 80);
}

public Action:Hook_SetTransmit(client1, client2) 
{ 
	new entity = (client1 != client2 && g_hide[client2] && g_bHide[client1][client2]);
	AdjustAlpha(entity);
	
	return Plugin_Continue; 
}
much of that code was written by me, especially since it has written parts in my language (spanish).


And SDKHook_SetTransmit ofcourse that works well.


Here I leave the original plugin.
PHP Code:
#include <sourcemod> 
#include <sdktools> 
#include <sdkhooks> 
#include <zombiereloaded>

#define PLUGIN_VERSION "1.0" 

new bool:g_bHide[MAXPLAYERS+1][MAXPLAYERS+1]; 
new 
bool:g_hide[MAXPLAYERS+1]; 

public 
Plugin:myinfo =  

    
name "SM Hide Teammates For Proximity"
    
author "Franc1sco franug"
    
description ""
    
version PLUGIN_VERSION
    
url "www.steamcommunity.com/id/franug/" 


public 
OnPluginStart() 

    
CreateTimer(0.5Pasar_TIMER_REPEAT);
    
    
HookEvent("player_death"Event_OnPlayerDeathEventHookMode_Pre);
    
    
RegConsoleCmd("sm_hide"Comando);
}

public 
Action:Comando(clientargs)
{
    
g_hide[client] = !g_hide[client];
    
PrintToChat(client"Hide feature %s" ,g_hide[client]?"Activated":"Desactivated");

    return 
Plugin_Handled;
}

public 
Action:Event_OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    for(new 
1<= MaxClientsi++)
        
g_bHide[client][i] = false
}

public 
ZR_OnClientInfected(clientattackerbool:motherInfectbool:respawnOverridebool:respawn)
{
    for(new 
1<= MaxClientsi++)
        
g_bHide[client][i] = false
}

public 
Action:Pasar(Handle:timer)
{
    for(new 
1<= MaxClientsi++)
        if(
IsClientInGame(i) && IsPlayerAlive(i) && ZR_IsClientHuman(i))
            
CheckClientOrg(i);

}

CheckClientOrg(Client
{
    
decl Float:MedicOrigin[3],Float:TargetOrigin[3], Float:Distance;
    
GetClientAbsOrigin(ClientMedicOrigin);
    for (new 
1<= MaxClientsX++)
    {
        if(
!= Client && IsClientInGame(X) && IsPlayerAlive(X) && ZR_IsClientHuman(X))
        {
            
GetClientAbsOrigin(XTargetOrigin);
            
Distance GetVectorDistance(TargetOrigin,MedicOrigin);
            if(
Distance <= 100.0)
                
g_bHide[Client][X] = true;
            else
                
g_bHide[Client][X] = false;
        }
    }
}

public 
OnClientPutInServer(client

    
g_hide[client] = true;
    for(new 
1<= MaxClientsi++)
        
g_bHide[client][i] = false
        
    
    
SDKHook(clientSDKHook_SetTransmitHook_SetTransmit); 


public 
Action:Hook_SetTransmit(client1client2

    if (
client1 != client2 && g_hide[client2] && g_bHide[client1][client2]) 
        return 
Plugin_Handled;
     
    return 
Plugin_Continue


Quote:
Originally Posted by Bad Cold Man View Post
This is very useful when your teammates when approaching you become transparent but when they are far away the transparency disappears.
I can make it easily (and for free) if someone can help me to test it with a server with people (add me in steam).
Attached Files
File Type: sp Get Plugin or Get Source (zr_hider.sp - 233 views - 2.3 KB)
File Type: smx zr_hider.smx (5.7 KB, 329 views)
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.


Last edited by Franc1sco; 11-14-2015 at 02:51.
Franc1sco is offline
Send a message via MSN to Franc1sco
 



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 12:43.


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