hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.05.23. 07:58



Jelenlévő felhasználók

Jelenleg 277 felhasználó van jelen :: 1 regisztrált, 0 rejtett és 276 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: Bing [Bot] az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 10 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: Bővített ShowDamage (Sebzés mutató)
HozzászólásElküldve: 2013.09.07. 18:17 
Offline
Tud valamit
Avatar

Csatlakozott: 2013.04.01. 12:11
Hozzászólások: 119
Megköszönt másnak: 17 alkalommal
Megköszönték neki: 16 alkalommal
Sziasztok.
Egy olyan kérésem lenne, hogy az alábbi ShowDamage plugint valaki bővítse ki egy körvégi statisztikával.
A kör végén írja ki a játékosoknak csetbe, hogy hány találatból mennyit sebeztek.
Az alábbi kép egy eventscriptes script.
[ablak]Kép[/ablak]

Itt van az alap plugin forrás kódja amit ki kellene bővíteni.
Segítségeteket előre is köszönöm (:

SMX Forráskód: [ Mindet kijelol ]
  1. #include <sourcemod>
  2. #include <clientprefs>
  3. #include <colors>
  4.  
  5. #define PLUGIN_VERSION "1.0.7"
  6.  
  7. public Plugin:myinfo =
  8. {
  9. name = "Show Damage",
  10. author = "exvel",
  11. description = "Shows damage in the center of the screen.",
  12. version = PLUGIN_VERSION,
  13. url = "www.hlmod.hu"
  14. }
  15.  
  16. new player_old_health[MAXPLAYERS + 1];
  17. new player_damage[MAXPLAYERS + 1];
  18. new bool:block_timer[MAXPLAYERS + 1] = {false,...};
  19. new bool:FrameMod = true;
  20. new String:DamageEventName[16];
  21. new MaxDamage = 10000000;
  22. new bool:option_show_damage[MAXPLAYERS + 1] = {true,...};
  23. new Handle:cookie_show_damage = INVALID_HANDLE;
  24.  
  25. //CVars' handles
  26. new Handle:cvar_show_damage = INVALID_HANDLE;
  27. new Handle:cvar_show_damage_ff = INVALID_HANDLE;
  28. new Handle:cvar_show_damage_own_dmg = INVALID_HANDLE;
  29. new Handle:cvar_show_damage_text_area = INVALID_HANDLE;
  30.  
  31. //CVars' varibles
  32. new bool:show_damage = true;
  33. new bool:show_damage_ff = false;
  34. new bool:show_damage_own_dmg = false;
  35. new show_damage_text_area = 1;
  36.  
  37.  
  38. public OnPluginStart()
  39. {
  40. decl String:gameName[80];
  41. GetGameFolderName(gameName, 80);
  42.  
  43. if (StrEqual(gameName, "cstrike") || StrEqual(gameName, "insurgency"))
  44. {
  45. HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Post);
  46. DamageEventName = "dmg_health";
  47. FrameMod = false;
  48. }
  49. else if (StrEqual(gameName, "left4dead") || StrEqual(gameName, "left4dead2"))
  50. {
  51. HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Post);
  52. HookEvent("infected_hurt", Event_InfectedHurt, EventHookMode_Post);
  53. MaxDamage = 2000;
  54. DamageEventName = "dmg_health";
  55. FrameMod = false;
  56. }
  57. else if (StrEqual(gameName, "dod") || StrEqual(gameName, "hidden"))
  58. {
  59. HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Post);
  60. DamageEventName = "damage";
  61. FrameMod = false;
  62. }
  63. else
  64. {
  65. HookEvent("player_hurt", Event_PlayerHurt_FrameMod, EventHookMode_Pre);
  66. FrameMod = true;
  67. }
  68.  
  69. CreateConVar("sm_show_damage_version", PLUGIN_VERSION, "Show Damage Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
  70. cvar_show_damage = CreateConVar("sm_show_damage", "1", "Enabled/Disabled show damage functionality, 0 = off/1 = on", FCVAR_PLUGIN, true, 0.0, true, 1.0);
  71. cvar_show_damage_ff = CreateConVar("sm_show_damage_ff", "0", "Show friendly fire damage, 0 = off/1 = on", FCVAR_PLUGIN, true, 0.0, true, 1.0);
  72. cvar_show_damage_own_dmg = CreateConVar("sm_show_damage_own_dmg", "0", "Show your own damage, 0 = off/1 = on", FCVAR_PLUGIN, true, 0.0, true, 1.0);
  73. cvar_show_damage_text_area = CreateConVar("sm_show_damage_text_area", "1", "Defines the area for damage text:\n 1 = in the center of the screen\n 2 = in the hint text area \n 3 = in chat area of screen", FCVAR_PLUGIN, true, 1.0, true, 3.0);
  74.  
  75. HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
  76.  
  77. HookConVarChange(cvar_show_damage, OnCVarChange);
  78. HookConVarChange(cvar_show_damage_ff, OnCVarChange);
  79. HookConVarChange(cvar_show_damage_own_dmg, OnCVarChange);
  80. HookConVarChange(cvar_show_damage_text_area, OnCVarChange);
  81.  
  82. AutoExecConfig(true, "plugin.showdamage");
  83. LoadTranslations("common.phrases");
  84. LoadTranslations("showdamage.phrases");
  85.  
  86. cookie_show_damage = RegClientCookie("Show Damage On/Off", "", CookieAccess_Private);
  87. new info;
  88. SetCookieMenuItem(CookieMenuHandler_ShowDamage, any:info, "Show Damage");
  89. }
  90.  
  91. public CookieMenuHandler_ShowDamage(client, CookieMenuAction:action, any:info, String:buffer[], maxlen)
  92. {
  93. if (action == CookieMenuAction_DisplayOption)
  94. {
  95. decl String:status[10];
  96. if (option_show_damage[client])
  97. {
  98. Format(status, sizeof(status), "%T", "On", client);
  99. }
  100. else
  101. {
  102. Format(status, sizeof(status), "%T", "Off", client);
  103. }
  104.  
  105. Format(buffer, maxlen, "%T: %s", "Cookie Show Damage", client, status);
  106. }
  107. // CookieMenuAction_SelectOption
  108. else
  109. {
  110. option_show_damage[client] = !option_show_damage[client];
  111.  
  112. if (option_show_damage[client])
  113. {
  114. SetClientCookie(client, cookie_show_damage, "On");
  115. }
  116. else
  117. {
  118. SetClientCookie(client, cookie_show_damage, "Off");
  119. }
  120.  
  121. ShowCookieMenu(client);
  122. }
  123. }
  124.  
  125. public OnClientCookiesCached(client)
  126. {
  127. option_show_damage[client] = GetCookieShowDamage(client);
  128. }
  129.  
  130. bool:GetCookieShowDamage(client)
  131. {
  132. decl String:buffer[10];
  133. GetClientCookie(client, cookie_show_damage, buffer, sizeof(buffer));
  134.  
  135. return !StrEqual(buffer, "Off");
  136. }
  137.  
  138. public OnConfigsExecuted()
  139. {
  140. GetCVars();
  141. }
  142.  
  143. public OnClientConnected(client)
  144. {
  145. block_timer[client] = false;
  146. }
  147.  
  148. public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
  149. {
  150. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  151. block_timer[client] = false;
  152.  
  153. return Plugin_Continue;
  154. }
  155.  
  156. //This is for games that have no damage information in player_hurt event
  157. public OnGameFrame()
  158. {
  159. if (FrameMod && show_damage)
  160. {
  161. for (new client = 1; client <= MaxClients; client++)
  162. {
  163. if (IsClientInGame(client))
  164. {
  165. player_old_health[client] = GetClientHealth(client);
  166. }
  167. }
  168. }
  169. }
  170.  
  171. public Action:ShowDamage(Handle:timer, any:client)
  172. {
  173. block_timer[client] = false;
  174.  
  175. if (player_damage[client] <= 0 || !client)
  176. {
  177. return;
  178. }
  179.  
  180. if (!IsClientInGame(client))
  181. {
  182. return;
  183. }
  184.  
  185. switch (show_damage_text_area)
  186. {
  187. case 1:
  188. {
  189. PrintCenterText(client, "%t", "CenterText Damage Text", player_damage[client]);
  190. }
  191.  
  192. case 2:
  193. {
  194. PrintHintText(client, "%t", "HintText Damage Text", player_damage[client]);
  195. }
  196.  
  197. case 3:
  198. {
  199. CPrintToChat(client, "%t", "Chat Damage Text", player_damage[client]);
  200. }
  201. }
  202.  
  203. player_damage[client] = 0;
  204. }
  205.  
  206. public Action:Event_PlayerHurt_FrameMod(Handle:event, const String:name[], bool:dontBroadcast)
  207. {
  208. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  209. new client_attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  210. new damage = player_old_health[client] - GetClientHealth(client);
  211.  
  212. CalcDamage(client, client_attacker, damage);
  213.  
  214. return Plugin_Continue;
  215. }
  216.  
  217. public Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
  218. {
  219. new client_attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  220. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  221. new damage = GetEventInt(event, DamageEventName);
  222.  
  223. CalcDamage(client, client_attacker, damage);
  224.  
  225. return Plugin_Continue;
  226. }
  227.  
  228. public Action:Event_InfectedHurt(Handle:event, const String:name[], bool:dontBroadcast)
  229. {
  230. new client_attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  231. new damage = GetEventInt(event, "amount");
  232.  
  233. CalcDamage(0, client_attacker, damage);
  234.  
  235. return Plugin_Continue;
  236. }
  237.  
  238.  
  239.  
  240. CalcDamage(client, client_attacker, damage)
  241. {
  242. if (!show_damage || !option_show_damage[client_attacker])
  243. {
  244. return;
  245. }
  246.  
  247. if (client_attacker == 0)
  248. {
  249. return;
  250. }
  251.  
  252. if (IsFakeClient(client_attacker) || !IsClientInGame(client_attacker))
  253. {
  254. return;
  255. }
  256.  
  257. //If client == 0 than skip this verifying. It can be an infected or something else without client index.
  258. if (client != 0)
  259. {
  260. if (client == client_attacker)
  261. {
  262. if (!show_damage_own_dmg)
  263. {
  264. return;
  265. }
  266. }
  267. else if (GetClientTeam(client) == GetClientTeam(client_attacker))
  268. {
  269. if (!show_damage_ff)
  270. {
  271. return;
  272. }
  273. }
  274. }
  275.  
  276. //This is a fix for Left 4 Dead. When tank dies the game fires hurt event with 5000 dmg that is a bug.
  277. if (damage > MaxDamage)
  278. {
  279. return;
  280. }
  281.  
  282. player_damage[client_attacker] += damage;
  283.  
  284. if (block_timer[client_attacker])
  285. {
  286. return;
  287. }
  288.  
  289. CreateTimer(0.01, ShowDamage, client_attacker);
  290. block_timer[client_attacker] = true;
  291. }
  292.  
  293. public OnCVarChange(Handle:convar_hndl, const String:oldValue[], const String:newValue[])
  294. {
  295. GetCVars();
  296. }
  297.  
  298. GetCVars()
  299. {
  300. show_damage = GetConVarBool(cvar_show_damage);
  301. show_damage_ff = GetConVarBool(cvar_show_damage_ff);
  302. show_damage_own_dmg = GetConVarBool(cvar_show_damage_own_dmg);
  303. show_damage_text_area = GetConVarInt(cvar_show_damage_text_area);
  304. }
  305.  


