Администратор Райан Posted August 31, 2020 Администратор Share Posted August 31, 2020 На этот раз дяде Нику не повезло, я все тесты проделывал на нем. Скрытый текст Этот плагин устанавливает цвет и прозрачность игроков в зависимости от его здоровья. Кстати, этот плагин полностью настраивается с помощью конфиг файла. Это особенно полезно для серверов Сражения на реализме. Компиляция была произведена на 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 0 Quote Ненавижу загружать новые файлы, но обожаю обновлять версии. Link to comment Share on other sites More sharing options...
BLOODY BLADE Posted September 15, 2020 Share Posted September 15, 2020 Новый синтаксис: coloredhealth.sp 1 Quote Link to comment Share on other sites More sharing options...
Администратор Райан Posted September 16, 2020 Author Администратор Share Posted September 16, 2020 2 часа назад, BLOODY BLADE сказал: Новый синтаксис: coloredhealth.sp Из всего пака который ты скинул, только этот вызывает Warning 241 при компиляции. Остальные скомпилировались идеально. 0 Quote Ненавижу загружать новые файлы, но обожаю обновлять версии. Link to comment Share on other sites More sharing options...
BLOODY BLADE Posted September 16, 2020 Share Posted September 16, 2020 10 часов назад, Ryancoolround сказал: Из всего пака который ты скинул, только этот вызывает Warning 241 при компиляции. Остальные скомпилировались идеально. Это для sm 1.10 нормально. Предупреждение просто оповещает на будущее, что "структуры перечислений на основе массивов удалены в sm 1.11". 1 Quote Link to comment Share on other sites More sharing options...
Администратор Райан Posted September 16, 2020 Author Администратор Share Posted September 16, 2020 Только что, BLOODY BLADE сказал: для sm 1.10 нормально Я как понял, в 1.11 оно не будет появляться, верно? 0 Quote Ненавижу загружать новые файлы, но обожаю обновлять версии. Link to comment Share on other sites More sharing options...
BLOODY BLADE Posted September 16, 2020 Share Posted September 16, 2020 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 ... 1 Quote Link to comment Share on other sites More sharing options...
Администратор Райан Posted November 23, 2021 Author Администратор Share Posted November 23, 2021 Все же, есть решение скомпилировать этот плагин на актуальной стабильной версии 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; } } } 0 Quote Ненавижу загружать новые файлы, но обожаю обновлять версии. Link to comment Share on other sites More sharing options...
Администратор Райан Posted July 19, 2022 Author Администратор Share Posted July 19, 2022 В 23.11.2021 в 11:05, Райан сказал: Все же, есть решение скомпилировать этот плагин на актуальной стабильной версии SM Снова перестал компилироваться на SourceMod 1.11. Что то связано с данным массивом: enum LevelAttributes { Float:BiggerThan, R, G, B, A } 0 Quote Ненавижу загружать новые файлы, но обожаю обновлять версии. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.