Advertisement
FlacoBey

Untitled

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