Hozzászólás jelentése
Vissza a tetejére
   
HozzászólásElküldve: 2013.09.09. 18:02 
Offline
Őskövület
Avatar

Csatlakozott: 2012.02.27. 09:42
Hozzászólások: 2588
Megköszönt másnak: 26 alkalommal
Megköszönték neki: 418 alkalommal
Tessék teszt nemvolt de elvileg kéne, hogy működjön
SMX Forráskód: [ Mindet kijelol ]
  1. #include <sourcemod>
  2. #include <clientprefs>
  3. #include <colors>
  4.  
  5. #define PLUGIN_VERSION "1.0.7"
  6.  
  7. public Plugin:myinfo =
  8. {
  9. name = "Show Damage",
  10. author = "exvel",
  11. description = "Shows damage in the center of the screen.",
  12. version = PLUGIN_VERSION,
  13. url = "www.hlmod.hu"
  14. }
  15.  
  16. new player_old_health[MAXPLAYERS + 1];
  17. new player_damage[MAXPLAYERS + 1];
  18. new maxseb[MAXPLAYERS + 1];
  19. new bool:block_timer[MAXPLAYERS + 1] = {false,...};
  20. new bool:FrameMod = true;
  21. new String:DamageEventName[16];
  22. new MaxDamage = 10000000;
  23. new bool:option_show_damage[MAXPLAYERS + 1] = {true,...};
  24. new Handle:cookie_show_damage = INVALID_HANDLE;
  25.  
  26. //CVars' handles
  27. new Handle:cvar_show_damage = INVALID_HANDLE;
  28. new Handle:cvar_show_damage_ff = INVALID_HANDLE;
  29. new Handle:cvar_show_damage_own_dmg = INVALID_HANDLE;
  30. new Handle:cvar_show_damage_text_area = INVALID_HANDLE;
  31.  
  32. //CVars' varibles
  33. new bool:show_damage = true;
  34. new bool:show_damage_ff = false;
  35. new bool:show_damage_own_dmg = false;
  36. new show_damage_text_area = 1;
  37.  
  38.  
  39. public OnPluginStart()
  40. {
  41. decl String:gameName[80];
  42. GetGameFolderName(gameName, 80);
  43.  
  44. if (StrEqual(gameName, "cstrike") || StrEqual(gameName, "insurgency"))
  45. {
  46. HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Post);
  47. HookEvent("round_end", Event_Korveg)
  48. DamageEventName = "dmg_health";
  49. FrameMod = false;
  50. }
  51. else if (StrEqual(gameName, "left4dead") || StrEqual(gameName, "left4dead2"))
  52. {
  53. HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Post);
  54. HookEvent("round_end", Event_Korveg)
  55. HookEvent("infected_hurt", Event_InfectedHurt, EventHookMode_Post);
  56. MaxDamage = 2000;
  57. DamageEventName = "dmg_health";
  58. FrameMod = false;
  59. }
  60. else if (StrEqual(gameName, "dod") || StrEqual(gameName, "hidden"))
  61. {
  62. HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Post);
  63. HookEvent("round_end", Event_Korveg)
  64. DamageEventName = "damage";
  65. FrameMod = false;
  66. }
  67. else
  68. {
  69. HookEvent("player_hurt", Event_PlayerHurt_FrameMod, EventHookMode_Pre);
  70. HookEvent("round_end", Event_Korveg)
  71. FrameMod = true;
  72. }
  73.  
  74. CreateConVar("sm_show_damage_version", PLUGIN_VERSION, "Show Damage Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
  75. cvar_show_damage = CreateConVar("sm_show_damage", "1", "Enabled/Disabled show damage functionality, 0 = off/1 = on", FCVAR_PLUGIN, true, 0.0, true, 1.0);
  76. cvar_show_damage_ff = CreateConVar("sm_show_damage_ff", "0", "Show friendly fire damage, 0 = off/1 = on", FCVAR_PLUGIN, true, 0.0, true, 1.0);
  77. cvar_show_damage_own_dmg = CreateConVar("sm_show_damage_own_dmg", "0", "Show your own damage, 0 = off/1 = on", FCVAR_PLUGIN, true, 0.0, true, 1.0);
  78. cvar_show_damage_text_area = CreateConVar("sm_show_damage_text_area", "1", "Defines the area for damage text:\n 1 = in the center of the screen\n 2 = in the hint text area \n 3 = in chat area of screen", FCVAR_PLUGIN, true, 1.0, true, 3.0);
  79.  
  80. HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
  81.  
  82. HookConVarChange(cvar_show_damage, OnCVarChange);
  83. HookConVarChange(cvar_show_damage_ff, OnCVarChange);
  84. HookConVarChange(cvar_show_damage_own_dmg, OnCVarChange);
  85. HookConVarChange(cvar_show_damage_text_area, OnCVarChange);
  86.  
  87. AutoExecConfig(true, "plugin.showdamage");
  88. LoadTranslations("common.phrases");
  89. LoadTranslations("showdamage.phrases");
  90.  
  91. cookie_show_damage = RegClientCookie("Show Damage On/Off", "", CookieAccess_Private);
  92. new info;
  93. SetCookieMenuItem(CookieMenuHandler_ShowDamage, any:info, "Show Damage");
  94. }
  95.  
  96. public CookieMenuHandler_ShowDamage(client, CookieMenuAction:action, any:info, String:buffer[], maxlen)
  97. {
  98. if (action == CookieMenuAction_DisplayOption)
  99. {
  100. decl String:status[10];
  101. if (option_show_damage[client])
  102. {
  103. Format(status, sizeof(status), "%T", "On", client);
  104. }
  105. else
  106. {
  107. Format(status, sizeof(status), "%T", "Off", client);
  108. }
  109.  
  110. Format(buffer, maxlen, "%T: %s", "Cookie Show Damage", client, status);
  111. }
  112. // CookieMenuAction_SelectOption
  113. else
  114. {
  115. option_show_damage[client] = !option_show_damage[client];
  116.  
  117. if (option_show_damage[client])
  118. {
  119. SetClientCookie(client, cookie_show_damage, "On");
  120. }
  121. else
  122. {
  123. SetClientCookie(client, cookie_show_damage, "Off");
  124. }
  125.  
  126. ShowCookieMenu(client);
  127. }
  128. }
  129.  
  130. public OnClientCookiesCached(client)
  131. {
  132. option_show_damage[client] = GetCookieShowDamage(client);
  133. }
  134.  
  135. bool:GetCookieShowDamage(client)
  136. {
  137. decl String:buffer[10];
  138. GetClientCookie(client, cookie_show_damage, buffer, sizeof(buffer));
  139.  
  140. return !StrEqual(buffer, "Off");
  141. }
  142.  
  143. public OnConfigsExecuted()
  144. {
  145. GetCVars();
  146. }
  147.  
  148. public OnClientConnected(client)
  149. {
  150. block_timer[client] = false;
  151. }
  152.  
  153. public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
  154. {
  155. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  156. block_timer[client] = false;
  157.  
  158. return Plugin_Continue;
  159. }
  160.  
  161. //This is for games that have no damage information in player_hurt event
  162. public OnGameFrame()
  163. {
  164. if (FrameMod && show_damage)
  165. {
  166. for (new client = 1; client <= MaxClients; client++)
  167. {
  168. if (IsClientInGame(client))
  169. {
  170. player_old_health[client] = GetClientHealth(client);
  171. }
  172. }
  173. }
  174. }
  175.  
  176. public Action:ShowDamage(Handle:timer, any:client)
  177. {
  178. block_timer[client] = false;
  179.  
  180. if (player_damage[client] <= 0 || !client)
  181. {
  182. return;
  183. }
  184.  
  185. if (!IsClientInGame(client))
  186. {
  187. return;
  188. }
  189.  
  190. switch (show_damage_text_area)
  191. {
  192. case 1:
  193. {
  194. PrintCenterText(client, "%t", "CenterText Damage Text", player_damage[client]);
  195. }
  196.  
  197. case 2:
  198. {
  199. PrintHintText(client, "%t", "HintText Damage Text", player_damage[client]);
  200. }
  201.  
  202. case 3:
  203. {
  204. CPrintToChat(client, "%t", "Chat Damage Text", player_damage[client]);
  205. }
  206. }
  207.  
  208. player_damage[client] = 0;
  209. }
  210.  
  211. public Action:Event_PlayerHurt_FrameMod(Handle:event, const String:name[], bool:dontBroadcast)
  212. {
  213. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  214. new client_attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  215. new damage = player_old_health[client] - GetClientHealth(client);
  216.  
  217. CalcDamage(client, client_attacker, damage);
  218.  
  219. return Plugin_Continue;
  220. }
  221.  
  222. public Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
  223. {
  224. new client_attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  225. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  226. new damage = GetEventInt(event, DamageEventName);
  227.  
  228. CalcDamage(client, client_attacker, damage);
  229.  
  230. return Plugin_Continue;
  231. }
  232.  
  233. public Action:Event_InfectedHurt(Handle:event, const String:name[], bool:dontBroadcast)
  234. {
  235. new client_attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  236. new damage = GetEventInt(event, "amount");
  237.  
  238. CalcDamage(0, client_attacker, damage);
  239.  
  240. return Plugin_Continue;
  241. }
  242.  
  243.  
  244.  
  245. CalcDamage(client, client_attacker, damage)
  246. {
  247. if (!show_damage || !option_show_damage[client_attacker])
  248. {
  249. return;
  250. }
  251.  
  252. if (client_attacker == 0)
  253. {
  254. return;
  255. }
  256.  
  257. if (IsFakeClient(client_attacker) || !IsClientInGame(client_attacker))
  258. {
  259. return;
  260. }
  261.  
  262. //If client == 0 than skip this verifying. It can be an infected or something else without client index.
  263. if (client != 0)
  264. {
  265. if (client == client_attacker)
  266. {
  267. if (!show_damage_own_dmg)
  268. {
  269. return;
  270. }
  271. }
  272. else if (GetClientTeam(client) == GetClientTeam(client_attacker))
  273. {
  274. if (!show_damage_ff)
  275. {
  276. return;
  277. }
  278. }
  279. }
  280.  
  281. //This is a fix for Left 4 Dead. When tank dies the game fires hurt event with 5000 dmg that is a bug.
  282. if (damage > MaxDamage)
  283. {
  284. return;
  285. }
  286.  
  287. player_damage[client_attacker] += damage;
  288. maxseb[client_attacker] += damage;
  289.  
  290. if (block_timer[client_attacker])
  291. {
  292. return;
  293. }
  294.  
  295. CreateTimer(0.01, ShowDamage, client_attacker);
  296. block_timer[client_attacker] = true;
  297. }
  298. public OnCVarChange(Handle:convar_hndl, const String:oldValue[], const String:newValue[])
  299. {
  300. GetCVars();
  301. }
  302.  
  303. GetCVars()
  304. {
  305. show_damage = GetConVarBool(cvar_show_damage);
  306. show_damage_ff = GetConVarBool(cvar_show_damage_ff);
  307. show_damage_own_dmg = GetConVarBool(cvar_show_damage_own_dmg);
  308. show_damage_text_area = GetConVarInt(cvar_show_damage_text_area);
  309. }
  310. public Action:Event_Korveg(Handle:event, const String:name[], bool:dontBroadcast)
  311. {
  312. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  313. PrintToChat(client, "[Show Damage]Maximalis sebzesed: %d",maxseb[client])
  314. }

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
HozzászólásElküldve: 2013.09.09. 18:46 
Offline
Tud valamit
Avatar

