Shadax

grenadier

Feb 8th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.78 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <sdkhooks>
  4. #include <cstrike>
  5.  
  6. #define MAXENTITIES 2048
  7.  
  8. public Plugin:myinfo =
  9. {
  10.     name = "[CS:GO] Grenadier",
  11.     description = "Zabawa calodniowa Grenadier ",
  12.     author = "",
  13.     version = "1.0",
  14.     url = ""
  15. };
  16.  
  17. // ConVars
  18. new Handle:g_hGiveTime = INVALID_HANDLE;
  19. new Handle:g_hPrint = INVALID_HANDLE;
  20. new Handle:g_hRemovetimer = INVALID_HANDLE;
  21. new Handle:g_hBounces = INVALID_HANDLE;
  22. new Handle:g_hRandom = INVALID_HANDLE;
  23. new Handle:g_hRandomMax = INVALID_HANDLE;
  24. new Handle:g_hRandomMin = INVALID_HANDLE;
  25. new Handle:g_hRoundStartAdvert = INVALID_HANDLE;
  26. new Handle:g_hClientHealth = INVALID_HANDLE;
  27. new Handle:g_hClientArmor = INVALID_HANDLE;
  28. new Handle:g_hDBDamage = INVALID_HANDLE;
  29. new Handle:g_hDebug = INVALID_HANDLE;
  30. new Handle:g_hAutoMode = INVALID_HANDLE;
  31. new Handle:g_hLogFile = INVALID_HANDLE;
  32. new Handle:g_hEnabled = INVALID_HANDLE;
  33. new Handle:g_hGEnabled = INVALID_HANDLE;
  34.  
  35. // ConVar Values
  36. new Float:g_fGiveTime;
  37. new bool:g_bPrint;
  38. new Float:g_fRemoveTimer;
  39. new g_iBounces;
  40. new g_iRandom;
  41. new g_iRandomMax;
  42. new g_iRandomMin;
  43. new bool:g_bRoundStartAd;
  44. new g_iClientHealth;
  45. new g_iClientArmor;
  46. new Float:g_fDBDamage;
  47. new bool:g_bDebug;
  48. new bool:g_bAutoMode;
  49. new String:g_sLogFile[PLATFORM_MAX_PATH];
  50. new bool:g_bEnabled;
  51. new bool:g_bGEnabled;
  52.  
  53. // Other Values
  54. new g_iBounceCount[MAXENTITIES+1];
  55. new g_iBouncesRand;
  56. new g_iBouncesRandClient[MAXPLAYERS+1];
  57. new String:g_sRECC2[MAX_NAME_LENGTH];
  58. new String:g_sLogFilePath[PLATFORM_MAX_PATH];
  59.  
  60. public OnPluginStart()
  61. {
  62.     // Events.
  63.     HookEvent("player_spawn", Event_PlayerSpawn);
  64.     HookEvent("round_start", Event_RoundStart);
  65.     HookEvent("round_end", Event_RoundEnd);
  66.    
  67.     // Convars.
  68.     g_hGiveTime = CreateConVar("sm_db_give_time", "1.0", "The delay on giving grenades after being thrown.");
  69.     g_hPrint = CreateConVar("sm_db_equip_notify", "0", "Whether to print to chat or not when a client spawns with a grenade.");
  70.     g_hRemovetimer = CreateConVar("sm_db_remove_timer", "30.0", "Every X seconds, it will remove all grenades on the map.");
  71.     g_hBounces = CreateConVar("sm_db_bounces", "10", "Amount of bounces the grenade can have (off a surface), before destroying. This is ineffective if random mode is on.");
  72.     g_hRandom = CreateConVar("sm_db_random", "0", "If enabled, a random number depending on \"sm_db_random_max\" and \"sm_db_random_min\" will be used for the amount of bounces a grenade (grenade) can have. (1 = Mode 1, 2 = Mode 2, 3 = Mode 3 0 = Off). More information about the modes on the AlliedMods thread.");
  73.     g_hRandomMax = CreateConVar("sm_db_random_max", "3", "The maximum amount of bounces the grenade (grenade) can have using random mode.");
  74.     g_hRandomMin = CreateConVar("sm_db_random_min", "1", "The minimum amount of bounces the grenade (grenade) can have using random mode.");
  75.     g_hRoundStartAdvert = CreateConVar("sm_db_rs_advert", "1", "Enables the Round Start advertisement.");
  76.     g_hClientHealth = CreateConVar("sm_db_client_health", "100", "Set the health to this number on client spawn.");
  77.     g_hClientArmor = CreateConVar("sm_db_client_armor", "0", "Set the armor to this number on client spawn.");
  78.     g_hDBDamage = CreateConVar("sm_db_damage", "0", "The amount of damage the grenades (grenades) do.");
  79.     g_hDebug = CreateConVar("sm_db_debug", "0", "Enables debugging for grenade (will spam the SourceMod logs if enabled).");
  80.     g_hAutoMode = CreateConVar("sm_db_automode", "1", "If 1, if the HP/Armor ConVar is changed, all current alive players will be set to the values.");
  81.     g_hLogFile = CreateConVar("sm_db_logfile", "logs/grenade.log", "The logging file starting from the SourceMod directory.");
  82.     g_hEnabled = CreateConVar("sm_db_enabled", "1", "Enables grenade.");
  83.     g_hGEnabled = CreateConVar("sm_db_give_enabled", "1", "Enable/Disable the plugin giving grenades.");
  84.    
  85.     // AlliedMods Release.
  86.     CreateConVar("sm_db_version", "1.0", "The current version of CS:GO grenade.");
  87.    
  88.     // Hook ConVar Changes
  89.     HookConVarChange(g_hGiveTime, CVarChanged);
  90.     HookConVarChange(g_hPrint, CVarChanged);
  91.     HookConVarChange(g_hRemovetimer, CVarChanged);
  92.     HookConVarChange(g_hBounces, CVarChanged);
  93.     HookConVarChange(g_hRandom, CVarChanged);
  94.     HookConVarChange(g_hRandomMax, CVarChanged);
  95.     HookConVarChange(g_hRandomMin, CVarChanged);
  96.     HookConVarChange(g_hRoundStartAdvert, CVarChanged);
  97.     HookConVarChange(g_hClientHealth, CVarChanged);
  98.     HookConVarChange(g_hClientArmor, CVarChanged);
  99.     HookConVarChange(g_hDBDamage, CVarChanged);
  100.     HookConVarChange(g_hDebug, CVarChanged);
  101.     HookConVarChange(g_hAutoMode, CVarChanged);
  102.     HookConVarChange(g_hLogFile, CVarChanged);
  103.     HookConVarChange(g_hEnabled, CVarChanged);
  104.     HookConVarChange(g_hGEnabled, CVarChanged);
  105.    
  106.     // Auto execute the config!
  107.     AutoExecConfig(true, "plugin.grenade");
  108.    
  109.     // Late Loading
  110.     for (new i = 1; i <= MaxClients; i++)
  111.     {
  112.         if (IsClientInGame(i))
  113.         {
  114.             OnClientPutInServer(i);
  115.         }
  116.     }
  117. }
  118.  
  119. public CVarChanged(Handle:hCvar, const String:sOldv[], const String:sNewv[])
  120. {
  121.     OnConfigsExecuted();
  122.    
  123.     // Auto-Mode
  124.     if (g_bAutoMode)
  125.     {
  126.         if (hCvar == g_hClientHealth)
  127.         {
  128.             for (new i = 1; i <= MaxClients; i++)
  129.             {
  130.                 if (IsClientInGame(i) && IsPlayerAlive(i))
  131.                 {
  132.                     SetEntityHealth(i, StringToInt(sNewv));
  133.                 }
  134.             }
  135.         }
  136.         else if (hCvar == g_hClientArmor)
  137.         {
  138.             for (new i = 1; i <= MaxClients; i++)
  139.             {
  140.                 if (IsClientInGame(i) && IsPlayerAlive(i))
  141.                 {
  142.                     SetEntProp(i, Prop_Send, "m_ArmorValue", StringToInt(sNewv));
  143.                 }
  144.             }
  145.         }
  146.     }
  147. }
  148.  
  149. public OnConfigsExecuted()
  150. {
  151.     // Set all the convars!
  152.     g_fGiveTime = GetConVarFloat(g_hGiveTime);
  153.     g_bPrint = GetConVarBool(g_hPrint);
  154.     g_fRemoveTimer = GetConVarFloat(g_hRemovetimer);
  155.     g_iBounces = GetConVarInt(g_hBounces);
  156.     g_iRandom = GetConVarInt(g_hRandom);
  157.     g_iRandomMax = GetConVarInt(g_hRandomMax);
  158.     g_iRandomMin = GetConVarInt(g_hRandomMin);
  159.     g_bRoundStartAd = GetConVarBool(g_hRoundStartAdvert);
  160.     g_iClientHealth = GetConVarInt(g_hClientHealth);
  161.     g_iClientArmor = GetConVarInt(g_hClientArmor);
  162.     g_fDBDamage = GetConVarFloat(g_hDBDamage);
  163.     g_bDebug = GetConVarBool(g_hDebug);
  164.     g_bAutoMode = GetConVarBool(g_hAutoMode);
  165.     GetConVarString(g_hLogFile, g_sLogFile, sizeof(g_sLogFile));
  166.     g_bEnabled = GetConVarBool(g_hEnabled);
  167.     g_bGEnabled = GetConVarBool(g_hGEnabled);
  168.    
  169.     BuildPath(Path_SM, g_sLogFilePath, sizeof(g_sLogFilePath), g_sLogFile);
  170.     if (g_bEnabled)
  171.     {
  172.         CreateTimer(g_fRemoveTimer, Timer_RemoveGroundWeapons, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  173.     }
  174. }
  175.  
  176. public Action:Timer_RemoveGroundWeapons(Handle:hTimer, any:data)
  177. {
  178.     if (g_bEnabled)
  179.     {
  180.         RemoveGroundWeapons();
  181.     }
  182. }
  183.  
  184. public OnClientPutInServer(iClient)
  185. {
  186.     if (g_bEnabled)
  187.     {
  188.         SDKHook(iClient, SDKHook_WeaponSwitch, OnWeaponSwitch);
  189.         SDKHook(iClient, SDKHook_OnTakeDamage, OnTakeDamage);
  190.         SDKHook(iClient, SDKHook_WeaponCanUse, OnWeaponCanUse);
  191.         SDKHook(iClient, SDKHook_WeaponDrop, OnWeaponDrop);
  192.     }
  193.    
  194.  
  195. }
  196.  
  197. public OnClientDisconnect(iClient)
  198. {
  199.     // Reset g_iBouncesRandClient for saftey reasons.
  200.     g_iBouncesRandClient[iClient] = 0;
  201. }
  202.  
  203. public Action:OnWeaponSwitch(iClient, iWeapon)
  204. {
  205.     if (!g_bEnabled)
  206.     {
  207.         return Plugin_Continue;
  208.     }
  209.    
  210.     // Block weapon switching.
  211.     decl String:sWeapon[32];
  212.     GetEdictClassname(iWeapon, sWeapon, sizeof(sWeapon));
  213.    
  214.     if(!StrEqual(sWeapon, "weapon_grenade"))
  215.     {
  216.         return Plugin_Handled;
  217.     }
  218.  
  219.     return Plugin_Continue;
  220. }
  221.  
  222. public Action:OnTakeDamage(iVictim, &iAttacker, &iInflictor, &Float:fDamage, &iDamageType)
  223. {
  224.     if (!g_bEnabled)
  225.     {
  226.         return Plugin_Continue;
  227.     }
  228.    
  229.     decl String:sWeapon[32];
  230.     GetEdictClassname(iInflictor, sWeapon, sizeof(sWeapon));
  231.  
  232.     if(StrEqual(sWeapon, "weapon_hegrenade") || StrEqual(sWeapon, "hegrenade_projectile"))
  233.     {
  234.         if (g_bDebug)
  235.         {
  236.             LogToFile(g_sLogFilePath, "[NOTE]%N is taking damage from a grenade! Damage: %f", iVictim, g_fDBDamage);
  237.         }
  238.        
  239.         fDamage = g_fDBDamage;
  240.         return Plugin_Changed;
  241.     }
  242.  
  243.     return Plugin_Continue;
  244. }
  245.  
  246. public Action:OnWeaponCanUse(iClient, iWeapon)
  247. {
  248.     if (!g_bEnabled)
  249.     {
  250.         return Plugin_Continue;
  251.     }
  252.    
  253.     decl String:sClassName[MAX_NAME_LENGTH];
  254.     new iOwner = GetEntPropEnt(iWeapon, Prop_Send, "m_hOwnerEntity");
  255.     GetEntityClassname(iWeapon, sClassName, sizeof(sClassName));
  256.    
  257.     if (!StrEqual(sClassName, "weapon_hegrenade", false) || iOwner > 0)
  258.     {
  259.         return Plugin_Handled;
  260.     }
  261.    
  262.     return Plugin_Continue;
  263. }
  264.  
  265. public Action:OnWeaponDrop(iClient, iWeapon)
  266. {
  267.     if (!g_bEnabled)
  268.     {
  269.         return Plugin_Continue;
  270.     }
  271.    
  272.     if (iWeapon > 0)
  273.     {
  274.         AcceptEntityInput(iWeapon, "kill");
  275.     }
  276.    
  277.     return Plugin_Continue;
  278. }
  279.  
  280. public Event_PlayerSpawn(Handle:hEvent, const String:sName[], bool:bDontBroadcast)
  281. {
  282.     if (!g_bEnabled)
  283.     {
  284.         return;
  285.     }
  286.    
  287.     new iClient = GetClientOfUserId(GetEventInt(hEvent, "userid"));
  288.    
  289.     // Remove all player weapons.
  290.     RemoveClientWeapons(iClient);
  291.    
  292.     // Give the iClient a grenade at spawn.
  293.     RequestFrame(Givegrenade, iClient);
  294.    
  295.     // Set the iClient's health and armor depending on the ConVars.
  296.     SetEntityHealth(iClient, g_iClientHealth);
  297.     SetEntProp(iClient, Prop_Send, "m_ArmorValue", g_iClientArmor);
  298.    
  299.     // Random Bounces Per Player (mode 2 for sm_db_random)
  300.     if (g_iRandom == 2)
  301.     {
  302.         g_iBouncesRandClient[iClient] = GetRandomInt(g_iRandomMin, g_iRandomMax);
  303.        
  304.         if (g_iBouncesRandClient[iClient] < 1)
  305.         {
  306.             g_iBouncesRandClient[iClient] = 1;
  307.         }
  308.        
  309.         if (g_bDebug)
  310.         {
  311.             LogToFile(g_sLogFilePath, "[NOTE]g_iRandom is two. %N has the bounce count of %i", iClient, g_iBouncesRandClient[iClient]);
  312.         }
  313.     }
  314. }
  315.  
  316. public Event_RoundStart(Handle:hEvent, const String:sName[], bool:bDontBroadcast)
  317. {
  318.     if (!g_bEnabled)
  319.     {
  320.         return;
  321.     }
  322.    
  323.     RemoveGroundWeapons();
  324.    
  325.     if (g_bRoundStartAd)
  326.     {
  327.         for (new i = 1; i <= MaxClients; i++)
  328.         {
  329.             if (!IsClientInGame(i) || IsFakeClient(i))
  330.             {
  331.                 continue;
  332.             }
  333.            
  334.             PrintToChat(i, "\x02[DB]\x03 grenade plugin made by Christian Deacon (download at \x02AlliedMods.net\x03).");
  335.         }
  336.     }
  337.    
  338.     if (g_iRandom == 1)
  339.     {
  340.         g_iBouncesRand = GetRandomInt(g_iRandomMin, g_iRandomMax);
  341.        
  342.         if (g_iBouncesRand < 1)
  343.         {
  344.             g_iBouncesRand = 1;
  345.         }
  346.        
  347.         if (g_bDebug)
  348.         {
  349.             LogToFile(g_sLogFilePath, "[NOTE]g_iRandom is one. Bounce count is %i for this round.", g_iBouncesRand);
  350.         }
  351.     }
  352.    
  353. }
  354.  
  355. public OnEntityCreated(iEntity, const String:sClassName[])
  356. {
  357.     if (StrEqual(sClassName, "hegrenade_projectile", false) && g_bEnabled)
  358.     {
  359.         SDKHook(iEntity, SDKHook_Spawn, OngrenadeSpawned);
  360.         SDKHook(iEntity, SDKHook_StartTouch, OngrenadeTouch);
  361.     }
  362. }
  363.  
  364. public OngrenadeSpawned(iEntity)
  365. {
  366.     if (!g_bEnabled)
  367.     {
  368.         return;
  369.     }
  370.    
  371.     new iClient = GetEntPropEnt(iEntity, Prop_Send, "m_hOwnerEntity");
  372.    
  373.     if (!iClient || !IsClientInGame(iClient) || !IsPlayerAlive(iClient))
  374.     {
  375.         if (g_bDebug)
  376.         {
  377.             LogToFile(g_sLogFilePath, "[ERROR]OngrenadeSpawned function returned: Client is not valid.");
  378.         }
  379.        
  380.         return;
  381.     }
  382.  
  383.     // Delay giving grenades so it isn't spamming grenades...
  384.     CreateTimer(g_fGiveTime, Givegrenade2Timer, GetClientUserId(iClient));
  385. }
  386.  
  387. public OngrenadeTouch(iEntity, itEntity)
  388. {
  389.     if (!g_bEnabled)
  390.     {
  391.         return;
  392.     }
  393.    
  394.     new iOwner = GetEntPropEnt(iEntity, Prop_Send, "m_hOwnerEntity");
  395.    
  396.     if (iOwner > MaxClients || iOwner < 1)
  397.     {
  398.         if (g_bDebug)
  399.         {
  400.             LogToFile(g_sLogFilePath, "[ERROR]OngrenadeTouch function reported: Owner is not valid.");
  401.         }
  402.        
  403.         Killgrenade(iEntity);
  404.        
  405.         return;
  406.     }
  407.    
  408.     g_iBounceCount[iEntity] += 1;
  409.    
  410.     if (!g_iRandom || g_iRandom > 3)
  411.     {  
  412.         if (g_iBounceCount[iEntity] >= g_iBounces)
  413.         {
  414.             if (g_bDebug)
  415.             {
  416.                 LogToFile(g_sLogFilePath, "[NOTE]g_iRandom isn't enabled. Bounces exceeded. %i/%i", g_iBounceCount[iEntity], g_iBounces);
  417.             }
  418.            
  419.             Killgrenade(iEntity);
  420.         }
  421.     }
  422.     else if (g_iRandom == 1)
  423.     {
  424.         if (g_iBounceCount[iEntity] >= g_iBouncesRand)
  425.         {
  426.             if (g_bDebug)
  427.             {
  428.                 LogToFile(g_sLogFilePath, "[NOTE]g_iRandom is set to mode one. Bounces exceeded. %i/%i", g_iBounceCount[iEntity], g_iBouncesRand);
  429.             }
  430.            
  431.             Killgrenade(iEntity);
  432.         }
  433.     }
  434.     else if (g_iRandom == 2)
  435.     {
  436.         if (g_iBounceCount[iEntity] >= g_iBouncesRandClient[iOwner])
  437.         {
  438.             if (g_bDebug)
  439.             {
  440.                 LogToFile(g_sLogFilePath, "[NOTE]g_iRandom is set to mode two. Bounces exceeded. %i/%i", g_iBounceCount[iEntity], g_iBouncesRandClient[iOwner]);
  441.             }
  442.            
  443.             Killgrenade(iEntity);
  444.         }
  445.     }
  446.     else if (g_iRandom == 3)
  447.     {
  448.         if (g_iBounceCount[iEntity] >= g_iBouncesRandClient[iOwner])
  449.         {
  450.             if (g_bDebug)
  451.             {
  452.                 LogToFile(g_sLogFilePath, "[NOTE]g_iRandom is set to mode three. Bounces exceeded. %i/%i", g_iBounceCount[iEntity], g_iBouncesRandClient[iOwner]);
  453.             }
  454.            
  455.             Killgrenade(iEntity);
  456.         }
  457.     }
  458. }
  459.  
  460. public Givegrenade(any:iClient)
  461. {
  462.     if (!g_bEnabled)
  463.     {
  464.         return;
  465.     }
  466.    
  467.     if (!iClient || !IsClientInGame(iClient))
  468.     {
  469.         if (g_bDebug)
  470.         {
  471.             LogToFile(g_sLogFilePath, "[ERROR]Givegrenade() function returned: Client is not valid.");
  472.         }
  473.        
  474.         return;
  475.     }
  476.    
  477.     if (!IsPlayerAlive(iClient))
  478.     {
  479.         if (g_bDebug)
  480.         {
  481.             decl String:sClientName[MAX_NAME_LENGTH], String:sSteamID[32];
  482.             GetClientName(iClient, sClientName, sizeof(sClientName));
  483.             GetClientAuthId(iClient, AuthId_Steam2, sSteamID, sizeof(sSteamID));
  484.             LogToFile(g_sLogFilePath, "[ERROR]Givegrenade() function returned: Client is not alive. Client Name: %s -- Client Steam ID: %s", sClientName, sSteamID);
  485.         }
  486.        
  487.         return;
  488.     }
  489.    
  490.     Givegrenade(iClient);
  491.    
  492.     if (g_bPrint)
  493.     {
  494.         PrintToChat(iClient, "\x02[DB]\x03 grenade equipped! Go play some grenade!");
  495.     }
  496. }
  497.  
  498. public Action:Givegrenade2Timer(Handle:hTimer, any:iUserID)
  499. {
  500.     if (!g_bEnabled)
  501.     {
  502.         return Plugin_Stop;
  503.     }
  504.    
  505.     new iClient = GetClientOfUserId(iUserID);
  506.    
  507.     if (!iClient || !IsClientInGame(iClient) || !IsPlayerAlive(iClient))
  508.     {
  509.         if (g_bDebug)
  510.         {
  511.             LogToFile(g_sLogFilePath, "[ERROR]Givegrenade2Timer timer returned: Client is not valid.");
  512.         }
  513.        
  514.         return Plugin_Stop;
  515.     }
  516.    
  517.     // Remove client's weapons.
  518.     RemoveClientWeapons(iClient);
  519.    
  520.     // Give the grenade!
  521.     Givegrenade(iClient);
  522.    
  523.     return Plugin_Stop;
  524. }
  525.  
  526. // grenade specific functions (not sure whether to use public or stock).
  527. stock Killgrenade(iEntity)
  528. {
  529.     if (!g_bEnabled)
  530.     {
  531.         return;
  532.     }
  533.    
  534.     if (iEntity < 1)
  535.     {
  536.         if (g_bDebug)
  537.         {
  538.             LogToFile(g_sLogFilePath, "[WARNING]Killgrenade function returned: Entity not valid.");
  539.         }
  540.        
  541.         return;
  542.     }
  543.    
  544.     // Kill the iEntity.
  545.     AcceptEntityInput(iEntity, "kill");
  546.    
  547.     // Reset the iEntity index bounce count.
  548.     g_iBounceCount[iEntity] = 0;
  549. }
  550.  
  551. stock Givegrenade(iClient)
  552. {
  553.     if (!g_bEnabled || !g_bGEnabled)
  554.     {
  555.         return;
  556.     }
  557.    
  558.     GivePlayerItem(iClient, "weapon_hegrenade");
  559.    
  560.     if (g_iRandom == 3)
  561.     {
  562.         g_iBouncesRandClient[iClient] = GetRandomInt(g_iRandomMin, g_iRandomMax);
  563.        
  564.         if (g_iBouncesRandClient[iClient] < 1)
  565.         {
  566.             g_iBouncesRandClient[iClient] = 1;
  567.         }
  568.     }
  569. }
  570.  
  571. stock RemoveClientWeapons(iClient)
  572. {
  573.     if (!g_bEnabled)
  574.     {
  575.         return;
  576.     }
  577.    
  578.     for (new i=0; i < 5; i++)
  579.     {
  580.         new iEnt = GetPlayerWeaponSlot(iClient, i);
  581.        
  582.         if (iEnt > 0)
  583.         {
  584.             RemovePlayerItem(iClient, iEnt);
  585.             RemoveEdict(iEnt);
  586.         }
  587.     }
  588. }
  589.  
  590. stock RemoveGroundWeapons()
  591. {
  592.     if (!g_bEnabled)
  593.     {
  594.         return;
  595.     }
  596.    
  597.     decl String:sClassname[MAX_NAME_LENGTH];
  598.     new iOwner;
  599.    
  600.     for (new i = MaxClients; i <= MAXENTITIES; i++)
  601.     {
  602.         if (!IsValidEntity(i) || !IsValidEdict(i))
  603.         {
  604.             continue;
  605.         }
  606.        
  607.         GetEntityClassname(i, sClassname, sizeof(sClassname));
  608.        
  609.         if (StrContains(sClassname, "weapon_", false) == -1)
  610.         {
  611.             continue;
  612.         }
  613.        
  614.         iOwner = GetEntPropEnt(i, Prop_Send, "m_hOwnerEntity");
  615.        
  616.         if (iOwner > 0)
  617.         {
  618.             continue;
  619.         }
  620.        
  621.         AcceptEntityInput(i, "kill");
  622.         RemoveEdict(i);
  623.     }
  624. }
  625.  
  626. // Not currently used.
  627. stock Removegrenades()
  628. {
  629.     if (!g_bEnabled)
  630.     {
  631.         return;
  632.     }
  633.    
  634.     new iEnt = -1;
  635.    
  636.     while ((iEnt = FindEntityByClassname(iEnt, "weapon_hegrenade")) != INVALID_ENT_REFERENCE)
  637.     {
  638.         if (GetEntPropEnt(iEnt, Prop_Send, "m_hOwnerEntity") == -1)
  639.         {
  640.             AcceptEntityInput(iEnt, "kill");
  641.         }
  642.     }
  643. }
Advertisement
Add Comment
Please, Sign In to add comment