FlacoBey

Untitled

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