Jump to content

Подсветка цветом игрока в зависимости от здоровья (ColoredHealth)


Райан

Recommended Posts

  • Администратор

На этот раз дяде Нику не повезло, я все тесты проделывал на нем.

Скрытый текст

20200831062308_1.jpg20200831062123_1.jpg20200831062137_1.jpg20200831062139_1.jpg20200831062157_1.jpg

Этот плагин устанавливает цвет и прозрачность игроков в зависимости от его здоровья. Кстати, этот плагин полностью настраивается с помощью конфиг файла.

Это особенно полезно для серверов Сражения на реализме.

Компиляция была произведена на SM 1.10.0.6492

Установка:

  • Скомпилировать .sp файл и поместить плагин в /left4dead2/addons/sourcemod/plugins
  • Либо уже готовый .smx файл поместить в /left4dead2/addons/sourcemod/plugins
  • Файл coloredhealth.txt поместить в /left4dead2/addons/sourcemod/configs
  • Сделать рестарт сервера.

 

coloredhealth.smx coloredhealth.sp coloredhealth.txt

Ненавижу загружать новые файлы, но обожаю обновлять версии.

Link to comment
Share on other sites

  • 3 weeks later...
  • Администратор
2 часа назад, BLOODY BLADE сказал:

Новый синтаксисcoloredhealth.sp

Из всего пака который ты скинул, только этот вызывает Warning 241 при компиляции. Остальные скомпилировались идеально.

Ненавижу загружать новые файлы, но обожаю обновлять версии.

Link to comment
Share on other sites

10 часов назад, Ryancoolround сказал:

Из всего пака который ты скинул, только этот вызывает Warning 241 при компиляции. Остальные скомпилировались идеально.

Это для sm 1.10 нормально. Предупреждение просто оповещает на будущее, что "структуры перечислений на основе массивов удалены в sm 1.11".

Link to comment
Share on other sites

  • Администратор
Только что, BLOODY BLADE сказал:

для sm 1.10 нормально

Я как понял, в 1.11 оно не будет появляться, верно?

Ненавижу загружать новые файлы, но обожаю обновлять версии.

Link to comment
Share on other sites

3 минуты назад, Ryancoolround сказал:

Я как понял, в 1.11 оно не будет появляться, верно?

На sm 1.11, при компиляции данного плагина компилятор выдаст предупреждения и ошибки:

Цитата

//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// coloredhealth.sp
//
// D:\Games\Left4Dead2_Repack_by_Pioneer\scripting\sm&mm\sourcemod-1.11.0-git6624-windows\addons\sourcemod\scripting\coloredhealth.sp(9) : error 153: Array-based enum structs have been removed. See https://wiki.alliedmods.net/SourcePawn_Transitional_Syntax#Enum_Structs
// D:\Games\Left4Dead2_Repack_by_Pioneer\scripting\sm&mm\sourcemod-1.11.0-git6624-windows\addons\sourcemod\scripting\coloredhealth.sp(17) : error 009: invalid array size (negative, zero or out of bounds)
// D:\Games\Left4Dead2_Repack_by_Pioneer\scripting\sm&mm\sourcemod-1.11.0-git6624-windows\addons\sourcemod\scripting\coloredhealth.sp(64) : warning 213: tag mismatch (expected "int", got "float")
// D:\Games\Left4Dead2_Repack_by_Pioneer\scripting\sm&mm\sourcemod-1.11.0-git6624-windows\addons\sourcemod\scripting\coloredhealth.sp(68) : error 032: array index out of bounds (variable "g_levelData")
// D:\Games\Left4Dead2_Repack_by_Pioneer\scripting\sm&mm\sourcemod-1.11.0-git6624-windows\addons\sourcemod\scripting\coloredhealth.sp(69) : error 032: array index out of bounds (variable "g_levelData")
// D:\Games\Left4Dead2_Repack_by_Pioneer\scripting\sm&mm\sourcemod-1.11.0-git6624-windows\addons\sourcemod\scripting\coloredhealth.sp(70) : error 032: array index out of bounds (variable "g_levelData")
// D:\Games\Left4Dead2_Repack_by_Pioneer\scripting\sm&mm\sourcemod-1.11.0-git6624-windows\addons\sourcemod\scripting\coloredhealth.sp(71) : error 032: array index out of bounds (variable "g_levelData")
// D:\Games\Left4Dead2_Repack_by_Pioneer\scripting\sm&mm\sourcemod-1.11.0-git6624-windows\addons\sourcemod\scripting\coloredhealth.sp(92) : error 032: array index out of bounds (variable "g_levelData")
//
// 7 Errors.
//
// Compilation Time: 1,59 sec
// ----------------------------------------

