View Single Post
Teamkiller324
Senior Member
Join Date: Feb 2014
Location: Earth
Old 03-15-2021 , 10:43   Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
Reply With Quote #8

PHP Code:

#include    <sdkhooks>
#include    <sdktools>
#include    <multicolors>

#pragma        semicolon    1
#pragma        newdecls    required

public    Plugin    myinfo    =    {
    
name        =    "[TF2] Block Jumpers",
    
author        =    "Tk /id/Teamkiller324",
    
description    =    "Prevent the Rocket Jumper & Sticky Jumper from being equipped.",
    
version        =    "0.1",
    
url            =    "https://steamcommunity.com/id/Teamkiller324"
}

public 
void OnMapStart()    {
    for(
int i 0MaxClientsi++)    {
        if(!
IsValidClient(i))
            continue;
        
        
SDKHook(iSDKHook_WeaponEquipPostWeaponEquipPost);
    }
}

public 
void OnClientPutInServer(int client)    {
    
SDKHook(clientSDKHook_WeaponEquipPostWeaponEquipPost);
}

public 
void OnClientDisconnect(int client)    {
    
SDKUnhook(clientSDKHook_WeaponEquipPostWeaponEquipPost);
}

Action WeaponEquipPost(int clientint weapon)    {
    if(!
IsValidClient(client))
        return    
Plugin_Handled;
    
    switch(
GetWeaponDefinitionIndex(weapon))    {
        case    
237:    {
            
CPrintToChat(client"The {orange}Rocket Jumper {default}is not permitted in this server.");
            
RemovePlayerItem(clientweapon);
        }
        case    
265:    {
            
CPrintToChat(client"The {orange}Sticky Jumper {default}is not permitted in this server");
            
RemovePlayerItem(clientweapon);
        }
    }
    
    return    
Plugin_Continue;
}

/**
 *    Returns if the client is valid.
 *
 *    @param client        Client index.
 *    @return                Valid if true, else not valid.
 *    @error                Invalid client index.
 */
stock bool IsValidClient(int client)    {
    if(
client == 0)
        return    
false;
    if(
client == -1)
        return    
false;
    if(
client || client MaxClients)
        return    
false;
    if(!
IsClientInGame(client))
        return    
false;
    if(!
IsClientConnected(client))
        return    
false;
    if(
IsClientReplay(client))
        return    
false;
    if(
IsClientSourceTV(client))
        return    
false;
    return    
true;
}

//Taken from Tklib

/**
 *    Get the weapon definition index value
 *
 *    @param weapon        Weapon entity.
 */
stock int GetWeaponDefinitionIndex(int weapon)    {
    return    
GetEntProp(weaponProp_Send"m_iItemDefinitionIndex");

This is my approach to this, altough this requires Multicolors to compile, you can edit it to not require multicolors.
Untested but should work.
Attached Files
File Type: sp Get Plugin or Get Source (tf_block_jumpers.sp - 32 views - 2.0 KB)
File Type: smx tf_block_jumpers.smx (13.4 KB, 30 views)
__________________
Teamkiller324 is offline