Raised This Month: $12 Target: $400
 3% 

[TF2][REQ] Block Sticky Jumper & Rocket Jumper


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ph
AlliedModders Donor
Join Date: Mar 2006
Old 03-13-2021 , 14:03   [TF2][REQ] Block Sticky Jumper & Rocket Jumper
Reply With Quote #1

I need a plugin that will block

Sticky Jumper
Rocket Jumper


This is for a public TF2 server, not based under a mp_tournament


I would appreciate if someone can create a plugin for this.
__________________

Last edited by ph; 03-14-2021 at 05:49.
ph is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-13-2021 , 14:42   Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
Reply With Quote #2

about soldier, I found these cheat cvars
Code:
"tf_damageforcescale_self_soldier_badrj" "5.0"
"tf_damageforcescale_self_soldier_rj" "10.0"
pyro
Code:
tf_damageforcescale_pyro_jump" "8.5"
use sm_cvar and set value to 0 or 1

but sticky have hardcoded value, DAMAGE_FORCE_SCALE_SELF 9
That need plugin
__________________
Do not Private Message @me
Bacardi is offline
tair
Junior Member
Join Date: Apr 2015
Location: OnGameFrame()
Old 03-13-2021 , 17:24   Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
Reply With Quote #3

Here you go mate.

PHP Code:
#include <sourcemod>
#include <tf2_stocks>

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo = {
    
name        "Rocket & Sticky Jumper Blocker",
    
author      "Tair",
    
description "Blocks: Rocket Jumper & Sticky Jumper",
    
version     "1.0",
    
url         "https://steamcommunity.com/id/Rarrawuo"
};

public 
void OnPluginStart()
{
    
HookEvent("post_inventory_application"OnResupply);
}

public 
Action OnResupply(Handle eventchar[] namebool dontBroadcast
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
bool hasRocket = (GetIndexOfWeaponSlot(client,0) == 237);
    
bool hasSticky = (GetIndexOfWeaponSlot(client,1) == 265);
    
    if(
hasRocket// Rocket Jumper
    
{
        
TF2_RemoveWeaponSlot(client0);
        
PrintToChat(client"[SM] Rocket Jumper is not allowed in this server!");
    }
    
    if(
hasSticky// Sticky Jumper
    
{
        
TF2_RemoveWeaponSlot(client1);
        
PrintToChat(client"[SM] Sticky Jumper is not allowed in this server!");
    }
}

int GetIndexOfWeaponSlot(int clientint slot) {
  return 
GetWeaponIndex(GetPlayerWeaponSlot(clientslot));
}

int GetWeaponIndex(int weapon) {
  return 
IsValidEnt(weapon) ? GetEntProp(weaponProp_Send"m_iItemDefinitionIndex") : -1;
}

bool IsValidEnt(int ent) {
  return 
ent MaxClients && IsValidEntity(ent);


Last edited by tair; 03-13-2021 at 17:32.
tair is offline
ph
AlliedModders Donor
Join Date: Mar 2006
Old 03-13-2021 , 18:55   Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
Reply With Quote #4

Thank you, very much appreciated.
__________________
ph is offline
ph
AlliedModders Donor
Join Date: Mar 2006
Old 03-13-2021 , 21:29   Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
Reply With Quote #5

Not working

Quote:
Originally Posted by tair View Post
Here you go mate.

PHP Code:
#include <sourcemod>
#include <tf2_stocks>

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo = {
    
name        "Rocket & Sticky Jumper Blocker",
    
author      "Tair",
    
description "Blocks: Rocket Jumper & Sticky Jumper",
    
version     "1.0",
    
url         "https://steamcommunity.com/id/Rarrawuo"
};

public 
void OnPluginStart()
{
    
HookEvent("post_inventory_application"OnResupply);
}

public 
Action OnResupply(Handle eventchar[] namebool dontBroadcast
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
bool hasRocket = (GetIndexOfWeaponSlot(client,0) == 237);
    
bool hasSticky = (GetIndexOfWeaponSlot(client,1) == 265);
    
    if(
hasRocket// Rocket Jumper
    
{
        
TF2_RemoveWeaponSlot(client0);
        
PrintToChat(client"[SM] Rocket Jumper is not allowed in this server!");
    }
    
    if(
hasSticky// Sticky Jumper
    
{
        
TF2_RemoveWeaponSlot(client1);
        
PrintToChat(client"[SM] Sticky Jumper is not allowed in this server!");
    }
}

int GetIndexOfWeaponSlot(int clientint slot) {
  return 
GetWeaponIndex(GetPlayerWeaponSlot(clientslot));
}

int GetWeaponIndex(int weapon) {
  return 
IsValidEnt(weapon) ? GetEntProp(weaponProp_Send"m_iItemDefinitionIndex") : -1;
}

bool IsValidEnt(int ent) {
  return 
ent MaxClients && IsValidEntity(ent);



Tested in game.

It seems that sticky and rocket jumper is still possible... any reasons why the plugin is not working.
__________________

Last edited by ph; 03-14-2021 at 05:51.
ph is offline
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 - 73 views - 1.9 KB)

Last edited by ThatKidWhoGames; 03-14-2021 at 09:47. Reason: Quick Update
ThatKidWhoGames is offline
ph
AlliedModders Donor
Join Date: Mar 2006
Old 03-14-2021 , 12:59   Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
Reply With Quote #7

Thank you, will give this a try on my servers.
__________________
ph is offline
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 - 30 views - 2.0 KB)
File Type: smx tf_block_jumpers.smx (13.4 KB, 30 views)
__________________
Teamkiller324 is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 03-15-2021 , 14:43   Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
Reply With Quote #9

Quote:
Originally Posted by Teamkiller324 View Post
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.
Why are you looping all clients every map start? You can just do it once in OnPluginStart for handling late loading. Also, while looping clients you should start from 1 and go until it’s <= MaxClients. Further, SDKHooks automatically handles unhooking disconnecting clients, manually doing so is unnecessary. Also, I believe RemovePlayerItem does not actually kill the weapon entity, which could lead to issues.

Last edited by ThatKidWhoGames; 03-15-2021 at 14:44.
ThatKidWhoGames is offline
Teamkiller324
Senior Member
Join Date: Feb 2014
Location: Earth
Old 03-16-2021 , 06:44   Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
Reply With Quote #10

Quote:
Originally Posted by ThatKidWhoGames View Post
Why are you looping all clients every map start? You can just do it once in OnPluginStart for handling late loading. Also, while looping clients you should start from 1 and go until it’s <= MaxClients. Further, SDKHooks automatically handles unhooking disconnecting clients, manually doing so is unnecessary. Also, I believe RemovePlayerItem does not actually kill the weapon entity, which could lead to issues.
I'm an idiot, i should quit.
__________________
Teamkiller324 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode