Advertisement
FlacoBey

Untitled

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