Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.00 KB | None | 0 0
  1. #pragma semicolon 1
  2. #pragma newdecls required
  3.  
  4. #include <sdktools>
  5. #include <sdkhooks>
  6.  
  7. #define BeepSound "weapons/hegrenade/beep.wav"
  8.  
  9. int viTimerDude[MAXPLAYERS+1], pipebomb[MAXPLAYERS+1], iRef[MAXPLAYERS + 1];
  10. Handle vTimerPipe[MAXPLAYERS+1], sdkKillPipe, sdkActivatePipe;
  11. ConVar iTimerPipeBomb;
  12. bool vSwitch[MAXPLAYERS+1], bSoundStop[MAXPLAYERS + 1];
  13. Handle gTimer;
  14.  
  15. public void OnPluginStart()
  16. {
  17. Handle hGameConf = LoadGameConfigFile("Realistico.GameData");
  18. StartPrepSDKCall(view_as<SDKCallType>(1));
  19. if (!(PrepSDKCall_SetFromConf(hGameConf, view_as<SDKFuncConfSource>(1), "iDetonatePipeBomb")))
  20. SetFailState("Could not load the \"iDetonatePipeBomb\" gamedata signature.");
  21. sdkKillPipe = EndPrepSDKCall();
  22.  
  23. StartPrepSDKCall(SDKCall_Static);
  24. if ( PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "CPipeBombProjectile_Create") == false )
  25. SetFailState("Could not load the \"CPipeBombProjectile_Create\" gamedata signature.");
  26. PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  27. PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  28. PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  29. PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  30. PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);
  31. PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
  32. PrepSDKCall_SetReturnInfo(SDKType_CBaseEntity, SDKPass_Pointer);
  33. sdkActivatePipe = EndPrepSDKCall();
  34. if ( sdkActivatePipe == null )
  35. SetFailState("Could not prep the \"CPipeBombProjectile_Create\" function.");
  36. iTimerPipeBomb = FindConVar("pipe_bomb_timer_duration");
  37. HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
  38. }
  39.  
  40. public void OnMapStart()
  41. {
  42. PrecacheSound(BeepSound, true);
  43. }
  44.  
  45. public Action Event_RoundEnd(Handle event, const char[] name, bool dontbroadcast)
  46. {
  47. for (int i = 1; i <= MaxClients; i++)
  48. {
  49. viTimerDude[i] = 0;
  50. pipebomb[i] = 0;
  51. vSwitch[i] = false;
  52. if(vTimerPipe[i] != null)
  53. {
  54. KillTimer(vTimerPipe[i]);
  55. vTimerPipe[i] = null;
  56. }
  57. }
  58. if(gTimer != null)
  59. {
  60. KillTimer(gTimer);
  61. gTimer = null;
  62. }
  63. }
  64.  
  65. public Action TimerOut(Handle timer)
  66. {
  67. bool set;
  68. for (int i = 1; i <= MaxClients; i++)
  69. {
  70. if (IsClientInGame(i) && viTimerDude[i] > 0)
  71. {
  72. viTimerDude[i]--;
  73. PrintHintText(i, "Time to detonate %d", viTimerDude[i]);
  74. if (bSoundStop[i])
  75. StopSound(i, 50, BeepSound);
  76. else
  77. EmitSoundToAll(BeepSound, i, 50);
  78. set = true;
  79. }
  80. }
  81.  
  82. if( !set )
  83. {
  84. gTimer = null;
  85. return Plugin_Stop;
  86. }
  87. return Plugin_Continue;
  88. }
  89.  
  90. public Action tStop (Handle timer, any i)
  91. {
  92. if ((i = GetClientOfUserId(i)) > 0 && i <= MaxClients && IsClientInGame(i))
  93. StopSound(i, 50, BeepSound);
  94. }
  95.  
  96. public void OnClientPutInServer(int client)
  97. {
  98. SDKHook(client, SDKHook_WeaponSwitch, WeaponSwitch);
  99. }
  100.  
  101. public Action WeaponSwitch(int client, int deleted)
  102. {
  103. if(vSwitch[client])
  104. {
  105. vSwitch[client] = false;
  106. int iPipe = GetPlayerWeaponSlot(client, 2);
  107. if(!IsValidEntity(iPipe))
  108. return Plugin_Continue;
  109. char sWeaponEx[32];
  110. GetEntityClassname(iPipe, sWeaponEx, sizeof(sWeaponEx));
  111. if(strcmp(sWeaponEx, "weapon_pipe_bomb") == 0)
  112. {
  113. if(vTimerPipe[client] != null)
  114. {
  115. KillTimer(vTimerPipe[client]);
  116. vTimerPipe[client] = null;
  117. }
  118. RemovePlayerItem(client, iPipe);
  119. AcceptEntityInput(iPipe, "Kill");
  120. float vAng[3], vPos[3];
  121. GetEntPropVector(client, Prop_Send, "m_vecOrigin", vPos);
  122. vPos[2] += 40.0;
  123. int entity = SDKCall(sdkActivatePipe, vPos, vAng, vAng, vAng, client, 2.0);
  124. CreateTimer(float(viTimerDude[client]), vDropPipeBomb, EntIndexToEntRef(entity));
  125. return Plugin_Continue;
  126. }
  127. }
  128. return Plugin_Continue;
  129. }
  130.  
  131. public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon)
  132. {
  133. if (vTimerPipe[client] == null)
  134. {
  135. int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  136.  
  137. if (!(buttons & IN_ATTACK))
  138. bSoundStop[client] = true;
  139.  
  140. if (!IsValidEntity(iCurrentWeapon))
  141. return Plugin_Continue;
  142.  
  143. char weaponclass[32];
  144. GetEntityClassname(iCurrentWeapon, weaponclass, sizeof(weaponclass));
  145. if (buttons & IN_ATTACK)
  146. {
  147. if (strcmp(weaponclass, "weapon_pipe_bomb") == 0)
  148. {
  149. vSwitch[client] = true;
  150. viTimerDude[client] = iTimerPipeBomb.IntValue * 2;
  151. vTimerPipe[client] = CreateTimer(float(viTimerDude[client]), timerpipe, GetClientUserId(client));
  152. int entity = CreateEntityByName("info_goal_infected_chase");
  153.  
  154. if(IsValidEntity(entity))
  155. {
  156. SetVariantString("!activator");
  157. AcceptEntityInput(entity, "SetParent", client);
  158. DispatchSpawn(entity);
  159. TeleportEntity(entity, view_as<float>({0.0, 0.0, 0.0}), NULL_VECTOR, NULL_VECTOR);
  160. AcceptEntityInput(entity, "Enable");
  161.  
  162. iRef[client] = EntIndexToEntRef(entity);
  163. }
  164.  
  165. bSoundStop[client] = false;
  166. if( gTimer == null )
  167. gTimer = CreateTimer(0.5, TimerOut, _, TIMER_REPEAT);
  168. }
  169. }
  170. }
  171. else
  172. {
  173. if (!(buttons & IN_ATTACK))
  174. {
  175. KillTimer(vTimerPipe[client]);
  176. vTimerPipe[client] = null;
  177. vSwitch[client] = false;
  178. CreateTimer(float(viTimerDude[client]), TimerBomb, GetClientUserId(client));
  179. int entity = INVALID_ENT_REFERENCE;
  180. if((entity = EntRefToEntIndex(iRef[client])) != INVALID_ENT_REFERENCE)
  181. {
  182. AcceptEntityInput(entity, "kill");
  183. iRef[client] = INVALID_ENT_REFERENCE;
  184. }
  185. StopSound(client, 50, BeepSound);
  186. }
  187. }
  188.  
  189. return Plugin_Continue;
  190. }
  191.  
  192. public Action vDropPipeBomb(Handle timer, any ref)
  193. {
  194. int entity = EntRefToEntIndex(ref);
  195. if(IsValidEntity(entity))
  196. SDKCall(sdkKillPipe, entity);
  197. }
  198.  
  199. public Action TimerBomb(Handle timer, int client)
  200. {
  201. client = GetClientOfUserId(client);
  202. if(!client || !IsClientInGame(client)) return;
  203. vSwitch[client] = false;
  204. if (IsValidEntRef(pipebomb[client]))
  205. {
  206. int entity = EntRefToEntIndex(pipebomb[client]);
  207. SDKCall(sdkKillPipe, entity);
  208. }
  209. }
  210.  
  211. public Action timerpipe(Handle timer, int client)
  212. {
  213. client = GetClientOfUserId(client);
  214. if(!client || !IsClientInGame(client)) return;
  215.  
  216. vSwitch[client] = false;
  217. vTimerPipe[client] = null;
  218. int iPipe = GetPlayerWeaponSlot(client, 2);
  219. if (IsValidEntity(iPipe))
  220. {
  221. RemovePlayerItem(client, iPipe);
  222. AcceptEntityInput(iPipe, "Kill");
  223. }
  224. ForcePlayerSuicide(client);
  225.  
  226. int iRefrence = INVALID_ENT_REFERENCE;
  227. if((iRefrence = EntRefToEntIndex(iRef[client])) != INVALID_ENT_REFERENCE)
  228. {
  229. AcceptEntityInput(iRefrence, "kill");
  230. iRef[client] = INVALID_ENT_REFERENCE;
  231. }
  232.  
  233. float vPos[3];
  234. GetEntPropVector(client, Prop_Send, "m_vecOrigin", vPos);
  235. vPos[2] += 40.0;
  236. int entity = CreateEntityByName("prop_physics");
  237. if(IsValidEntity(entity))
  238. {
  239. DispatchKeyValue(entity, "model", "models/props_junk/propanecanister001a.mdl");
  240. DispatchSpawn(entity);
  241. TeleportEntity(entity, vPos, NULL_VECTOR, NULL_VECTOR);
  242. AcceptEntityInput(entity, "break");
  243. }
  244. }
  245.  
  246. public void OnEntityCreated(int entity, const char[] class)
  247. {
  248. if (strcmp(class, "pipe_bomb_projectile") == 0)
  249. {
  250. SDKHook(entity, SDKHook_SpawnPost, SpawnPost);
  251. }
  252. }
  253.  
  254. public void SpawnPost(int entity)
  255. {
  256. RequestFrame(nextFrame, EntIndexToEntRef(entity));
  257. }
  258.  
  259. public void nextFrame(int entity)
  260. {
  261. if( (entity = EntRefToEntIndex(entity)) != INVALID_ENT_REFERENCE )
  262. {
  263. int client;
  264. if ((client = GetEntPropEnt(entity, Prop_Data, "m_hThrower")) > 0 && IsClientInGame(client))
  265. {
  266. pipebomb[client] = EntIndexToEntRef(entity);
  267. }
  268. }
  269. }
  270.  
  271. public Action OnHeSpawned(Handle timer, any ent)
  272. {
  273. int client;
  274. if ((ent = EntRefToEntIndex(ent)) > 0 && (client = GetEntPropEnt(ent, Prop_Data, "m_hThrower")) > 0 && IsClientInGame(client))
  275. {
  276. pipebomb[client] = EntIndexToEntRef(ent);
  277. }
  278. }
  279.  
  280. bool IsValidEntRef(int iEnt)
  281. {
  282. if (iEnt && EntRefToEntIndex(iEnt) != INVALID_ENT_REFERENCE)
  283. return true;
  284. return false;
  285. }
  286.  
  287. stock bool bIsSurvivor(int client)
  288. {
  289. return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  290. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement