├── README.md ├── plugins └── kento_dmgtext.smx ├── translations └── kento.dmgtext.phrases.txt └── scripting └── kento_dmgtext.sp /README.md: -------------------------------------------------------------------------------- 1 | # CSGO-Damage-Text 2 | https://forums.alliedmods.net/showthread.php?t=303760 3 | -------------------------------------------------------------------------------- /plugins/kento_dmgtext.smx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogeraabbccdd/CSGO-Damage-Text/HEAD/plugins/kento_dmgtext.smx -------------------------------------------------------------------------------- /translations/kento.dmgtext.phrases.txt: -------------------------------------------------------------------------------- 1 | //********************************************** Valid Colors ******************************************************** 2 | // {NORMAL}, {DARKRED}, {PINK}, {YELLOW}, {GREEN}, {LIGHTGREEN}, {RED}, {GRAY}, {BLUE}, {DARKBLUE}, {PURPLE}, {ORANGE} * 3 | //********************************************************************************************************************** 4 | // http://i.imgur.com/q2wb8Cu.png * 5 | //{NORMAL} = x01 | {DARKRED} = x02 | {PINK} = x03 | {GREEN} = x04 | {YELLOW} = x09 | {LIGHTGREEN} = x06 | {RED} = x07 * 6 | //{GRAY} = x08 | {BLUE} = x0B | {DARKBLUE} = x0C | {PURPLE} = x0E| {ORANGE} = x10 * 7 | //********************************************************************************************************************** 8 | "Phrases" 9 | { 10 | //******************* PrintToChat ******************* 11 | "Say Normal Size" 12 | { 13 | "#format" "" 14 | "en" "{GREEN}[DMGTEXT] {NORMAL}Please type a number in chat to set normal damage text size. Type {PINK}!cancel{NORMAL} to cancel. {NORMAL}Default: 5" 15 | "zho" "{GREEN}[DMGTEXT] {NORMAL}請在對話框輸入普通傷害數字大小, 輸入{PINK}!cancel{NORMAL}取消, {NORMAL}預設: 5" 16 | } 17 | 18 | "Say Kill Size" 19 | { 20 | "#format" "" 21 | "en" "{GREEN}[DMGTEXT] {NORMAL}Please type a number in chat to set kill damage text size. Type {PINK}!cancel{NORMAL} to cancel. {NORMAL}Default: 8" 22 | "zho" "{GREEN}[DMGTEXT] {NORMAL}請在對話框輸入擊殺傷害數字大小, 輸入{PINK}!cancel{NORMAL}取消, {NORMAL}預設: 8" 23 | } 24 | 25 | "Say Normal Color" 26 | { 27 | "#format" "" 28 | "en" "{GREEN}[DMGTEXT] {NORMAL}Please type a rgb color in chat to set normal damage text color. Type {PINK}!cancel{NORMAL} to cancel. {NORMAL}Default: 255 255 255" 29 | "zho" "{GREEN}[DMGTEXT] {NORMAL}請在對話框輸入普通傷害數字RGB, 輸入{PINK}!cancel{NORMAL}取消, {NORMAL}預設: 255 255 255" 30 | } 31 | 32 | "Say Kill Color" 33 | { 34 | "#format" "" 35 | "en" "{GREEN}[DMGTEXT] {NORMAL}Please type a rgb color in chat to set kill damage text color. Type {PINK}!cancel{NORMAL} to cancel. {NORMAL}Default: 255 0 0" 36 | "zho" "{GREEN}[DMGTEXT] {NORMAL}請在對話框輸入擊殺傷害數字RGB, 輸入{PINK}!cancel{NORMAL}取消, {NORMAL}預設: 255 0 0" 37 | } 38 | 39 | "Say Cancel" 40 | { 41 | "#format" "" 42 | "en" "{GREEN}[DMGTEXT] {RED}Settings has been canceled." 43 | "zho" "{GREEN}[DMGTEXT] {RED}設定已取消." 44 | } 45 | 46 | "Normal Size Is" 47 | { 48 | "#format" "{1:s}" 49 | "en" "{GREEN}[DMGTEXT] {LIGHTGREEN}Your normal damage text size is {1}." 50 | "zho" "{GREEN}[DMGTEXT] {LIGHTGREEN}你的普通傷害數字大小為{1}." 51 | } 52 | 53 | "Kill Size Is" 54 | { 55 | "#format" "{1:s}" 56 | "en" "{GREEN}[DMGTEXT] {LIGHTGREEN}Your kill damage text size is {1}." 57 | "zho" "{GREEN}[DMGTEXT] {LIGHTGREEN}你的擊殺傷害數字大小為{1}." 58 | } 59 | 60 | "Normal RGB Color Is" 61 | { 62 | "#format" "{1:s}" 63 | "en" "{GREEN}[DMGTEXT] {LIGHTGREEN}Your normal damage text color is {1}." 64 | "zho" "{GREEN}[DMGTEXT] {LIGHTGREEN}你的普通傷害數字顏色為{1}." 65 | } 66 | 67 | "Kill RGB Color Is" 68 | { 69 | "#format" "{1:s}" 70 | "en" "{GREEN}[DMGTEXT] {LIGHTGREEN}Your kill damage text color is {1}." 71 | "zho" "{GREEN}[DMGTEXT] {LIGHTGREEN}你的擊殺傷害數字顏色為{1}." 72 | } 73 | 74 | //*********************** Menu *********************** 75 | 76 | "Menu Settings Title" 77 | { 78 | "#format" "" 79 | "en" "Damage Text Settings" 80 | "zho" "傷害數字設定" 81 | } 82 | 83 | "Menu Settings Show" 84 | { 85 | "#format" "{1:s},{2:s},{3:s},{4:s}" 86 | "en" "Your Settings:\nShow damage text\nNormal Size:{1} RGB:{2}\nKill Size:{3} RGB:{4}" 87 | "zho" "目前設定:\n顯示傷害數字\n普通大小:{1} RGB:{2}\n擊殺大小:{3} RGB:{4}" 88 | } 89 | 90 | "Menu Settings Hide" 91 | { 92 | "#format" "{1:s},{2:s},{3:s},{4:s}" 93 | "en" "Your Settings:\nHide damage text\nNormal Size:{1} RGB:{2}\nKill Size:{3} RGB:{4}" 94 | "zho" "目前設定:\n隱藏傷害數字\n普通大小:{1} RGB:{2}\n擊殺大小:{3} RGB:{4}" 95 | } 96 | 97 | "Menu Hide Text" 98 | { 99 | "#format" "" 100 | "en" "Hide damage text" 101 | "zho" "隱藏傷害數字" 102 | } 103 | 104 | "Menu Show Text" 105 | { 106 | "#format" "" 107 | "en" "Show damage text" 108 | "zho" "顯示傷害數字" 109 | } 110 | 111 | "Menu Normal Size" 112 | { 113 | "#format" "" 114 | "en" "Change normal damage text size" 115 | "zho" "改變普通傷害數字大小" 116 | } 117 | 118 | "Menu Kill Size" 119 | { 120 | "#format" "" 121 | "en" "Change kill damage text size" 122 | "zho" "改變擊殺傷害數字大小" 123 | } 124 | 125 | "Menu Noraml Color" 126 | { 127 | "#format" "" 128 | "en" "Change normal damage text color" 129 | "zho" "改變普通傷害數字顏色" 130 | } 131 | 132 | "Menu Kill Color" 133 | { 134 | "#format" "" 135 | "en" "Change kill damage text color" 136 | "zho" "改變擊殺傷害數字顏色" 137 | } 138 | } -------------------------------------------------------------------------------- /scripting/kento_dmgtext.sp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #pragma newdecls required 9 | 10 | Handle Cookie_Show, Cookie_Size_Normal, Cookie_Size_Kill, Cookie_Color_Normal, Cookie_Color_Kill; 11 | bool text_show[MAXPLAYERS + 1]; 12 | char text_size_normal[MAXPLAYERS + 1][64]; 13 | char text_size_kill[MAXPLAYERS + 1][64]; 14 | char text_color_normal[MAXPLAYERS + 1][64]; 15 | char text_color_kill[MAXPLAYERS + 1][64]; 16 | int SayingSettings[MAXPLAYERS + 1]; 17 | 18 | ConVar Cvar_Flag; 19 | char Flag[AdminFlags_TOTAL]; 20 | ConVar Cvar_Size; 21 | int MaxSize; 22 | 23 | Handle db = INVALID_HANDLE; 24 | 25 | public Plugin myinfo = 26 | { 27 | name = "[CS:GO] Damage Text", 28 | author = "Kento, Kxnrl, IT-KiLLER, root88", 29 | version = "1.6", 30 | description = "Show damage text like RPG games :D", 31 | url = "http://steamcommunity.com/id/kentomatoryoshika/" 32 | }; 33 | 34 | public void OnPluginStart() 35 | { 36 | HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Post); 37 | 38 | RegConsoleCmd("sm_dmgtext", Command_DmgText, "Damage Text Settings"); 39 | RegConsoleCmd("say", Command_Say); 40 | 41 | Cookie_Show = RegClientCookie("dmgtext_show", "Show damage text or not", CookieAccess_Private); 42 | Cookie_Size_Normal = RegClientCookie("dmgtext_size_normal", "Normal Damage text size", CookieAccess_Private); 43 | Cookie_Size_Kill = RegClientCookie("dmgtext_size_kill", "Kill damage text size", CookieAccess_Private); 44 | Cookie_Color_Normal = RegClientCookie("dmgtext_normal_color", "Noraml damage text rgb", CookieAccess_Private); 45 | Cookie_Color_Kill = RegClientCookie("dmgtext_kill_color", "Kill damage text rgb", CookieAccess_Private); 46 | 47 | LoadTranslations("kento.dmgtext.phrases"); 48 | 49 | Cvar_Flag = CreateConVar("sm_dmgtext_flag", "", "Flag to use damage text, blank = disabled"); 50 | Cvar_Flag.AddChangeHook(OnConVarChanged); 51 | 52 | Cvar_Size = CreateConVar("sm_dmgtext_size", "20", "Max size of damage text, 0 = disabled"); 53 | Cvar_Size.AddChangeHook(OnConVarChanged); 54 | 55 | AutoExecConfig(true, "kento_dmgtext"); 56 | 57 | for(int i = 1; i <= MaxClients; i++) 58 | { 59 | if(IsValidClient(i)) 60 | { 61 | SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage); 62 | if(!IsFakeClient(i)) OnClientCookiesCached(i); 63 | } 64 | } 65 | } 66 | 67 | public void OnMapStart() 68 | { 69 | char[] error = new char[PLATFORM_MAX_PATH]; 70 | db = SQL_Connect("clientprefs", true, error, PLATFORM_MAX_PATH); 71 | 72 | if (!LibraryExists("clientprefs") || db == INVALID_HANDLE) SetFailState("clientpref error: %s", error); 73 | } 74 | 75 | public void OnClientPutInServer(int client) 76 | { 77 | if(IsValidClient(client) && !IsFakeClient(client)) 78 | { 79 | SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); 80 | if (!IsFakeClient(client)) OnClientCookiesCached(client); 81 | } 82 | } 83 | 84 | public void OnClientCookiesCached(int client) 85 | { 86 | SayingSettings[client] = 0; 87 | 88 | char scookie[64]; 89 | GetClientCookie(client, Cookie_Show, scookie, sizeof(scookie)); 90 | if(!StrEqual(scookie, "")) 91 | { 92 | text_show[client] = view_as(StringToInt(scookie)); 93 | } 94 | else text_show[client] = true; 95 | 96 | GetClientCookie(client, Cookie_Size_Normal, scookie, sizeof(scookie)); 97 | if(!StrEqual(scookie, "")) 98 | { 99 | text_size_normal[client] = scookie; 100 | } 101 | else text_size_normal[client] = "5"; 102 | 103 | GetClientCookie(client, Cookie_Size_Kill, scookie, sizeof(scookie)); 104 | if(!StrEqual(scookie, "")) 105 | { 106 | text_size_kill[client] = scookie; 107 | } 108 | else text_size_kill[client] = "8"; 109 | 110 | GetClientCookie(client, Cookie_Color_Normal, scookie, sizeof(scookie)); 111 | if(!StrEqual(scookie, "")) 112 | { 113 | text_color_normal[client] = scookie; 114 | } 115 | else text_color_normal[client] = "255 255 255" 116 | 117 | GetClientCookie(client, Cookie_Color_Kill, scookie, sizeof(scookie)); 118 | if(!StrEqual(scookie, "")) 119 | { 120 | text_color_kill[client] = scookie; 121 | } 122 | else text_color_kill[client] = "255 0 0" 123 | } 124 | 125 | public void OnConfigsExecuted() 126 | { 127 | Cvar_Flag.GetString(Flag, sizeof(Flag)); 128 | MaxSize = Cvar_Size.IntValue; 129 | } 130 | 131 | public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue) 132 | { 133 | if (convar == Cvar_Flag) Cvar_Flag.GetString(Flag, sizeof(Flag)); 134 | 135 | else if (convar == Cvar_Size) 136 | { 137 | MaxSize = Cvar_Size.IntValue; 138 | 139 | if(MaxSize > 0) 140 | { 141 | char[] query = new char[512]; 142 | FormatEx(query, 512, "UPDATE `sm_cookie_cache` SET `value`='%d' WHERE EXISTS( SELECT * FROM sm_cookies WHERE sm_cookie_cache.cookie_id = sm_cookies.id AND sm_cookies.name = 'dmgtext_size_normal') AND `value` > '%d';", MaxSize, MaxSize); 143 | SQL_TQuery(db, ClientPref_PurgeCallback, query); 144 | 145 | char[] query2 = new char[512]; 146 | FormatEx(query2, 512, "UPDATE `sm_cookie_cache` SET `value`='%d' WHERE EXISTS( SELECT * FROM sm_cookies WHERE sm_cookie_cache.cookie_id = sm_cookies.id AND sm_cookies.name = 'dmgtext_size_kill') AND `value` > '%d';", MaxSize, MaxSize); 147 | SQL_TQuery(db, ClientPref_PurgeCallback, query2); 148 | } 149 | } 150 | } 151 | 152 | public void ClientPref_PurgeCallback(Handle owner, Handle handle, const char[] error, any data) 153 | { 154 | if (SQL_GetAffectedRows(owner)) 155 | { 156 | char sMaxSize[8]; 157 | IntToString(MaxSize, sMaxSize, sizeof(sMaxSize)); 158 | 159 | for(int i = 1; i <= MaxClients; i++) 160 | { 161 | if(IsValidClient(i) && !IsFakeClient(i)) 162 | { 163 | if(StringToInt(text_size_normal[i]) > MaxSize) text_size_normal[i] = sMaxSize; 164 | if(StringToInt(text_size_kill[i]) > MaxSize) text_size_kill[i] = sMaxSize; 165 | } 166 | } 167 | } 168 | } 169 | 170 | public void OnEntityCreated(int entity, const char[] classname) 171 | { 172 | if(StrEqual(classname, "func_physbox", false) || StrEqual(classname, "func_physbox_multiplayer", false) || StrEqual(classname, "func_breakable", false)) 173 | { 174 | if (IsValidEntity(entity)) SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage); 175 | } 176 | } 177 | 178 | public Action OnTakeDamage (int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3]) 179 | { 180 | if (IsValidEntity(victim) && IsValidClient(attacker) && CanUseText(attacker) && text_show[attacker]) 181 | { 182 | char sdamage[8]; 183 | int idamage = RoundToZero(damage); 184 | IntToString(idamage, sdamage, sizeof(sdamage)); 185 | 186 | if (idamage > 0) 187 | { 188 | int health = GetEntProp(victim, Prop_Data, "m_iHealth"); 189 | float victimpos[3], clientAngle[3], clientpos[3]; 190 | GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victimpos); 191 | GetClientEyeAngles(attacker, clientAngle); 192 | GetClientAbsOrigin(attacker, clientpos); 193 | 194 | //PrintToChat(attacker, "weapon %d, type %d", weapon , damagetype); 195 | //PrintToChat(attacker, "Vic %f, %f, %f", victimpos[0], victimpos[1], victimpos[2]); 196 | //PrintToChat(attacker, "DMG %f, %f, %f", damagePosition[0], damagePosition[1], damagePosition[2]); 197 | //PrintToChat(attacker, "damageForce %f, %f, %f", damageForce[0], damageForce[1], damageForce[2]); 198 | 199 | if(damagetype == 8) return; // inferno doesn't have damageposition and damageForce :( 200 | 201 | if(weapon == -1 && damagetype == 64) // grenades 202 | { 203 | if(idamage > health) ShowDamageText(attacker, damagePosition, clientAngle, sdamage, true, victim); 204 | else ShowDamageText(attacker, damagePosition, clientAngle, sdamage, false, victim); 205 | } 206 | else if(weapon != -1) // normal weapons 207 | { 208 | if(idamage > health) ShowDamageText(attacker, damagePosition, clientAngle, sdamage, true, victim); 209 | else ShowDamageText(attacker, damagePosition, clientAngle, sdamage, false, victim); 210 | } 211 | } 212 | } 213 | } 214 | 215 | public void Event_PlayerHurt(Event event, const char[] name, bool dontBroadcast) 216 | { 217 | int victim = GetClientOfUserId(event.GetInt("userid")); 218 | int attacker = GetClientOfUserId(event.GetInt("attacker")); 219 | int idamage = event.GetInt("dmg_health"); 220 | char sWeapon[50]; 221 | event.GetString("weapon", sWeapon, 50, ""); 222 | int health = GetClientHealth(victim); 223 | 224 | if(!IsValidClient(attacker) || IsFakeClient(attacker) || attacker == victim || !CanUseText(attacker) || !text_show[attacker]) return; 225 | 226 | ReplaceString(sWeapon, 50, "_projectile", ""); 227 | 228 | if (!sWeapon[0]) return; 229 | if(StrContains("inferno|molotov|decoy|flashbang|hegrenade|smokegrenade", sWeapon) != -1) 230 | { 231 | float victimpos[3], clientAngle[3]; 232 | GetClientAbsOrigin(victim, victimpos); 233 | GetClientEyeAngles(attacker, clientAngle); 234 | 235 | victimpos[0] += GetRandomFloat(-20.0, 20.0); 236 | victimpos[1] += GetRandomFloat(-20.0, 20.0); 237 | victimpos[2] += GetRandomFloat(10.0, 30.0); 238 | 239 | char damage[8]; 240 | IntToString(idamage, damage, sizeof(damage)); 241 | 242 | if(health < 1) ShowDamageText(attacker, victimpos, clientAngle, damage, true, victim); 243 | else ShowDamageText(attacker, victimpos, clientAngle, damage, false, victim); 244 | } 245 | else 246 | { 247 | float pos[3], clientEye[3], clientAngle[3]; 248 | GetClientEyePosition(attacker, clientEye); 249 | GetClientEyeAngles(attacker, clientAngle); 250 | 251 | TR_TraceRayFilter(clientEye, clientAngle, MASK_SOLID, RayType_Infinite, HitSelf, attacker); 252 | 253 | if (TR_DidHit(INVALID_HANDLE)) TR_GetEndPosition(pos); 254 | 255 | char damage[8]; 256 | IntToString(idamage, damage, sizeof(damage)); 257 | 258 | if(health < 1) ShowDamageText(attacker, pos, clientAngle, damage, true, victim); 259 | else ShowDamageText(attacker, pos, clientAngle, damage, false, victim); 260 | } 261 | } 262 | 263 | // Edit from 264 | // https://forums.alliedmods.net/showpost.php?p=2523113&postcount=8 265 | stock int ShowDamageText(int client, float fPos[3], float fAngles[3], char[] sText, bool kill, int victim) 266 | { 267 | int entity = CreateEntityByName("point_worldtext"); 268 | 269 | if(entity == -1) return entity; 270 | float distance; 271 | char stext_size_kill[8]; 272 | char stext_size_normal[8]; 273 | distance = Entity_GetDistance(client, victim); 274 | DispatchKeyValue(entity, "message", sText); 275 | 276 | FloatToString(0.0015*distance*StringToFloat(text_size_kill[client]), stext_size_kill, sizeof(stext_size_kill)); 277 | FloatToString(0.0015*distance*StringToFloat(text_size_normal[client]), stext_size_normal, sizeof(stext_size_normal)); 278 | 279 | if(kill) 280 | { 281 | DispatchKeyValue(entity, "textsize", stext_size_kill); 282 | DispatchKeyValue(entity, "color", text_color_kill[client]); 283 | //debug distance 284 | //PrintToChat(client, "Kill distance: %f", distance); 285 | //1500.0 - very long distance, <100 - very close distance 286 | } 287 | else 288 | { 289 | DispatchKeyValue(entity, "textsize", stext_size_normal); 290 | DispatchKeyValue(entity, "color", text_color_normal[client]); 291 | } 292 | 293 | SetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity", client); 294 | SetFlags(entity); 295 | 296 | SDKHook(entity, SDKHook_SetTransmit, SetTransmit); 297 | TeleportEntity(entity, fPos, fAngles, NULL_VECTOR); 298 | 299 | CreateTimer(0.5, KillText, EntIndexToEntRef(entity)); 300 | 301 | return entity; 302 | } 303 | 304 | public void SetFlags(int entity) 305 | { 306 | if (GetEdictFlags(entity) & FL_EDICT_ALWAYS) 307 | { 308 | SetEdictFlags(entity, (GetEdictFlags(entity) ^ FL_EDICT_ALWAYS)); 309 | } 310 | } 311 | 312 | public Action KillText(Handle timer, int ref) 313 | { 314 | int entity = EntRefToEntIndex(ref); 315 | if(entity == INVALID_ENT_REFERENCE || !IsValidEntity(entity)) return; 316 | SDKUnhook(entity, SDKHook_SetTransmit, SetTransmit); 317 | AcceptEntityInput(entity, "kill"); 318 | } 319 | 320 | public bool HitSelf(int entity, int contentsMask, any data) 321 | { 322 | if (entity == data) return false; 323 | return true; 324 | } 325 | 326 | //https://forums.alliedmods.net/showthread.php?p=2483070 327 | //https://forums.alliedmods.net/showpost.php?p=2482807&postcount=16 328 | //https://github.com/bbennett905/store-aura/blob/master/store-aura.sp#L509 329 | public Action SetTransmit(int entity, int client) 330 | { 331 | SetFlags(entity); 332 | int owner = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity"); 333 | if(client == owner) return Plugin_Continue; // draw 334 | else return Plugin_Stop; // not draw 335 | } 336 | 337 | public Action Command_DmgText(int client, int args) 338 | { 339 | if (IsValidClient(client) && !IsFakeClient(client)) 340 | { 341 | if(!CanUseText(client)) CPrintToChat(client, "%T", "No Access", client); 342 | else ShowSettingsMenu(client); 343 | } 344 | return Plugin_Handled; 345 | } 346 | 347 | public void ShowSettingsMenu(int client) 348 | { 349 | Menu dmg_menu = new Menu(DMGMenuHandler); 350 | 351 | char dmgmenutitle[512]; 352 | Format(dmgmenutitle, sizeof(dmgmenutitle), "%T", "Menu Settings Title", client); 353 | dmg_menu.SetTitle(dmgmenutitle); 354 | 355 | char settings[PLATFORM_MAX_PATH]; 356 | if(text_show[client]) Format(settings, sizeof(settings), "%T", "Menu Settings Show", client, text_size_normal[client], text_color_normal[client], text_size_kill[client], text_color_kill[client]); 357 | else Format(settings, sizeof(settings), "%T", "Menu Settings Hide", client, text_size_normal[client], text_color_normal[client], text_size_kill[client], text_color_kill[client]); 358 | dmg_menu.AddItem("settings", settings); 359 | 360 | if(text_show[client]) 361 | { 362 | char hide[PLATFORM_MAX_PATH]; 363 | Format(hide, sizeof(hide), "%T", "Menu Hide Text", client); 364 | dmg_menu.AddItem("hide", hide); 365 | } 366 | else 367 | { 368 | char show[PLATFORM_MAX_PATH]; 369 | Format(show, sizeof(show), "%T", "Menu Show Text", client); 370 | dmg_menu.AddItem("show", show); 371 | } 372 | 373 | char normal_size[PLATFORM_MAX_PATH]; 374 | Format(normal_size, sizeof(normal_size), "%T", "Menu Normal Size", client); 375 | dmg_menu.AddItem("normal_size", normal_size); 376 | 377 | char kill_size[PLATFORM_MAX_PATH]; 378 | Format(kill_size, sizeof(kill_size), "%T", "Menu Kill Size", client); 379 | dmg_menu.AddItem("kill_size", kill_size); 380 | 381 | char normal_color[PLATFORM_MAX_PATH]; 382 | Format(normal_color, sizeof(normal_color), "%T", "Menu Noraml Color", client); 383 | dmg_menu.AddItem("normal_color", normal_color); 384 | 385 | char kill_color[PLATFORM_MAX_PATH]; 386 | Format(kill_color, sizeof(kill_color), "%T", "Menu Kill Color", client); 387 | dmg_menu.AddItem("kill_color", kill_color); 388 | 389 | dmg_menu.Display(client, 0); 390 | } 391 | 392 | public int DMGMenuHandler(Menu menu, MenuAction action, int client,int param) 393 | { 394 | switch(action) 395 | { 396 | case MenuAction_Select: 397 | { 398 | char menuitem[20]; 399 | menu.GetItem(param, menuitem, sizeof(menuitem)); 400 | 401 | if(StrEqual(menuitem, "settings")) 402 | { 403 | ShowSettingsMenu(client); 404 | } 405 | else if(StrEqual(menuitem, "show")) 406 | { 407 | text_show[client] = true; 408 | ShowSettingsMenu(client); 409 | SetClientCookie(client, Cookie_Show, "1"); 410 | } 411 | else if(StrEqual(menuitem, "hide")) 412 | { 413 | text_show[client] = false; 414 | ShowSettingsMenu(client); 415 | SetClientCookie(client, Cookie_Show, "0"); 416 | } 417 | else if(StrEqual(menuitem, "normal_size")) 418 | { 419 | CPrintToChat(client, "%T", "Say Normal Size", client); 420 | SayingSettings[client] = 1; 421 | } 422 | else if(StrEqual(menuitem, "kill_size")) 423 | { 424 | CPrintToChat(client, "%T", "Say Kill Size", client); 425 | SayingSettings[client] = 2; 426 | } 427 | else if(StrEqual(menuitem, "normal_color")) 428 | { 429 | CPrintToChat(client, "%T", "Say Normal Color", client); 430 | SayingSettings[client] = 3; 431 | } 432 | else if(StrEqual(menuitem, "kill_color")) 433 | { 434 | CPrintToChat(client, "%T", "Say Kill Color", client); 435 | SayingSettings[client] = 4; 436 | } 437 | } 438 | } 439 | } 440 | 441 | public void OnClientDisconnect(int client) 442 | { 443 | if(IsValidClient(client) && !IsFakeClient(client)) 444 | { 445 | SayingSettings[client] = 0; 446 | } 447 | } 448 | 449 | public Action Command_Say(int client, int args) 450 | { 451 | if(!IsValidClient(client) || IsFakeClient(client) || SayingSettings[client] == 0) return Plugin_Continue; 452 | 453 | char arg[64]; 454 | GetCmdArgString(arg, sizeof(arg)); 455 | StripQuotes(arg); 456 | 457 | if(StrEqual(arg, "!cancel")) 458 | { 459 | CPrintToChat(client, "%T", "Say Cancel", client); 460 | SayingSettings[client] = 0; 461 | ShowSettingsMenu(client); 462 | } 463 | else 464 | { 465 | char sMaxSize[8]; 466 | IntToString(MaxSize, sMaxSize, sizeof(sMaxSize)); 467 | 468 | if(SayingSettings[client] == 1) 469 | { 470 | SayingSettings[client] = 0; 471 | 472 | if(MaxSize > 0 && StringToInt(arg) > MaxSize) text_size_normal[client] = sMaxSize; 473 | else text_size_normal[client] = arg; 474 | 475 | SetClientCookie(client, Cookie_Size_Normal, text_size_normal[client]); 476 | CPrintToChat(client, "%T", "Normal Size Is", client, text_size_normal[client]); 477 | ShowSettingsMenu(client); 478 | } 479 | else if(SayingSettings[client] == 2) 480 | { 481 | SayingSettings[client] = 0; 482 | 483 | if(MaxSize > 0 && StringToInt(arg) > MaxSize) text_size_kill[client] = sMaxSize; 484 | else text_size_kill[client] = arg; 485 | 486 | SetClientCookie(client, Cookie_Size_Kill, text_size_kill[client]); 487 | CPrintToChat(client, "%T", "Kill Size Is", client, text_size_kill[client]); 488 | ShowSettingsMenu(client); 489 | } 490 | else if(SayingSettings[client] == 3) 491 | { 492 | SayingSettings[client] = 0; 493 | 494 | text_color_normal[client] = arg; 495 | SetClientCookie(client, Cookie_Color_Normal, text_color_normal[client]); 496 | CPrintToChat(client, "%T", "Normal RGB Color Is", client, text_color_normal[client]); 497 | ShowSettingsMenu(client); 498 | } 499 | else if(SayingSettings[client] == 4) 500 | { 501 | SayingSettings[client] = 0; 502 | 503 | text_color_kill[client] = arg; 504 | SetClientCookie(client, Cookie_Color_Kill, text_color_kill[client]); 505 | CPrintToChat(client, "%T", "Kill RGB Color Is", client, text_color_kill[client]); 506 | ShowSettingsMenu(client); 507 | } 508 | } 509 | return Plugin_Handled; 510 | } 511 | 512 | stock bool CanUseText(int client) 513 | { 514 | if(StrEqual(Flag, "") || StrEqual(Flag, " ")) return true; 515 | else 516 | { 517 | if (CheckCommandAccess(client, "dmgtext", ReadFlagString(Flag), true)) return true; 518 | else return false; 519 | } 520 | } 521 | 522 | stock bool IsValidClient(int client) 523 | { 524 | if (client <= 0) return false; 525 | if (client > MaxClients) return false; 526 | if (!IsClientConnected(client)) return false; 527 | return IsClientInGame(client); 528 | } 529 | --------------------------------------------------------------------------------