Thread: [Solved] Items are glow
View Single Post
Visual77
Veteran Member
Join Date: Jan 2009
Old 06-13-2017 , 05:23   Re: [L4D2]Items are glow
Reply With Quote #29

Silvers, how do you make items in the footlocker glow? Here's my code but no success.

Code:
public Action Event_PlayerUse(Event event, const char[] name, bool dontBroadcast)
{
	int entity = event.GetInt("targetid");
	if (entity <= 0 || entity >= 2048 || !IsValidEntity(entity)) return;

	char buffer[32];
	GetEntPropString(entity, Prop_Data, "m_iName", buffer, sizeof(buffer));

	if (StrContains(buffer, "button_locker", false) != -1)
	{
		float lockerPos[3];
		GetEntPropVector(entity, Prop_Send, "m_vecOrigin", lockerPos);

		DataPack data;
		CreateDataTimer(1.0, timerDelay, data, TIMER_FLAG_NO_MAPCHANGE); 

		data.WriteFloat(lockerPos[0]);
		data.WriteFloat(lockerPos[1]);
		data.WriteFloat(lockerPos[2]);
	}
}

public Action timerDelay(Handle timer, DataPack data)
{
	float lockerPos[3], itemPos[3];
	int ent = -1;
	char items[32];

	data.Reset();

	lockerPos[0] = data.ReadFloat();
	lockerPos[1] = data.ReadFloat();
	lockerPos[2] = data.ReadFloat();

	while ((ent = FindEntityByClassname(ent, "prop_dynamic")) != -1)
	{	
		GetEntPropVector(ent, Prop_Send, "m_vecOrigin", itemPos);
		GetEntPropString(ent, Prop_Data, "m_iName", items, sizeof(items));

		if (StrContains(items, "molotov", false) != -1 
		|| StrContains(items, "pipebomb", false) != -1
		|| StrContains(items, "vomitjar", false) != -1)
		{
			if (GetVectorDistance(lockerPos, itemPos) < 150.0)
			{
				PrintToChatAll("setting glow on %s, pos %f", items, itemPos);
				SetGlowItem(ent, GetColor(cvarGlowColor_throwables), 2);
			}
		}

		if (StrContains(items, "adrenaline", false) != -1 
		|| StrContains(items, "pills", false) != -1
		|| StrContains(items, "first_aid", false) != -1)
		{
			if (GetVectorDistance(lockerPos, itemPos) < 150.0)
			{
				PrintToChatAll("setting glow on %s, pos %f", items, itemPos);
				SetGlowItem(ent, GetColor(cvarGlowColor_health), 2);
			}
		}
	}
}
Result https://steamuserimages-a.akamaihd.n...D9810DCDFAF80/

Edit: It only works if you don't put glow on the actual footlocker. And items must be of glowtype 3.
https://steamuserimages-a.akamaihd.n...CA5D62BEE4993/

Plus it seems like there are 2 weapon_pain_pills_spawn and the rest are prop_pills. You can't get nothing perfect in this game.

Another idea could be changing glowtype 3 to 0 as the foot locker is opend and then set glowtype 3 on its items.

Last edited by Visual77; 06-13-2017 at 05:52.
Visual77 is offline