Raised This Month: $32 Target: $400
 8% 

Solved tf2 light control--> l4d2 light control


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AK978
Senior Member
Join Date: Jun 2018
Old 07-24-2021 , 11:33   tf2 light control--> l4d2 light control
Reply With Quote #1

https://forums.alliedmods.net/showthread.php?p=978756

have l4d2 version?

It might be more interesting if there is a trigger function (the player approaches).

Last edited by AK978; 07-27-2021 at 09:04.
AK978 is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-24-2021 , 18:40   Re: tf2 light --> l4d2 light
Reply With Quote #2

I think it works on L4D2 I remember using it once.
__________________
Marttt is offline
AK978
Senior Member
Join Date: Jun 2018
Old 07-26-2021 , 11:15   Re: tf2 light --> l4d2 light
Reply With Quote #3

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

new Handle:timer_handle=INVALID_HANDLE;

public OnPluginStart()
{
}

public OnMapStart()
{
	if (timer_handle != INVALID_HANDLE)
	{
		KillTimer(timer_handle);
		timer_handle = INVALID_HANDLE;
	}
	timer_handle = CreateTimer(2.0, Timer_Light_Change, _,TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}

public OnMapEnd()
{
	if (timer_handle != INVALID_HANDLE)
	{
		KillTimer(timer_handle);
		timer_handle = INVALID_HANDLE;
	}
}

public Action:Timer_Light_Change(Handle:timer)
{
	new ent = -1;
	decl Float: EntPos[3], Float: PlayerPos[3];
	
	while ((ent = FindEntityByClassname(ent, "point_spotlight")) != -1)
	{
		if (IsValidEntity(ent))
		{
			GetEntPropVector(ent, Prop_Send, "m_vecOrigin", EntPos);
			
			for (int i = 1; i <= MaxClients; i++)
			{
				if (IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
				{
					GetClientAbsOrigin(i, PlayerPos);
					new Float: distance = GetVectorDistance(EntPos, PlayerPos);
					if (distance < 100)
					{
						AcceptEntityInput(ent, "LightOff");
						PrintToServer("Light Off Test");
					}
				}
			}
		}
	}
}
TEST FAIL.

Can tell me where I am wrong? Thank.

Last edited by AK978; 07-26-2021 at 11:20.
AK978 is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-26-2021 , 14:10   Re: tf2 light control--> l4d2 light control
Reply With Quote #4

I did some (minimum) changes in the original plugin to be able to compile on SM1.10
But is working fine, check it on c2m5_concert

Type !lights_disco

Btw the original plugin only checks by the "point_spotlight" entity, but in L4D2 you may find others aswell like
  • point_spotlight
  • light
  • light_spot
  • beam_spotlight
  • light_dynamic

Each one with a specific way to turn on/off and change the color.
Attached Files
File Type: sp Get Plugin or Get Source (lightcolors.sp - 146 views - 15.8 KB)
__________________

Last edited by Marttt; 07-26-2021 at 14:10.
Marttt is offline
AK978
Senior Member
Join Date: Jun 2018
Old 07-27-2021 , 09:04   Re: tf2 light control--> l4d2 light control
Reply With Quote #5

thank you.
AK978 is offline
marki89
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 07-28-2021 , 10:04   Re: tf2 light control--> l4d2 light control
Reply With Quote #6

Quote:
Originally Posted by Marttt View Post
I did some (minimum) changes in the original plugin to be able to compile on SM1.10
But is working fine, check it on c2m5_concert

Type !lights_disco

Btw the original plugin only checks by the "point_spotlight" entity, but in L4D2 you may find others aswell like
  • point_spotlight
  • light
  • light_spot
  • beam_spotlight
  • light_dynamic

Each one with a specific way to turn on/off and change the color.
hi Martt, does it also work for the other maps or only for the c2m5_concert?
marki89 is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-28-2021 , 10:21   Re: tf2 light control--> l4d2 light control
Reply With Quote #7

work for maps with "point_spotlight" entity only

I mentioned c2m5 cause in the stage there is a lot of them

to work on all "light" entities has to add support to the other ones aswell (that I listed before)

I started to modify the plugin to work for all but never finished

In theory is just copy and paste the logic with other names
But some entities uses "LightOff"/"LightOn" and others "TurnOff" / "TurnOn" to work.
And to change the color may have different netprops too (specific to each one)

May be incompatible with "Flashlight" plugin (for example) if you include support to all of them.
__________________

Last edited by Marttt; 07-28-2021 at 10:22.
Marttt 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 16:57.


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