Csatlakozott: 2013.04.01. 12:11
Hozzászólások: 119
Megköszönt másnak: 17 alkalommal
Megköszönték neki: 16 alkalommal
Sajnos nem működik :(
Amúgy ebben benne lenne az a statisztika, hogy hány találatból érte el az adott mennyiségű sebzést?
Itt van a hiba.
SMX Forráskód: [ Mindet kijelol ]
  1. L 09/09/2013 - 18:42:32: [SM] Displaying call stack trace for plugin "showdamage.smx":
  2. L 09/09/2013 - 18:42:32: [SM] [0] Line 313, showdamage.sp::Event_Korveg()
  3. L 09/09/2013 - 18:42:46: [SM] Native "PrintToChat" reported: Client index 0 is invalid
  4. L 09/09/2013 - 18:42:46: [SM] Displaying call stack trace for plugin "showdamage.smx":
  5. L 09/09/2013 - 18:42:46: [SM] [0] Line 313, showdamage.sp::Event_Korveg()


Hozzászólás jelentése
Vissza a tetejére
   
HozzászólásElküldve: 2013.09.10. 07:57 
Offline
Őskövület
Avatar

Csatlakozott: 2012.02.27. 09:42
Hozzászólások: 2588
Megköszönt másnak: 26 alkalommal
Megköszönték neki: 418 alkalommal
gondolom botok ellen tesztelted és azért írja, hogy a 0 id érvénytelen próbáld így
SMX Forráskód: [ Mindet kijelol ]
  1. #include <sourcemod>
  2. #include <clientprefs>
  3. #include <colors>
  4.  
  5. #define PLUGIN_VERSION "1.0.7"
  6.  
  7. public Plugin:myinfo =
  8. {
  9. name = "Show Damage",
  10. author = "exvel",
  11. description = "Shows damage in the center of the screen.",
  12. version = PLUGIN_VERSION,
  13. url = "www.hlmod.hu"
  14. }
  15.  
  16. new player_old_health[MAXPLAYERS + 1];
  17. new player_damage[MAXPLAYERS + 1];
  18. new maxseb[MAXPLAYERS + 1];
  19. new bool:block_timer[MAXPLAYERS + 1] = {false,...};
  20. new bool:FrameMod = true;
  21. new String:DamageEventName[16];
  22. new MaxDamage = 10000000;
  23. new bool:option_show_damage[MAXPLAYERS + 1] = {true,...};
  24. new Handle:cookie_show_damage = INVALID_HANDLE;
  25.  
  26. //CVars' handles
  27. new Handle:cvar_show_damage = INVALID_HANDLE;
  28. new Handle:cvar_show_damage_ff = INVALID_HANDLE;
  29. new Handle:cvar_show_damage_own_dmg = INVALID_HANDLE;
  30. new Handle:cvar_show_damage_text_area = INVALID_HANDLE;
  31.  
  32. //CVars' varibles
  33. new bool:show_damage = true;
  34. new bool:show_damage_ff = false;
  35. new bool:show_damage_own_dmg = false;
  36. new show_damage_text_area = 1;
  37.  
  38.  
  39. public OnPluginStart()
  40. {
  41. decl String:gameName[80];
  42. GetGameFolderName(gameName, 80);
  43.  
  44. if (StrEqual(gameName, "cstrike") || StrEqual(gameName, "insurgency"))
  45. {
  46. HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Post);
  47. HookEvent("round_end", Event_Korveg, EventHookMode_Pre)
  48. DamageEventName = "dmg_health";
  49. FrameMod = false;
  50. }
  51. else if (StrEqual(gameName, "left4dead") || StrEqual(gameName, "left4dead2"))
  52. {
  53. HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Post);
  54. HookEvent("round_end", Event_Korveg, EventHookMode_Pre)
  55. HookEvent("infected_hurt", Event_InfectedHurt, EventHookMode_Post);
  56. MaxDamage = 2000;
  57. DamageEventName = "dmg_health";
  58. FrameMod = false;
  59. }
  60. else if (StrEqual(gameName, "dod") || StrEqual(gameName, "hidden"))
  61. {
  62. HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Post);
  63. HookEvent("round_end", Event_Korveg, EventHookMode_Pre)
  64. DamageEventName = "damage";
  65. FrameMod = false;
  66. }
  67. else
  68. {
  69. HookEvent("player_hurt", Event_PlayerHurt_FrameMod, EventHookMode_Pre);
  70. HookEvent("round_end", Event_Korveg, EventHookMode_Pre)
  71. FrameMod = true;
  72. }
  73.  
  74. CreateConVar("sm_show_damage_version", PLUGIN_VERSION, "Show Damage Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
  75. cvar_show_damage = CreateConVar("sm_show_damage", "1", "Enabled/Disabled show damage functionality, 0 = off/1 = on", FCVAR_PLUGIN, true, 0.0, true, 1.0);
  76. cvar_show_damage_ff = CreateConVar("sm_show_damage_ff", "0", "Show friendly fire damage, 0 = off/1 = on", FCVAR_PLUGIN, true, 0.0, true, 1.0);
  77. cvar_show_damage_own_dmg = CreateConVar("sm_show_damage_own_dmg", "0", "Show your own damage, 0 = off/1 = on", FCVAR_PLUGIN, true, 0.0, true, 1.0);
  78. cvar_show_damage_text_area = CreateConVar("sm_show_damage_text_area", "1", "Defines the area for damage text:\n 1 = in the center of the screen\n 2 = in the hint text area \n 3 = in chat area of screen", FCVAR_PLUGIN, true, 1.0, true, 3.0);
  79.  
  80. HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
  81.  
  82. HookConVarChange(cvar_show_damage, OnCVarChange);
  83. HookConVarChange(cvar_show_damage_ff, OnCVarChange);
  84. HookConVarChange(cvar_show_damage_own_dmg, OnCVarChange);
  85. HookConVarChange(cvar_show_damage_text_area, OnCVarChange);
  86.  
  87. AutoExecConfig(true, "plugin.showdamage");
  88. LoadTranslations("common.phrases");
  89. LoadTranslations("showdamage.phrases");
  90.  
  91. cookie_show_damage = RegClientCookie("Show Damage On/Off", "", CookieAccess_Private);
  92. new info;
  93. SetCookieMenuItem(CookieMenuHandler_ShowDamage, any:info, "Show Damage");
  94. }
  95.  
  96. public CookieMenuHandler_ShowDamage(client, CookieMenuAction:action, any:info, String:buffer[], maxlen)
  97. {
  98. if (action == CookieMenuAction_DisplayOption)
  99. {
  100. decl String:status[10];
  101. if (option_show_damage[client])
  102. {
  103. Format(status, sizeof(status), "%T", "On", client);
  104. }
  105. else
  106. {
  107. Format(status, sizeof(status), "%T", "Off", client);
  108. }
  109.  
  110. Format(buffer, maxlen, "%T: %s", "Cookie Show Damage", client, status);
  111. }
  112. // CookieMenuAction_SelectOption
  113. else
  114. {
  115. option_show_damage[client] = !option_show_damage[client];
  116.  
  117. if (option_show_damage[client])
  118. {
  119. SetClientCookie(client, cookie_show_damage, "On");
  120. }
  121. else
  122. {
  123. SetClientCookie(client, cookie_show_damage, "Off");
  124. }
  125.  
  126. ShowCookieMenu(client);
  127. }
  128. }
  129.  
  130. public OnClientCookiesCached(client)
  131. {
  132. option_show_damage[client] = GetCookieShowDamage(client);
  133. }
  134.  
  135. bool:GetCookieShowDamage(client)
  136. {
  137. decl String:buffer[10];
  138. GetClientCookie(client, cookie_show_damage, buffer, sizeof(buffer));
  139.  
  140. return !StrEqual(buffer, "Off");
  141. }
  142.  
  143. public OnConfigsExecuted()
  144. {
  145. GetCVars();
  146. }
  147.  
  148. public OnClientConnected(client)
  149. {
  150. block_timer[client] = false;
  151. }
  152.  
  153. public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
  154. {
  155. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  156. block_timer[client] = false;
  157.  
  158. return Plugin_Continue;
  159. }
  160.  
  161. //This is for games that have no damage information in player_hurt event
  162. public OnGameFrame()
  163. {
  164. if (FrameMod && show_damage)
  165. {
  166. for (new client = 1; client <= MaxClients; client++)
  167. {
  168. if (IsClientInGame(client))
  169. {
  170. player_old_health[client] = GetClientHealth(client);
  171. }
  172. }
  173. }
  174. }
  175.  
  176. public Action:ShowDamage(Handle:timer, any:client)
  177. {
  178. block_timer[client] = false;
  179.  
  180. if (player_damage[client] <= 0 || !client)
  181. {
  182. return;
  183. }
  184.  
  185. if (!IsClientInGame(client))
  186. {
  187. return;
  188. }
  189.  
  190. switch (show_damage_text_area)
  191. {
  192. case 1:
  193. {
  194. PrintCenterText(client, "%t", "CenterText Damage Text", player_damage[client]);
  195. }
  196.  
  197. case 2:
  198. {
  199. PrintHintText(client, "%t", "HintText Damage Text", player_damage[client]);
  200. }
  201.  
  202. case 3:
  203. {
  204. CPrintToChat(client, "%t", "Chat Damage Text", player_damage[client]);
  205. }
  206. }
  207.  
  208. player_damage[client] = 0;
  209. }
  210.  
  211. public Action:Event_PlayerHurt_FrameMod(Handle:event, const String:name[], bool:dontBroadcast)
  212. {
  213. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  214. new client_attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  215. new damage = player_old_health[client] - GetClientHealth(client);
  216.  
  217. CalcDamage(client, client_attacker, damage);
  218.  
  219. return Plugin_Continue;
  220. }
  221.  
  222. public Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
  223. {
  224. new client_attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  225. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  226. new damage = GetEventInt(event, DamageEventName);
  227.  
  228. CalcDamage(client, client_attacker, damage);
  229.  
  230. return Plugin_Continue;
  231. }
  232.  
  233. public Action:Event_InfectedHurt(Handle:event, const String:name[], bool:dontBroadcast)
  234. {
  235. new client_attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  236. new damage = GetEventInt(event, "amount");
  237.  
  238. CalcDamage(0, client_attacker, damage);
  239.  
  240. return Plugin_Continue;
  241. }
  242.  
  243.  
  244.  
  245. CalcDamage(client, client_attacker, damage)
  246. {
  247. if (!show_damage || !option_show_damage[client_attacker])
  248. {
  249. return;
  250. }
  251.  
  252. if (client_attacker == 0)
  253. {
  254. return;
  255. }
  256.  
  257. if (IsFakeClient(client_attacker) || !IsClientInGame(client_attacker))
  258. {
  259. return;
  260. }
  261.  
  262. //If client == 0 than skip this verifying. It can be an infected or something else without client index.
  263. if (client != 0)
  264. {
  265. if (client == client_attacker)
  266. {
  267. if (!show_damage_own_dmg)
  268. {
  269. return;
  270. }
  271. }
  272. else if (GetClientTeam(client) == GetClientTeam(client_attacker))
  273. {
  274. if (!show_damage_ff)
  275. {
  276. return;
  277. }
  278. }
  279. }
  280.  
  281. //This is a fix for Left 4 Dead. When tank dies the game fires hurt event with 5000 dmg that is a bug.
  282. if (damage > MaxDamage)
  283. {
  284. return;
  285. }
  286.  
  287. player_damage[client_attacker] += damage;
  288. maxseb[client_attacker] += damage;
  289.  
  290. if (block_timer[client_attacker])
  291. {
  292. return;
  293. }
  294.  
  295. CreateTimer(0.01, ShowDamage, client_attacker);
  296. block_timer[client_attacker] = true;
  297. }
  298. public OnCVarChange(Handle:convar_hndl, const String:oldValue[], const String:newValue[])
  299. {
  300. GetCVars();
  301. }
  302.  
  303. GetCVars()
  304. {
  305. show_damage = GetConVarBool(cvar_show_damage);
  306. show_damage_ff = GetConVarBool(cvar_show_damage_ff);
  307. show_damage_own_dmg = GetConVarBool(cvar_show_damage_own_dmg);
  308. show_damage_text_area = GetConVarInt(cvar_show_damage_text_area);
  309. }
  310. public Action:Event_Korveg(Handle:event, const String:name[], bool:dontBroadcast)
  311. {
  312. for (new client=1; client<=MaxClients; ++client)
  313. {
  314. PrintToChat(client, "[Show Damage]Maximalis sebzesed: %d",maxseb[client])
  315. }
  316. return;
  317. }

