FlacoBey

Untitled

May 6th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.29 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.             RemovePlayerItem(client, GetPlayerWeaponSlot(client, 2))
  54.            
  55.             float vPos[3]
  56.             GetEntPropVector(client, Prop_Send, "m_vecOrigin", vPos);
  57.             int entity = SDKCall(sdkActivatePipe, vPos, 0.0, 90.0, 0.0, client, 15.0);
  58.             if(IsValidEntity(entity))
  59.             {
  60.                 SetEntProp(entity, Prop_Send, "m_nSolidType", 0);
  61.                 TeleportEntity(entity, vPos, NULL_VECTOR, NULL_VECTOR);
  62.                 CreateTimer(pipe_peremenya[client], vDropPipe, EntIndexToEntRef(entity))
  63.             }
  64.         }
  65.     }
  66. }
  67.  
  68. public Action vDropPipe(Handle timer, entity)
  69. {
  70.     if (EntRefToEntIndex(entity) > 0)
  71.     {
  72.         float vOrigin[3];
  73.         GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vOrigin);
  74.         AcceptEntityInput(entity, "kill");
  75.         LittleFlower(vOrigin)
  76.     }
  77. }
  78.  
  79. public Action:TimerOut(Handle timer, fuck)
  80. {
  81.     LoopPlayers(i)
  82.    
  83.     if (pipe_peremenya[i] > 0)
  84.     {
  85.         pipe_peremenya[i]--;
  86.     }
  87. }
  88.  
  89. public Action:OnPlayerRunCmd(client, &buttons,  &impulse, float vel[3], float angles[3], int& weapon)
  90. {
  91.     if (timerpip[client] == INVALID_HANDLE)
  92.     {
  93.         new iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  94.  
  95.         if(!IsValidEntity(iCurrentWeapon))
  96.         return Plugin_Continue;
  97.  
  98.         decl String:weaponclass[32];
  99.         GetEntityClassname(iCurrentWeapon, weaponclass, sizeof(weaponclass));
  100.         if(buttons & IN_ATTACK)
  101.         {
  102.             if (StrEqual(weaponclass, "weapon_pipe_bomb"))
  103.             {
  104.                 IsAttackPipe[client] = true;
  105.                 pipe_peremenya[client] = 6.0;
  106.                 timerpip[client] = CreateTimer(6.0, timerpipe, client, TIMER_FLAG_NO_MAPCHANGE);
  107.             }
  108.         }
  109.     }
  110.     if (!(buttons & IN_ATTACK))
  111.     {
  112.         if(timerpip[client] != INVALID_HANDLE)
  113.         {
  114.             IsAttackPipe[client] = false;
  115.             KillTimer(timerpip[client]);
  116.             timerpip[client] = INVALID_HANDLE;
  117.             CreateTimer(pipe_peremenya[client], TimerBomb, client);
  118.         }
  119.     }
  120.     return Plugin_Continue;
  121. }
  122.  
  123. public Action:TimerBomb(Handle timer,any client)
  124. {
  125.     new entity = EntRefToEntIndex(pipebomb[client]);
  126.     if(entity > 0)
  127.     {
  128.         float origin[3];
  129.         AcceptEntityInput(entity, "kill");
  130.         GetEntPropVector(entity, Prop_Send, "m_vecOrigin", origin);
  131.         LittleFlower(origin)
  132.     }
  133. }
  134.  
  135. public Action:timerpipe(Handle timer, any client)
  136. {
  137.     KillTimer(timerpip[client]);
  138.     timerpip[client] = INVALID_HANDLE;
  139.     float origin2[3];
  140.     GetEntPropVector(client, Prop_Send, "m_vecOrigin", origin2);
  141.     ForcePlayerSuicide(client);
  142.     LittleFlower(origin2);
  143. }
  144.  
  145. public OnEntityCreated(int ent, const char[] class)
  146. {
  147.     if(StrEqual(class, "pipe_bomb_projectile"))
  148.     {
  149.         CreateTimer(0.1, OnHeSpawned, EntIndexToEntRef(ent), TIMER_FLAG_NO_MAPCHANGE);
  150.     }
  151. }
  152.  
  153. public Action:OnHeSpawned(Handle:timer, any:ent)
  154. {
  155.     decl client;
  156.     if ((ent = EntRefToEntIndex(ent)) > 0 && (client = GetEntPropEnt(ent, Prop_Data, "m_hThrower")) > 0 && IsClientInGame(client))
  157.     {
  158.         pipebomb[client] = EntIndexToEntRef(ent);
  159.     }
  160.     return Plugin_Stop;
  161. }
  162.  
  163. public LittleFlower(Float:pos[3])
  164. {
  165.     new entity = CreateEntityByName("prop_physics");
  166.     if (IsValidEntity(entity))
  167.     {
  168.         pos[2] += 1.0;
  169.         DispatchKeyValue(entity, "model", "models/props_junk/propanecanister001a.mdl");
  170.         DispatchSpawn(entity);
  171.         SetEntData(entity, GetEntSendPropOffs(entity, "m_CollisionGroup"), 1, 1, true);
  172.         SetEntityRenderMode(entity, RENDER_TRANSCOLOR);
  173.         SetEntityRenderColor(entity, 255, 255, 255, 0);
  174.         TeleportEntity(entity, pos, NULL_VECTOR, NULL_VECTOR);
  175.         AcceptEntityInput(entity, "break");
  176.     }
  177. }
  178.  
  179. stock bool:bIsSurvivor(int client)
  180. {
  181.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  182. }
Add Comment
Please, Sign In to add comment