HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* Plugin Template generated by Pawn Studio */
  2.  
  3. #include <sourcemod>
  4. #include <sdktools>
  5.  
  6. public Plugin:myinfo =
  7. {
  8. name = "New Plugin",
  9. author = "Unknown",
  10. description = "<- Description ->",
  11. version = "1.0",
  12. url = "www.devzone.cn"
  13. }
  14.  
  15. enum {
  16. kill_1,
  17. kill_2,
  18. kill_3,
  19. kill_4,
  20. kill_5,
  21. kill_headshot,
  22. kill_knife,
  23. kill_hegrenade,
  24. kill_inferno,
  25. kill_taser
  26. };
  27.  
  28. new String:SND_KILLVOICE[][] = {"vox/first.wav","vox/double.wav",
  29. "vox/third.wav","vox/forth.wav","vox/perfect.wav","vox/headshot.wav",
  30. "vox/knife.wav","vox/grenade.wav","vox/inferno.wav","vox/taser.wav"};
  31.  
  32. new String:NAME_OVERLAYS[][] = {"overlays/kill/kill_1","overlays/kill/kill_2",
  33. "overlays/kill/kill_3","overlays/kill/kill_4","overlays/kill/kill_5","overlays/kill/kill_headshot",
  34. "overlays/kill/kill_knife","overlays/kill/kill_hegrenade","overlays/kill/kill_inferno","overlays/kill/kill_taser"};
  35.  
  36. new Handle:g_taskCountdown[33] = INVALID_HANDLE,Handle:g_taskClean[33] = INVALID_HANDLE;
  37. new g_killCount[33] = 0,g_iMaxClients = 0;
  38. new bool:g_bShowAuthor[33] = false;
  39.  
  40. public OnPluginStart()
  41. {
  42. // Add your own code here...
  43. HookEvent("player_death", Event_PlayerDeath);
  44. HookEvent("round_start", Event_round_start,EventHookMode_Post);
  45. }
  46.  
  47. public OnMapStart()
  48. {
  49. for(new i = 0;i<sizeof(SND_KILLVOICE);i++)
  50. PrecacheSound(SND_KILLVOICE[i]);
  51.  
  52. AddFolderToDownloadsTable("materials/overlays/kill");
  53. AddFolderToDownloadsTable("sound/vox");
  54.  
  55. ServerCommand("sv_cheats 1");
  56. g_iMaxClients = GetMaxClients();
  57. }
  58.  
  59. public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
  60. {
  61. new victim = GetClientOfUserId(GetEventInt(event, "userid"))
  62. new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  63. new bool:headshot = GetEventBool(event, "headshot");
  64. new String:weapon[32];
  65. GetEventString(event, "weapon",weapon, sizeof(weapon));
  66.  
  67. g_killCount[victim] = 0;
  68. if(g_taskCountdown[victim] !=INVALID_HANDLE)
  69. {
  70. KillTimer(g_taskCountdown[victim]);
  71. g_taskCountdown[victim] =INVALID_HANDLE;
  72. }
  73.  
  74. if(attacker <1 || attacker == victim )
  75. return;
  76.  
  77. if(IsFakeClient(attacker) || GetEntityTeam(attacker) == GetEntityTeam(victim))
  78. return;
  79.  
  80. if(g_killCount[attacker] <5)
  81. g_killCount[attacker]++;
  82.  
  83. if(g_taskCountdown[attacker] !=INVALID_HANDLE)
  84. {
  85. KillTimer(g_taskCountdown[attacker]);
  86. g_taskCountdown[attacker] =INVALID_HANDLE;
  87. }
  88. g_taskCountdown[attacker] = CreateTimer(2.0,task_Countdown,attacker,1);
  89.  
  90. if(g_killCount[attacker] == 1)
  91. {
  92. if(StrEqual(weapon,"hegrenade"))
  93. ShowKillMessage(attacker,kill_hegrenade);
  94. else if(StrEqual(weapon,"knife"))
  95. ShowKillMessage(attacker,kill_knife);
  96. else if(StrEqual(weapon,"inferno"))
  97. ShowKillMessage(attacker,kill_inferno);
  98. else if(StrEqual(weapon,"taser"))
  99. ShowKillMessage(attacker,kill_taser);
  100. else if(headshot)
  101. ShowKillMessage(attacker,kill_headshot);
  102. else
  103. ShowKillMessage(attacker,kill_1);
  104. }
  105. else
  106. ShowKillMessage(attacker,g_killCount[attacker]-1);
  107.  
  108. if(g_taskClean[attacker] !=INVALID_HANDLE)
  109. {
  110. KillTimer(g_taskClean[attacker]);
  111. g_taskClean[attacker] =INVALID_HANDLE;
  112. }
  113. g_taskClean[attacker] = CreateTimer(3.0,task_Clean,attacker);
  114. }
  115.  
  116. public Event_round_start(Handle:event,const String:name[],bool:dontBroadcast)
  117. {
  118. for(new client=1;client <= g_iMaxClients;client++)
  119. {
  120. g_killCount[client] = 0;
  121. if(g_taskCountdown[client] !=INVALID_HANDLE)
  122. {
  123. KillTimer(g_taskCountdown[client]);
  124. g_taskCountdown[client] =INVALID_HANDLE;
  125. }
  126.  
  127. g_bShowAuthor[client] = GetRandomInt(1,3)==1 ? true : false;
  128. //PrintToConsole(1,"CCC %d",client);
  129. }
  130. }
  131.  
  132. public Action:task_Countdown(Handle:Timer, any:client)
  133. {
  134. g_killCount[client] --;
  135. if(!IsPlayerAlive(client) || g_killCount[client]==0)
  136. {
  137. KillTimer(Timer);
  138. g_taskCountdown[client] = INVALID_HANDLE;
  139. }
  140. }
  141.  
  142. public Action:task_Clean(Handle:Timer, any:client)
  143. {
  144. KillTimer(Timer);
  145. g_taskClean[client] = INVALID_HANDLE;
  146.  
  147. //if(!IsPlayerUseZoomWeapon(client)&&IsClientZooming(client))
  148. //return;
  149. ClientCommand(client, "r_screenoverlay \"\"");
  150. }
  151.  
  152. public ShowKillMessage(client,type)
  153. {
  154.  
  155. EmitSoundToClient(client,SND_KILLVOICE[type],SOUND_FROM_PLAYER,SNDCHAN_VOICE);
  156. //ClientCommand(client, "playgamesound \"%s\"",SND_KILLVOICE[type])
  157.  
  158. ClientCommand(client, "r_screenoverlay \"%s\"",NAME_OVERLAYS[type]);
  159.  
  160. if(g_bShowAuthor[client])
  161. {
  162. g_bShowAuthor[client] = false;
  163. ShowKeyHintText(client," 欢迎使用CS:GO杀敌提 -By fs_wTong www.devzone.cn");
  164. }
  165. }
  166.  
  167. public OnClientConnected(client)
  168. {
  169. ClientCommand(client,"r_drawscreenoverlay 1");
  170. }
  171.  
  172. public OnClientDisconnect_Post(client)
  173. {
  174. if(g_taskCountdown[client] !=INVALID_HANDLE)
  175. {
  176. KillTimer(g_taskCountdown[client]);
  177. g_taskCountdown[client] =INVALID_HANDLE;
  178. }
  179.  
  180. if(g_taskClean[client] !=INVALID_HANDLE)
  181. {
  182. KillTimer(g_taskClean[client]);
  183. g_taskClean[client] =INVALID_HANDLE;
  184. }
  185. }
  186.  
  187. public ShowKeyHintText(client,String:sMessage[])
  188. {
  189. new Handle:hBuffer = StartMessageOne("KeyHintText", client);
  190. if(hBuffer==INVALID_HANDLE)
  191. return;
  192. BfWriteByte(hBuffer, 1);
  193. BfWriteString(hBuffer,sMessage);
  194. EndMessage();
  195. }
  196.  
  197.  
  198. stock GetEntityTeam(entity)
  199. {
  200. return GetEntProp(entity, Prop_Send, "m_iTeamNum");
  201. }
  202.  
  203. stock AddFolderToDownloadsTable(const String:sDirectory[])
  204. {
  205. decl String:sFile[64], String:sPath[512];
  206. new FileType:iType, Handle:hDir = OpenDirectory(sDirectory);
  207. while(ReadDirEntry(hDir, sFile, sizeof(sFile), iType))
  208. {
  209. if(iType == FileType_File)
  210. {
  211. Format(sPath, sizeof(sPath), "%s/%s", sDirectory, sFile);
  212. AddFileToDownloadsTable(sPath);
  213. }
  214. }
  215. }