Advertisement
FlacoBey

Untitled

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