From 50528c2c895d502af74706900cea2984468b4510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20=C3=96hrstr=C3=B6m?= Date: Sun, 20 Aug 2017 14:47:30 +0200 Subject: [PATCH] 0.4 --- .../sourcemod/scripting}/betterwarden.sp | 114 +++++++++++++++--- .../sourcemod/scripting}/cmenu.sp | 0 .../scripting}/include/adminmenu.inc | 0 .../scripting}/include/betterwarden.inc | 18 ++- .../sourcemod/scripting}/include/cmenu.inc | 0 .../scripting}/include/colorvariables.inc | 0 .../sourcemod/scripting}/include/cstrike.inc | 0 .../sourcemod/scripting}/include/menus.inc | 0 .../sourcemod/scripting}/include/sdkhooks.inc | 0 .../sourcemod/scripting}/include/sdktools.inc | 0 .../scripting}/include/smartjaildoors.inc | 0 .../translations}/betterwarden.phrases.txt | 6 + .../sourcemod/translations}/cmenu.phrases.txt | 0 materials/decals/BetterWarden/warden.vmt | 5 + materials/decals/BetterWarden/warden.vtf | Bin 0 -> 5696 bytes 15 files changed, 128 insertions(+), 15 deletions(-) rename {scripting => addons/sourcemod/scripting}/betterwarden.sp (80%) rename {scripting => addons/sourcemod/scripting}/cmenu.sp (100%) rename {scripting => addons/sourcemod/scripting}/include/adminmenu.inc (100%) rename {scripting => addons/sourcemod/scripting}/include/betterwarden.inc (86%) rename {scripting => addons/sourcemod/scripting}/include/cmenu.inc (100%) rename {scripting => addons/sourcemod/scripting}/include/colorvariables.inc (100%) rename {scripting => addons/sourcemod/scripting}/include/cstrike.inc (100%) rename {scripting => addons/sourcemod/scripting}/include/menus.inc (100%) rename {scripting => addons/sourcemod/scripting}/include/sdkhooks.inc (100%) rename {scripting => addons/sourcemod/scripting}/include/sdktools.inc (100%) rename {scripting => addons/sourcemod/scripting}/include/smartjaildoors.inc (100%) rename {translations => addons/sourcemod/translations}/betterwarden.phrases.txt (94%) rename {translations => addons/sourcemod/translations}/cmenu.phrases.txt (100%) create mode 100644 materials/decals/BetterWarden/warden.vmt create mode 100644 materials/decals/BetterWarden/warden.vtf diff --git a/scripting/betterwarden.sp b/addons/sourcemod/scripting/betterwarden.sp similarity index 80% rename from scripting/betterwarden.sp rename to addons/sourcemod/scripting/betterwarden.sp index d112e2d..5240da5 100644 --- a/scripting/betterwarden.sp +++ b/addons/sourcemod/scripting/betterwarden.sp @@ -13,6 +13,7 @@ // Strings char prefix[] = "[{blue}Warden{default}] "; char curWardenStat[MAX_NAME_LENGTH]; +char WardenIconPath[256]; // Integers int curWarden = -1; @@ -21,6 +22,7 @@ int aliveCT = 0; int aliveTerrorists = 0; int totalCT = 0; int totalTerrorists = 0; +int iIcon[MAXPLAYERS +1] = {-1, ...}; // Forward handles Handle gF_OnWardenDeath = null; @@ -34,7 +36,6 @@ Handle gF_OnWardenCreatedByAdmin = null; ConVar cv_version; ConVar cv_EnableNoblock; ConVar cv_noblock; -//ConVar cv_NoblockStandard; ConVar cv_admFlag; ConVar cv_openCells; ConVar cv_wardenTwice; @@ -42,6 +43,8 @@ ConVar cv_StatsHint; ConVar cv_colorR; ConVar cv_colorG; ConVar cv_colorB; +ConVar cv_wardenIcon; +ConVar cv_wardenIconPath; public Plugin myinfo = { name = "[CS:GO] Better Warden", @@ -75,6 +78,8 @@ public void OnPluginStart() { cv_colorR = CreateConVar("sm_warden_color_R", "33", "The Red value of the color the warden gets.", FCVAR_NOTIFY, true, 0.0, true, 255.0); cv_colorG = CreateConVar("sm_warden_color_G", "114", "The Green value of the color the warden gets.", FCVAR_NOTIFY, true, 0.0, true, 255.0); cv_colorB = CreateConVar("sm_warden_color_B", "255", "The Blue value of the color the warden gets.", FCVAR_NOTIFY, true, 0.0, true, 255.0); + cv_wardenIcon = CreateConVar("sm_warden_icon", "1", "Have an icon above the wardens' head?\n1 = Enable.\n0 = Disable.", FCVAR_NOTIFY, true, 0.0, true, 1.0); + cv_wardenIconPath = CreateConVar("sm_warden_icon_path", "decals/BetterWarden/warden", "The path to the icon. Do not include file extensions!", FCVAR_NOTIFY); // Translation stuff LoadTranslations("betterwarden.phrases.txt"); @@ -117,8 +122,10 @@ public void OnPluginStart() { if(cv_StatsHint.IntValue == 1) CreateTimer(0.1, JBToolTip, _, TIMER_REPEAT); - // Fetch 3rd party CVars + // Fetch CVars cv_noblock = FindConVar("mp_solid_teammates"); + cv_wardenIconPath.GetString(WardenIconPath, sizeof(WardenIconPath)); + } ///////////////////////////// @@ -134,6 +141,10 @@ public void OnMapStart() { totalTerrorists = GetTeamClientCount(CS_TEAM_T); RemoveWarden(); + + if(cv_wardenIcon.IntValue == 1) { + PrecacheModelAnyDownload(WardenIconPath); + } } public void OnJoinTeam(Event event, const char[] name, bool dontBroadcast) { @@ -196,6 +207,54 @@ public void OnClientDisconnect(int client) { } +public void CreateIcon(int client) { + if(!IsValidClient(client) || !IsClientWarden(client)) + return; + + if(cv_wardenIcon.IntValue != 1) + return; + + RemoveIcon(client); + + char iTarget[16]; + Format(iTarget, 16, "client%d", client); + DispatchKeyValue(client, "targetname", iTarget); + + iIcon[client] = CreateEntityByName("env_sprite"); + + if (!iIcon[client]) + return; + + char iconbuffer[256]; + + Format(iconbuffer, sizeof(iconbuffer), "materials/%s.vmt", WardenIconPath); + + DispatchKeyValue(iIcon[client], "model", iconbuffer); + DispatchKeyValue(iIcon[client], "classname", "env_sprite"); + DispatchKeyValue(iIcon[client], "spawnflags", "1"); + DispatchKeyValue(iIcon[client], "scale", "0.3"); + DispatchKeyValue(iIcon[client], "rendermode", "1"); + DispatchKeyValue(iIcon[client], "rendercolor", "255 255 255"); + DispatchSpawn(iIcon[client]); + + float origin[3]; + GetClientAbsOrigin(client, origin); + origin[2] = origin[2] + 90.0; + + TeleportEntity(iIcon[client], origin, NULL_VECTOR, NULL_VECTOR); + SetVariantString(iTarget); + AcceptEntityInput(iIcon[client], "SetParent", iIcon[client], iIcon[client], 0); + + SDKHook(iIcon[client], SDKHook_SetTransmit, Should_TransmitW); +} + +public void RemoveIcon(int client) { + if(iIcon[client] > 0 && IsValidEdict(iIcon[client])) { + AcceptEntityInput(iIcon[client], "Kill"); + iIcon[client] = -1; + } +} + ///////////////////////////// // ACTIONS // @@ -263,11 +322,11 @@ public Action Command_Retire(int client, int args) { public Action Command_Unwarden(int client, int args) { if(!IsClientWardenAdmin(client)) { - CPrintToChat(client, "%s {red}%t", prefix, "Not Admin"); + CReplyToCommand(client, "%s {red}%t", prefix, "Not Admin"); return Plugin_Handled; } if(!WardenExists()) { - CPrintToChat(client, "%s %t", prefix, "No Warden Alive"); + CReplyToCommand(client, "%s %t", prefix, "No Warden Alive"); return Plugin_Handled; } @@ -302,19 +361,19 @@ public Action Command_OpenCells(int client, int args) { public Action Command_SetWarden(int client, int args) { if(!IsClientWardenAdmin(client)) { - CPrintToChat(client, "%s {red}%t", prefix, "Not Admin"); + CReplyToCommand(client, "%s {red}%t", prefix, "Not Admin"); return Plugin_Handled; } if(!IsValidClient(client, false, true)) { - CPrintToChat(client, "%s %t", prefix, "Invalid Client"); + CReplyToCommand(client, "%s %t", prefix, "Invalid Client"); return Plugin_Handled; } if(WardenExists()) { - CPrintToChat(client, "%s %t", prefix, "Warden Exists"); + CReplyToCommand(client, "%s %t", prefix, "Warden Exists"); return Plugin_Handled; } if(args < 1) { - ReplyToCommand(client, "[SM] Usage: sm_ip <#userid|name>"); + CReplyToCommand(client, "[SM] Usage: sm_ip <#userid|name>"); return Plugin_Handled; } @@ -331,15 +390,17 @@ public Action Command_SetWarden(int client, int args) { } for(int usr = 0; usr < target_count; usr++) { + if(GetClientTeam(target_list[usr]) != CS_TEAM_CT) { + CReplyToCommand(client, "%s %t", prefix, "Client must be CT"); + break; + } SetWarden(target_list[usr]); - ReplyToCommand(client, "%s %t", prefix, "Warden Set", target_list[usr]); + CReplyToCommand(client, "%s %t", prefix, "Warden Set", target_list[usr]); Call_StartForward(gF_OnWardenCreatedByAdmin); Call_PushCell(client); Call_PushCell(target_list[usr]); Call_Finish(); - - return Plugin_Handled; } return Plugin_Handled; @@ -378,11 +439,27 @@ public Action OnPlayerChat(int client, char[] command, int args) { if(message[0] == '/' || message[0] == '@' || IsChatTrigger()) return Plugin_Handled; - CPrintToChatAll("{bluegrey}[Warden] {team2}%N : %s", client, message); + CPrintToChatAll("{bluegrey}[Warden] {team2}%N :{default} %s", client, message); return Plugin_Handled; } +public Action Should_TransmitW(int entity, int client) { + char m_ModelName[PLATFORM_MAX_PATH]; + char iconbuffer[256]; + + Format(iconbuffer, sizeof(iconbuffer), "materials/%s.vmt", WardenIconPath); + + GetEntPropString(entity, Prop_Data, "m_ModelName", m_ModelName, sizeof(m_ModelName)); + + if (StrEqual(iconbuffer, m_ModelName)) + { + return Plugin_Continue; + } + + return Plugin_Handled; +} + ///////////////////////////// // TIMERS // @@ -449,14 +526,23 @@ public int Native_SetWarden(Handle plugin, int numParams) { curWardenStat = name; CreateTimer(1.0, RenderColor, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); + CreateIcon(client); + return true; } public int Native_RemoveWarden(Handle plugin, int numParams) { + if(!WardenExists()) + return false; + if(cv_wardenTwice.IntValue == 1) { prevWarden = curWarden; } + + RemoveIcon(GetCurrentWarden()); + curWarden = -1; curWardenStat = "None.."; + return true; } public int Native_GetCurrentWarden(Handle plugin, int numParams) { @@ -467,8 +553,8 @@ public int Native_IsClientWardenAdmin(Handle plugin, int numParams) { char admflag[32]; GetConVarString(cv_admFlag, admflag, sizeof(admflag)); - if(IsValidClient(client)) { - if(GetUserFlagBits(client) & ReadFlagString(admflag) == ReadFlagString(admflag)) + if(IsValidClient(client, false, true)) { + if((GetUserFlagBits(client) & ReadFlagString(admflag) == ReadFlagString(admflag)) || GetUserFlagBits(client) & ADMFLAG_ROOT) return true; } diff --git a/scripting/cmenu.sp b/addons/sourcemod/scripting/cmenu.sp similarity index 100% rename from scripting/cmenu.sp rename to addons/sourcemod/scripting/cmenu.sp diff --git a/scripting/include/adminmenu.inc b/addons/sourcemod/scripting/include/adminmenu.inc similarity index 100% rename from scripting/include/adminmenu.inc rename to addons/sourcemod/scripting/include/adminmenu.inc diff --git a/scripting/include/betterwarden.inc b/addons/sourcemod/scripting/include/betterwarden.inc similarity index 86% rename from scripting/include/betterwarden.inc rename to addons/sourcemod/scripting/include/betterwarden.inc index ea7ad9b..5026d78 100644 --- a/scripting/include/betterwarden.inc +++ b/addons/sourcemod/scripting/include/betterwarden.inc @@ -8,7 +8,7 @@ #endinput #endif #define bwardenincluded -#define VERSION "0.3.5c" +#define VERSION "0.4" #define a ADMFLAG_RESERVATION #define b ADMFLAG_GENERIC @@ -143,4 +143,20 @@ stock bool IsValidClient(int client, bool bAllowBots = false, bool bAllowDead = return false; } return true; +} + +/** +* Precaches and prepares models for download. Used for icons! +* +* @param path to model +*/ +stock void PrecacheModelAnyDownload(char[] sModel) +{ + char sBuffer[256]; + Format(sBuffer, sizeof(sBuffer), "materials/%s.vmt", sModel); + AddFileToDownloadsTable(sBuffer); + PrecacheModel(sBuffer, true); + Format(sBuffer, sizeof(sBuffer), "materials/%s.vtf", sModel); + AddFileToDownloadsTable(sBuffer); + PrecacheModel(sBuffer, true); } \ No newline at end of file diff --git a/scripting/include/cmenu.inc b/addons/sourcemod/scripting/include/cmenu.inc similarity index 100% rename from scripting/include/cmenu.inc rename to addons/sourcemod/scripting/include/cmenu.inc diff --git a/scripting/include/colorvariables.inc b/addons/sourcemod/scripting/include/colorvariables.inc similarity index 100% rename from scripting/include/colorvariables.inc rename to addons/sourcemod/scripting/include/colorvariables.inc diff --git a/scripting/include/cstrike.inc b/addons/sourcemod/scripting/include/cstrike.inc similarity index 100% rename from scripting/include/cstrike.inc rename to addons/sourcemod/scripting/include/cstrike.inc diff --git a/scripting/include/menus.inc b/addons/sourcemod/scripting/include/menus.inc similarity index 100% rename from scripting/include/menus.inc rename to addons/sourcemod/scripting/include/menus.inc diff --git a/scripting/include/sdkhooks.inc b/addons/sourcemod/scripting/include/sdkhooks.inc similarity index 100% rename from scripting/include/sdkhooks.inc rename to addons/sourcemod/scripting/include/sdkhooks.inc diff --git a/scripting/include/sdktools.inc b/addons/sourcemod/scripting/include/sdktools.inc similarity index 100% rename from scripting/include/sdktools.inc rename to addons/sourcemod/scripting/include/sdktools.inc diff --git a/scripting/include/smartjaildoors.inc b/addons/sourcemod/scripting/include/smartjaildoors.inc similarity index 100% rename from scripting/include/smartjaildoors.inc rename to addons/sourcemod/scripting/include/smartjaildoors.inc diff --git a/translations/betterwarden.phrases.txt b/addons/sourcemod/translations/betterwarden.phrases.txt similarity index 94% rename from translations/betterwarden.phrases.txt rename to addons/sourcemod/translations/betterwarden.phrases.txt index 580c2f2..bc57f2e 100644 --- a/translations/betterwarden.phrases.txt +++ b/addons/sourcemod/translations/betterwarden.phrases.txt @@ -113,4 +113,10 @@ "en" "You have made {1} the warden for this round!" "sv" "Du har satt {1} som warden för denna runda!" } + + "Client must be CT" + { + "en" "Client is not a Counter-Terrorist." + "sv" "Användaren är inte en Counter-Terrorist." + } } \ No newline at end of file diff --git a/translations/cmenu.phrases.txt b/addons/sourcemod/translations/cmenu.phrases.txt similarity index 100% rename from translations/cmenu.phrases.txt rename to addons/sourcemod/translations/cmenu.phrases.txt diff --git a/materials/decals/BetterWarden/warden.vmt b/materials/decals/BetterWarden/warden.vmt new file mode 100644 index 0000000..707b2e4 --- /dev/null +++ b/materials/decals/BetterWarden/warden.vmt @@ -0,0 +1,5 @@ +"UnlitGeneric" +{ + "$basetexture" "decals/BetterWarden/warden" + "$translucent" 1 +} diff --git a/materials/decals/BetterWarden/warden.vtf b/materials/decals/BetterWarden/warden.vtf new file mode 100644 index 0000000000000000000000000000000000000000..c08a5a0187180acd08d8a5b5e223ea1db5f72b70 GIT binary patch literal 5696 zcmcgw4OCOt9luFL6C@H&7YefugQgmXMKXiRHiEc%iZYkYJd)GLG?JY;aeVA_5FJc# z(suQua(Wi)+8}tkxe9)*XJF4!N45&niPJM1p=AZy`7x`AJ4gcNKdVtd5NFQ`uBZ=fb78nBezK|8C2c!-a%JChjmC*x(>4w&bPEr3 zd@Z?m`Ys%3#+`V-rrv7qNbc1H((r_F5U^CM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