_________________
Kép


A hozzászólást 3 alkalommal szerkesztették, utoljára CrB 2013.09.10. 18:06-kor.

Hozzászólás jelentése
Vissza a tetejére
   
HozzászólásElküldve: 2013.09.10. 15:29 
Offline
Tud valamit
Avatar

Csatlakozott: 2013.04.01. 12:11
Hozzászólások: 119
Megköszönt másnak: 17 alkalommal
Megköszönték neki: 16 alkalommal
Tesztelve lett botokkal és normál játékosokkal is, sajnos így se működik.


Hozzászólás jelentése
Vissza a tetejére
   
HozzászólásElküldve: 2013.09.10. 17:02 
Offline
Őskövület
Avatar

Csatlakozott: 2012.02.27. 09:42
Hozzászólások: 2588
Megköszönt másnak: 26 alkalommal
Megköszönték neki: 418 alkalommal
javítva 2. post (nálam működik szóval nálad is kéne :D)

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
HozzászólásElküldve: 2013.09.11. 15:37 
Offline
Őskövület
Avatar

Csatlakozott: 2012.02.27. 09:42
Hozzászólások: 2588
Megköszönt másnak: 26 alkalommal
Megköszönték neki: 418 alkalommal
amint elmondtad, hogy neked az nem kell bele, hogy mutassa a sebzést ittvan teszteld
legközelebb írd le :)
SMX Forráskód: [ Mindet kijelol ]
  1. /* Plugin Template generated by Pawn Studio */
  2.  
  3. #include <sourcemod>
  4. #include <clientprefs>
  5. public Plugin:myinfo =
  6. {
  7. name = "Sebzes kiiro",
  8. author = "qKKJ",
  9. description = "<- Description ->",
  10. version = "1.0",
  11. url = "<- URL ->"
  12. }
  13. new talalat[MAXPLAYERS + 1]
  14. new maxsebzes[MAXPLAYERS + 1]
  15. new String:DamageEventName[16];
  16. public OnPluginStart()
  17. {
  18. HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Post);
  19. HookEvent("round_end",Event_KorVeg, EventHookMode_Pre);
  20. }
  21. public Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
  22. {
  23. new sebzo = GetClientOfUserId(GetEventInt(event, "attacker"));
  24. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  25. new damage = GetEventInt(event, DamageEventName);
  26.  
  27. CalcDamage(client, sebzo, damage);
  28.  
  29. return Plugin_Continue;
  30. }
  31. CalcDamage(client, sebzo, damage)
  32. {
  33. if(sebzo == 0)
  34. {
  35. return;
  36. }
  37. if(IsFakeClient(sebzo) || !IsClientInGame(sebzo))
  38. {
  39. return;
  40. }
  41. maxsebzes[sebzo] += damage
  42. talalat[sebzo] += 1
  43. }
  44. public Action:Event_KorVeg(Handle: event , const String: name[] , bool: dontBroadcast)
  45. {
  46. new playersConnected = GetMaxClients();
  47. for(new client=1; client <= playersConnected; client++)
  48. {
  49. PrintToChat(client, "[Damage] Osszes sebzesed: %d , Talalat, %d",maxsebzes[client], talalat[client])
  50. }
  51. }

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
HozzászólásElküldve: 2013.09.14. 16:35 
Offline
Tud valamit
Avatar

