View Single Post
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 03-14-2021 , 09:03   Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
Reply With Quote #6

Try this version. Comes with one ConVar:
Code:
sm_block_jumpers_enable - Enable/disable the plugin (1 = Enable, 0 = Disable)
PHP Code:
#include <sourcemod>
#include <tf2_stocks>

#define ROCKET_JUMPER_INDEX 237
#define STICKY_JUMPER_INDEX 265

ConVar g_cvEnable null;

public 
void OnPluginStart()
{
    
g_cvEnable CreateConVar("sm_block_jumpers_enable""1""Enable/disable the plugin"_true0.0true1.0);

    
HookEvent("post_inventory_application"Event_PostInventoryApplication);
}

public 
void Event_PostInventoryApplication(Event hEvent, const char[] sNamebool bDontBroadcast)
{
    
RequestFrame(Frame_PostInventoryApplicationhEvent.GetInt("userid"));
}

public 
void Frame_PostInventoryApplication(any data)
{
    if (
g_cvEnable.BoolValue)
    {
        
int iClient GetClientOfUserId(data);
        if (
iClient != && IsPlayerAlive(iClient))
        {
            
int iPrimary GetPlayerWeaponSlot(iClientTFWeaponSlot_Primary);
            if (
iPrimary != -&& GetItemDefinitionIndex(iPrimary) == ROCKET_JUMPER_INDEX)
            {
                
TF2_RemoveWeaponSlot(iClientTFWeaponSlot_Primary);
                
EquipFreeWeaponSlot(iClient);
                
PrintToChat(iClient"[SM] The Rocket Jumper is not allowed!");
            }

            
int iSecondary GetPlayerWeaponSlot(iClientTFWeaponSlot_Secondary);
            if (
iSecondary != -&& GetItemDefinitionIndex(iSecondary) == STICKY_JUMPER_INDEX)
            {
                
TF2_RemoveWeaponSlot(iClientTFWeaponSlot_Secondary);
                
EquipFreeWeaponSlot(iClient);
                
PrintToChat(iClient"[SM] The Sticky Jumper is not allowed!");
            }
        }
    }
}

int GetItemDefinitionIndex(int iEntity)
{
    return 
GetEntProp(iEntityProp_Send"m_iItemDefinitionIndex");
}

void EquipWeapon(int iClientint iWeapon)
{
    
SetEntPropEnt(iClientProp_Send"m_hActiveWeapon"iWeapon);
}

void EquipFreeWeaponSlot(int iClient)
{
    
int iWeapon = -1;
    for (
int i TFWeaponSlot_Primary<= TFWeaponSlot_Meleei++)
    {
        
iWeapon GetPlayerWeaponSlot(iClienti);
        if (
iWeapon != -1)
        {
            
EquipWeapon(iClientiWeapon);
            break;
        }
    }

Attached Files
File Type: sp Get Plugin or Get Source (block_sticky_and_rocket_jumper.sp - 76 views - 1.9 KB)

Last edited by ThatKidWhoGames; 03-14-2021 at 09:47. Reason: Quick Update
ThatKidWhoGames is offline