Advertisement
FlacoBey

Untitled

Feb 2nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.13 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. public OnPluginStart()
  12. {
  13.     CreateTimer(1.0, TimerOut, _, TIMER_REPEAT);
  14. }
  15.  
  16. public Action:TimerOut(Handle timer, fuck)
  17. {
  18.     LoopPlayers(i)
  19.    
  20.     if (pipe_peremenya[i] > 0)
  21.     {
  22.         pipe_peremenya[i]--;
  23.     }
  24. }
  25.  
  26. public OnClientPutInServer(client)
  27. {
  28.     SDKHook(client, SDKHook_WeaponCanSwitchTo, WeaponSwitchPost);
  29. }
  30.  
  31. public OnClientDisconnect(client)
  32. {
  33.     SDKUnhook(client, SDKHook_WeaponCanSwitchTo, WeaponSwitchPost);
  34. }
  35.  
  36. public Action:WeaponSwitchPost(client, weapon)
  37. {
  38.     if(bIsSurvivor(client))
  39.     {
  40.         new pipe = GetPlayerWeaponSlot(client, 2);
  41.         if(GetClientButtons(client) & IN_ATTACK)
  42.         {
  43.             if(pipe > 0)
  44.             {
  45.                 return Plugin_Handled;
  46.             }
  47.         }
  48.     }
  49.     return Plugin_Continue;
  50. }
  51.  
  52. public Action:OnPlayerRunCmd(client, &buttons,  &impulse, float vel[3], float angles[3], int& weapon)
  53. {
  54.     if (timerpip[client] == INVALID_HANDLE)
  55.     {
  56.         new iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  57.  
  58.         if(!IsValidEntity(iCurrentWeapon))
  59.         return Plugin_Continue;
  60.    
  61.         decl String:weaponclass[32];
  62.         GetEntityClassname(iCurrentWeapon, weaponclass, sizeof(weaponclass));
  63.         if(buttons & IN_ATTACK)
  64.         {
  65.             if (StrEqual(weaponclass, "weapon_pipe_bomb"))
  66.             {
  67.                 pipe_peremenya[client] = 6.0;
  68.                 timerpip[client] = CreateTimer(6.0, timerpipe, client, TIMER_FLAG_NO_MAPCHANGE);
  69.             }
  70.         }
  71.     }
  72.     if (!(buttons & IN_ATTACK))
  73.     {
  74.         if(timerpip[client] != INVALID_HANDLE)
  75.         {
  76.             KillTimer(timerpip[client]);
  77.             timerpip[client] = INVALID_HANDLE;
  78.             CreateTimer(pipe_peremenya[client], TimerBomb, client);
  79.         }
  80.     }
  81.     return Plugin_Continue;
  82. }
  83.  
  84. public Action:TimerBomb(Handle timer,any client)
  85. {
  86.     new entity = EntRefToEntIndex(pipebomb[client]);
  87.     if(entity > 0)
  88.     {
  89.         float origin[3];
  90.         SetEntProp(entity, Prop_Data, "m_takedamage", 2 );
  91.         SDKHooks_TakeDamage(entity, 0, 0, 1.0);
  92.         GetEntPropVector(entity, Prop_Send, "m_vecOrigin", origin);
  93.         //LittleFlower(origin)
  94.     }
  95. }
  96.  
  97. public Action:timerpipe(Handle timer, any client)
  98. {
  99.     KillTimer(timerpip[client]);
  100.     timerpip[client] = INVALID_HANDLE;
  101.     float origin2[3];
  102.     GetEntPropVector(client, Prop_Send, "m_vecOrigin", origin2);
  103.     new pipe = GetPlayerWeaponSlot(client, 2);
  104.     RemovePlayerItem(client, pipe)
  105.     LittleFlower(origin2);
  106. }
  107.  
  108. public OnEntityCreated(int ent, const char[] class)
  109. {
  110.     if(StrEqual(class, "pipe_bomb_projectile"))
  111.     {
  112.         CreateTimer(0.1, OnHeSpawned, EntIndexToEntRef(ent), TIMER_FLAG_NO_MAPCHANGE);
  113.     }
  114. }
  115.  
  116. public Action:OnHeSpawned(Handle:timer, any:ent)
  117. {
  118.     decl client;
  119.     if ((ent = EntRefToEntIndex(ent)) > 0 && (client = GetEntPropEnt(ent, Prop_Data, "m_hThrower")) > 0 && IsClientInGame(client))
  120.     {
  121.         pipebomb[client] = EntIndexToEntRef(ent);
  122.     }
  123.     return Plugin_Stop;
  124. }
  125.  
  126. public LittleFlower(Float:pos[3])
  127. {
  128.     new entity = CreateEntityByName("prop_physics");
  129.     if (IsValidEntity(entity))
  130.     {
  131.         pos[2] += 1.0;
  132.         DispatchKeyValue(entity, "model", "models/props_junk/propanecanister001a.mdl");
  133.         DispatchSpawn(entity);
  134.         SetEntData(entity, GetEntSendPropOffs(entity, "m_CollisionGroup"), 1, 1, true);
  135.         SetEntityRenderMode(entity, RENDER_TRANSCOLOR);
  136.         SetEntityRenderColor(entity, 255, 255, 255, 0);
  137.         TeleportEntity(entity, pos, NULL_VECTOR, NULL_VECTOR);
  138.         AcceptEntityInput(entity, "break");
  139.     }
  140. }
  141.  
  142. /*
  143. FindEntityByClassname2(startEnt, const String:classname[])
  144. {
  145.     while (startEnt > -1 && !IsValidEntity(startEnt)) startEnt--;
  146.     return FindEntityByClassname(startEnt, classname);
  147. }
  148. */
  149.  
  150. stock bool:bIsSurvivor(int client)
  151. {
  152.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement