FlacoBey

Untitled

May 6th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.36 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <sdkhooks>
  4.  
  5. #define LoopPlayers(%0) for (int %0 = MaxClients; %0 != 0; --%0) if (IsClientInGame(%0))
  6.  
  7. float pipe_peremenya[MAXPLAYERS+1] = 0.0;
  8. new pipebomb[MAXPLAYERS+1];
  9. Handle:timerpip[MAXPLAYERS+1] = INVALID_HANDLE;
  10.  
  11. bool IsAttackPipe[MAXPLAYERS+1] = false;
  12.  
  13. Handle sdkActivatePipe;
  14.  
  15. public OnPluginStart()
  16. {
  17.     Handle hGameConf = LoadGameConfigFile("pipe_bomb");
  18.     if( hGameConf == null )
  19.         SetFailState("Couldn't find the offsets and signatures file. Please, check that it is installed correctly.");
  20.     StartPrepSDKCall(SDKCall_Static);
  21.     if( PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "CPipeBombProjectile_Create") == false )
  22.         SetFailState("Could not load the \"CPipeBombProjectile_Create\" gamedata signature.");
  23.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  24.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  25.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  26.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  27.     PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);
  28.     PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
  29.     PrepSDKCall_SetReturnInfo(SDKType_CBaseEntity, SDKPass_Pointer);
  30.     sdkActivatePipe = EndPrepSDKCall();
  31.     if( sdkActivatePipe == null )
  32.         SetFailState("Could not prep the \"CPipeBombProjectile_Create\" function.");
  33.        
  34.     CreateTimer(1.0, TimerOut, _, TIMER_REPEAT);
  35. }
  36.  
  37. public OnClientPutInServer(client)
  38. {
  39.     SDKHook(client, SDKHook_WeaponSwitchPost, WeaponSwitchPost);
  40. }
  41.  
  42. public OnClientDisconnect(client)
  43. {
  44.     SDKUnhook(client, SDKHook_WeaponSwitchPost, WeaponSwitchPost);
  45. }
  46.  
  47. public void WeaponSwitchPost(int client, int weapon)
  48. {
  49.     if(bIsSurvivor(client))
  50.     {
  51.         if(IsAttackPipe[client])
  52.         {
  53.             int slot = GetPlayerWeaponSlot(client, 2)
  54.             if(IsValidEntity(slot))
  55.             {
  56.                 RemovePlayerItem(client, slot)
  57.                
  58.                 float vPos[3]
  59.                 GetEntPropVector(client, Prop_Send, "m_vecOrigin", vPos);
  60.                 int entity = SDKCall(sdkActivatePipe, vPos, 0.0, 90.0, 0.0, client, 15.0);
  61.                 if(IsValidEntity(entity))
  62.                 {
  63.                     SetEntProp(entity, Prop_Send, "m_nSolidType", 0);
  64.                     TeleportEntity(entity, vPos, NULL_VECTOR, NULL_VECTOR);
  65.                     CreateTimer(pipe_peremenya[client], vDropPipe, EntIndexToEntRef(entity))
  66.                 }
  67.             }
  68.         }
  69.     }
  70. }
  71.  
  72. public Action vDropPipe(Handle timer, entity)
  73. {
  74.     if (EntRefToEntIndex(entity) > 0)
  75.     {
  76.         float vOrigin[3];
  77.         GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vOrigin);
  78.         AcceptEntityInput(entity, "kill");
  79.         LittleFlower(vOrigin)
  80.     }
  81. }
  82.  
  83. public Action:TimerOut(Handle timer, fuck)
  84. {
  85.     LoopPlayers(i)
  86.    
  87.     if (pipe_peremenya[i] > 0)
  88.     {
  89.         pipe_peremenya[i]--;
  90.     }
  91. }
  92.  
  93. public Action:OnPlayerRunCmd(client, &buttons,  &impulse, float vel[3], float angles[3], int& weapon)
  94. {
  95.     if (timerpip[client] == INVALID_HANDLE)
  96.     {
  97.         new iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  98.  
  99.         if(!IsValidEntity(iCurrentWeapon))
  100.         return Plugin_Continue;
  101.  
  102.         decl String:weaponclass[32];
  103.         GetEntityClassname(iCurrentWeapon, weaponclass, sizeof(weaponclass));
  104.         if(buttons & IN_ATTACK)
  105.         {
  106.             if (StrEqual(weaponclass, "weapon_pipe_bomb"))
  107.             {
  108.                 IsAttackPipe[client] = true;
  109.                 pipe_peremenya[client] = 6.0;
  110.                 timerpip[client] = CreateTimer(6.0, timerpipe, client, TIMER_FLAG_NO_MAPCHANGE);
  111.             }
  112.         }
  113.     }
  114.     if (!(buttons & IN_ATTACK))
  115.     {
  116.         if(timerpip[client] != INVALID_HANDLE)
  117.         {
  118.             IsAttackPipe[client] = false;
  119.             KillTimer(timerpip[client]);
  120.             timerpip[client] = INVALID_HANDLE;
  121.             CreateTimer(pipe_peremenya[client], TimerBomb, client);
  122.         }
  123.     }
  124.     return Plugin_Continue;
  125. }
  126.  
  127. public Action:TimerBomb(Handle timer,any client)
  128. {
  129.     new entity = EntRefToEntIndex(pipebomb[client]);
  130.     if(entity > 0)
  131.     {
  132.         float origin[3];
  133.         AcceptEntityInput(entity, "kill");
  134.         GetEntPropVector(entity, Prop_Send, "m_vecOrigin", origin);
  135.         LittleFlower(origin)
  136.     }
  137. }
  138.  
  139. public Action:timerpipe(Handle timer, any client)
  140. {
  141.     KillTimer(timerpip[client]);
  142.     timerpip[client] = INVALID_HANDLE;
  143.     float origin2[3];
  144.     GetEntPropVector(client, Prop_Send, "m_vecOrigin", origin2);
  145.     ForcePlayerSuicide(client);
  146.     LittleFlower(origin2);
  147. }
  148.  
  149. public OnEntityCreated(int ent, const char[] class)
  150. {
  151.     if(StrEqual(class, "pipe_bomb_projectile"))
  152.     {
  153.         CreateTimer(0.1, OnHeSpawned, EntIndexToEntRef(ent), TIMER_FLAG_NO_MAPCHANGE);
  154.     }
  155. }
  156.  
  157. public Action:OnHeSpawned(Handle:timer, any:ent)
  158. {
  159.     decl client;
  160.     if ((ent = EntRefToEntIndex(ent)) > 0 && (client = GetEntPropEnt(ent, Prop_Data, "m_hThrower")) > 0 && IsClientInGame(client))
  161.     {
  162.         pipebomb[client] = EntIndexToEntRef(ent);
  163.     }
  164.     return Plugin_Stop;
  165. }
  166.  
  167. public LittleFlower(Float:pos[3])
  168. {
  169.     new entity = CreateEntityByName("prop_physics");
  170.     if (IsValidEntity(entity))
  171.     {
  172.         pos[2] += 1.0;
  173.         DispatchKeyValue(entity, "model", "models/props_junk/propanecanister001a.mdl");
  174.         DispatchSpawn(entity);
  175.         SetEntData(entity, GetEntSendPropOffs(entity, "m_CollisionGroup"), 1, 1, true);
  176.         SetEntityRenderMode(entity, RENDER_TRANSCOLOR);
  177.         SetEntityRenderColor(entity, 255, 255, 255, 0);
  178.         TeleportEntity(entity, pos, NULL_VECTOR, NULL_VECTOR);
  179.         AcceptEntityInput(entity, "break");
  180.     }
  181. }
  182.  
  183. stock bool:bIsSurvivor(int client)
  184. {
  185.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  186. }
Advertisement
Add Comment
Please, Sign In to add comment