Press enter to exit ...

 

 

Link to comment
Share on other sites

  • 1 year later...
  • Администратор

Все же, есть решение скомпилировать этот плагин на актуальной стабильной версии SM, но так, что бы не было ни ошибок ни предупреждений. Это чисто для перфекционизма. Если что, вот код:

#include <sourcemod>

#define PL_VERSION "1.0.1-stable"

enum LevelAttributes
{
	Float:BiggerThan, 
	R, 
	G, 
	B, 
	A
}

new Handle:g_hConfigFilePath;
new g_levelData[64][LevelAttributes];

public Plugin:myinfo = 
{
	name = "ColoredHealth", 
	author = "alongub", 
	description = "Sets the color and transparency of players based on health.", 
	version = PL_VERSION, 
	url = "http://steamcommunity.com/id/alon"
};

public OnPluginStart()
{
	g_hConfigFilePath = 
	CreateConVar(
		"sm_coloredhealth_configfilepath", 
		"configs/coloredhealth.txt", 
		"Path, relative to root sourcemod directory, to colored health levels config file.", 
		_);
	
	HookEvent("player_hurt", Event_PlayerHurt);
	HookEvent("player_spawn", Event_PlayerSpawn);
	
	AutoExecConfig();
}

public OnConfigsExecuted()
{
	new Handle:kv = CreateKeyValues("levels");
	
	decl String:path[128];
	GetConVarString(g_hConfigFilePath, path, sizeof(path));
	
	BuildPath(Path_SM, path, sizeof(path), path);
	
	FileToKeyValues(kv, path);
	
	if (!KvGotoFirstSubKey(kv))
		return;
	
	decl String:sectionName[4];
	
	do
	{
		KvGetSectionName(kv, sectionName, sizeof(sectionName));
		new count = StringToInt(sectionName);
		
		new r = 255;
		new g = 255;
		new b = 255;
		new a = 255;
		
		g_levelData[count][BiggerThan] = KvGetFloat(kv, "biggerThan");
		
		KvGetColor(kv, "rgba", r, g, b, a);
		
		g_levelData[count][R] = r;
		g_levelData[count][G] = g;
		g_levelData[count][B] = b;
		g_levelData[count][A] = a;
		
	} while (KvGotoNextKey(kv));
	
	CloseHandle(kv)
}

public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	SetEntityRenderMode(client, RenderMode:RENDER_GLOW);
}

public Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	new Float:health = GetEventFloat(event, "health") / GetEntProp(client, Prop_Data, "m_iMaxHealth");
	
	for (new i = 0; i < sizeof(g_levelData); i++)
	{
		if (health >= g_levelData[i][BiggerThan])
		{
			SetEntityRenderColor(client, g_levelData[i][R], g_levelData[i][G], g_levelData[i][B], g_levelData[i][A]);
			return;
		}
	}
} 

 

Ненавижу загружать новые файлы, но обожаю обновлять версии.

Link to comment
Share on other sites

  • 7 months later...
  • Администратор
В 23.11.2021 в 11:05, Райан сказал:

Все же, есть решение скомпилировать этот плагин на актуальной стабильной версии SM

Снова перестал компилироваться на SourceMod 1.11. Что то связано с данным массивом:

enum LevelAttributes
{
	Float:BiggerThan, 
	R, 
	G, 
	B, 
	A
}

 

Ненавижу загружать новые файлы, но обожаю обновлять версии.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...