Raised This Month: $28 Target: $400
 7% 

[TF2] Client Side Fog (Halp)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tetradox
Junior Member
Join Date: Aug 2016
Old 02-14-2017 , 23:38   [TF2] Client Side Fog (Halp)
Reply With Quote #1

Hello, this can be quite simple, but i just can't get it to work, so it would we kind if you guys could help me

Well i was searching to see if someone made this before, so i found this thread "https://forums.alliedmods.net/showthread.php?t=205788&page=2" to see how they made it, but using the code provided seems to not work, when the fog is deactivated in a client somehow the screen freezes for them.

The next code is almost the same, but i edited some lines to get it to compile and it's the one i tested:

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

new Fogindex;
new bool:ShowFog[MAXPLAYERS+1];

public OnPluginStart()
{
    RegAdminCmd("sm_fogoff", fogoff, ADMFLAG_SLAY, "");
    RegAdminCmd("sm_fogon", fogon, ADMFLAG_SLAY, "");
}

public OnMapStart()
{
	Fog_Check();
}

public OnClientPutInServer(client)
{
	SDKHook(client, SDKHook_SetTransmit, Hook_SetTransmit);
	ShowFog[client] = false;
}

Fog_Check()
{
	new index; 
	index = FindEntityByClassname(-1, "env_fog_controller");
	if(index != -1)
		Fogindex = index;
	else
	{
		Fogindex = CreateEntityByName("env_fog_controller");
		DispatchSpawn(Fogindex);
	}
	if(Fogindex != -1) 
	{
		DispatchKeyValue(Fogindex, "fogenable", "1");
		DispatchKeyValue(Fogindex, "fogblend", "0");
		DispatchKeyValue(Fogindex, "fogcolor", "0 0 0");
		DispatchKeyValue(Fogindex, "fogcolor2", "0 0 0");
		DispatchKeyValueFloat(Fogindex, "fogstart", 0.0);
		DispatchKeyValueFloat(Fogindex, "fogend", 400.0);
		DispatchKeyValueFloat(Fogindex, "fogmaxdensity", 1.0);
	}
	AcceptEntityInput(Fogindex, "TurnOff");
	SDKHook(Fogindex, SDKHook_SetTransmit, Hook_SetTransmit);
}

public Action:fogoff(client, args)
{
	AcceptEntityInput(Fogindex, "TurnOff");
	CreateTimer(0.1, Fogchange, client);
}    

public Action:fogon(client, args)
{
	AcceptEntityInput(Fogindex, "TurnOn");
	CreateTimer(0.1, Fogchange, client);
}

public Action:Fogchange(Handle:timer, any:client)
{
	if(ShowFog[client] == true)
		ShowFog[client] = false;
	else
		ShowFog[client] = true;
}

public Action:Hook_SetTransmit(entity, client) 
{
	if(GetEdictFlags(Fogindex) & FL_EDICT_ALWAYS)
		SetEdictFlags(Fogindex, GetEdictFlags(Fogindex) ^ FL_EDICT_ALWAYS);
	if(!ShowFog[client])
		return Plugin_Handled;
	return Plugin_Continue;
}

Last edited by Tetradox; 02-19-2017 at 13:40. Reason: Solved :3
Tetradox is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 02-16-2017 , 16:03   Re: [TF2] Client Side Fog (Halp)
Reply With Quote #2

Mabye sendproxy the enable netprop tk the clients?
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 02-17-2017 , 08:50   Re: [TF2] Client Side Fog (Halp)
Reply With Quote #3

Try the SetFogController input instead of SetTransmit.
__________________
Chdata is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 02-19-2017 , 06:09   Re: [TF2] Client Side Fog (Halp)
Reply With Quote #4

Ah yes,
You can have multiple fog controllers and set the activator to use that controller.
Pretty sure the TF2 HELLTOWER map does this to change fog on individual clients when going to the underworld.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 02-19-2017 , 07:39   Re: [TF2] Client Side Fog (Halp)
Reply With Quote #5

Have a look at this -> https://github.com/KissLick/TeamGame...runkenRambo.sp
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
Tetradox
Junior Member
Join Date: Aug 2016
Old 02-19-2017 , 13:39   Re: [TF2] Client Side Fog (Halp)
Reply With Quote #6

Thank you!, AcceptEntityInput with SetFogController did the job for me (I used SetVariantString so now the clients see the map fog when the custom fog is disabled on them)

Last edited by Tetradox; 02-19-2017 at 13:49.
Tetradox is offline
Reply


Thread Tools
Display Modes

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 19:36.


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