Csatlakozott: 2013.04.01. 12:11
Hozzászólások: 119
Megköszönt másnak: 17 alkalommal
Megköszönték neki: 16 alkalommal
Ez nem az amit kértem, ez csak a jelenlegi adott sebzést mutatja HUD-ban.
Nekem az összesített sebzés kell körvégén csetbe ill., hogy hány találatból érte el az összeget.
PL:
[ablak]Ebben a körben 8 találattal 413-t sebeztél.[/ablak]


Hozzászólás jelentése
Vissza a tetejére
   
HozzászólásElküldve: 2013.09.14. 18:27 
Offline
Developer
Avatar

Csatlakozott: 2011.06.01. 21:11
Hozzászólások: 7965
Megköszönt másnak: 295 alkalommal
Megköszönték neki: 537 alkalommal
Alnilam írta:
Ez nem az amit kértem, ez csak a jelenlegi adott sebzést mutatja HUD-ban.
Nekem az összesített sebzés kell körvégén csetbe ill., hogy hány találatból érte el az összeget.
PL:
[ablak]Ebben a körben 8 találattal 413-t sebeztél.[/ablak]



Alsó kódot probáltad? Az kör végén írja chatbe.

_________________
http://www.easyrankup.eu


Hozzászólás jelentése
Vissza a tetejére
   
HozzászólásElküldve: 2013.09.14. 18:31 
Offline
Tud valamit
Avatar

Csatlakozott: 2013.04.01. 12:11
Hozzászólások: 119
Megköszönt másnak: 17 alkalommal
Megköszönték neki: 16 alkalommal
Privátban írtam Crazynek ezzel kapcsolatosan és persze az utolsó kódot is kipróbáltam és leírtam, hogy nem működik mivel:
Idézem.
[ablak]Mikor felmentem ezt írta ki csetbe.
SMX Forráskód: [ Mindet kijelol ] [Damage] Osszes sebzesed: 0 , Talalat, 83
[Damage] Osszes sebzesed: 0 , Talalat, 0
Továbbá semmi mást nem írt ki.[/ablak]


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 10 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 2 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole