Raised This Month: $32 Target: $400
 8% 

[REQ][TF2] Block renamed weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sreaper
髪を用心
Join Date: Nov 2009
Old 05-12-2021 , 23:58   [REQ][TF2] Block renamed weapons
Reply With Quote #1

Seeking a plugin that blocks all renamed weapons and sets them back to the default names.
Recently my server has had an influx of players coming in with racist weapon names.
While I know the default TF2 filter settings can censor it, it doesn't seem my community is really fond of that solution.

Anyone able to help?

Last edited by Sreaper; 05-13-2021 at 00:03.
Sreaper is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 05-13-2021 , 04:14   Re: [REQ][TF2] Block renamed weapons
Reply With Quote #2

I'm not aware of any method that allows you to view or edit the name of a weapon. However, you should be able to replace any renamed weapon you find with a stock version.

There are 29 renamed weapons in the game. You could replace some or all of them with their stock version. Here's example code to replace the 3 Scout renamed weapons. Note: I have not tested this.

Example code:
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <tf2_stocks>

#pragma newdecls required

#define PLUGIN_VERSION "1.0"

public Plugin myinfo =
{
    
name "[TF2] Block Renamed Weapons",
    
author "Sreaper",
    
description "Replace Renamed weapons with stock versions",
    
version PLUGIN_VERSION,
    
url "www.sourcemod.net"
}

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

public 
void EventInventoryApplication(Handle event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    if (
IsValidClient(client) && TF2_GetPlayerClass(client) == TFClass_Scout)
    {
        
int myslot0 GetIndexOfWeaponSlot(client0);
        if(
myslot0 == 200)//Renamed Scattergun
        
{
            
TF2_RemoveWeaponSlot(client0);
            
CreateWeapon(client"tf_weapon_scattergun"136);
        }
        
        
int myslot1 GetIndexOfWeaponSlot(client1);
        if(
myslot1 == 209)//Renamed Pistol
        
{
            
TF2_RemoveWeaponSlot(client1);
            
CreateWeapon(client"tf_weapon_pistol"236);
        }

        
int myslot2 GetIndexOfWeaponSlot(client2);
        if(
myslot2 == 190)//Renamed Bat
        
{
            
TF2_RemoveWeaponSlot(client2);
            
CreateWeapon(client"tf_weapon_bat"06);
        }        
    }
}

bool CreateWeapon(int clientchar[] classnameint itemindexint qualityint level 0)
{
    
int weapon CreateEntityByName(classname);
    
    if (!
IsValidEntity(weapon))
    {
        return 
false;
    }
    
    
char entclass[64];
    
GetEntityNetClass(weaponentclasssizeof(entclass));
    
SetEntProp(weaponProp_Send"m_iItemDefinitionIndex"itemindex);     
    
SetEntProp(weaponProp_Send"m_bInitialized"1);
    
SetEntData(weaponFindSendPropInfo(entclass"m_iEntityQuality"), quality);    

    if (
level)
    {
        
SetEntProp(weaponProp_Send"m_iEntityLevel"level);
    }
    else
    {
        
SetEntProp(weaponProp_Send"m_iEntityLevel"GetRandomUInt(1,99));
    }

    
DispatchSpawn(weapon);
    
EquipPlayerWeapon(clientweapon);     
    
    return 
true;    
}

stock bool IsValidClient(int client)

    if (
client <= || client MaxClients)
    {
        return 
false
    }
    return 
IsClientInGame(client); 
}  

stock int GetIndexOfWeaponSlot(int iClientint iSlot)
{
    return 
GetWeaponIndex(GetPlayerWeaponSlot(iClientiSlot));
}

stock int GetClientCloakIndex(int iClient)
{
    return 
GetWeaponIndex(GetPlayerWeaponSlot(iClientTFWeaponSlot_Watch));
}

stock int GetWeaponIndex(int iWeapon)
{
    return 
IsValidEnt(iWeapon) ? GetEntProp(iWeaponProp_Send"m_iItemDefinitionIndex"):-1;
}

stock int GetActiveIndex(int iClient)
{
    return 
GetWeaponIndex(GetEntPropEnt(iClientProp_Send"m_hActiveWeapon"));
}

stock bool IsWeaponSlotActive(int iClientint iSlot)
{
    return 
GetPlayerWeaponSlot(iClientiSlot) == GetEntPropEnt(iClientProp_Send"m_hActiveWeapon");
}

stock bool IsIndexActive(int iClientint iIndex)
{
    return 
iIndex == GetWeaponIndex(GetEntPropEnt(iClientProp_Send"m_hActiveWeapon"));
}

stock bool IsSlotIndex(int iClientint iSlotint iIndex)
{
    return 
iIndex == GetIndexOfWeaponSlot(iClientiSlot);
}

stock bool IsValidEnt(int iEnt)
{
    return 
iEnt MaxClients && IsValidEntity(iEnt);
}

stock int GetSlotFromPlayerWeapon(int iClientint iWeapon)
{
    for (new 
0<= 5i++)
    {
        if (
iWeapon == GetPlayerWeaponSlot(iClienti))
        {
            return 
i;
        }
    }
    return -
1;
}

int GetRandomUInt(int minint max)
{
    return 
RoundToFloor(GetURandomFloat() * (max min 1)) + min;

PC Gamer is offline
Sreaper
髪を用心
Join Date: Nov 2009
Old 05-13-2021 , 04:31   Re: [REQ][TF2] Block renamed weapons
Reply With Quote #3

Quote:
Originally Posted by PC Gamer View Post
I'm not aware of any method that allows you to view or edit the name of a weapon. However, you should be able to replace any renamed weapon you find with a stock version.

There are 29 renamed weapons in the game. You could replace some or all of them with their stock version. Here's example code to replace the 3 Scout renamed weapons. Note: I have not tested this.

Example code:
Spoiler


Thank you.
Sreaper 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 01:10.


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