AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [TF2][REQ] Block Sticky Jumper & Rocket Jumper (https://forums.alliedmods.net/showthread.php?t=331286)

ph 03-13-2021 14:03

[TF2][REQ] Block Sticky Jumper & Rocket Jumper
 
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.

Bacardi 03-13-2021 14:42

Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
 
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

tair 03-13-2021 17:24

Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
 
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);



ph 03-13-2021 18:55

Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
 
Thank you, very much appreciated.

ph 03-13-2021 21:29

Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
 
Not working :(

Quote:

Originally Posted by tair (Post 2740368)
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.

ThatKidWhoGames 03-14-2021 09:03

Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
 
1 Attachment(s)
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;
        }
    }



ph 03-14-2021 12:59

Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
 
Thank you, will give this a try on my servers.

Teamkiller324 03-15-2021 10:43

Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
 
2 Attachment(s)
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.

ThatKidWhoGames 03-15-2021 14:43

Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
 
Quote:

Originally Posted by Teamkiller324 (Post 2740549)
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.

Teamkiller324 03-16-2021 06:44

Re: [TF2][REQ] Block Sticky Jumper & Rocket Jumper
 
Quote:

Originally Posted by ThatKidWhoGames (Post 2740569)
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.


All times are GMT -4. The time now is 10:20.

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