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

PLEASE HELP! Editing Enforcer Restriction to block Red-Tape Recorder instead


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Grot
Member
Join Date: May 2012
Old 08-03-2012 , 10:46   PLEASE HELP! Editing Enforcer Restriction to block Red-Tape Recorder instead
Reply With Quote #1

Hey guys, I need some help because this is causing server crashes!

I edited this plugin: https://forums.alliedmods.net/showthread.php?t=185266 to use the new recorders itemid (810) but it doesn't seem to work. Am I doing something wrong?

Edit: Got it working! Code below!

Code:
#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <tf2_stocks>

public Plugin:myinfo = 
{
	name = "WeaponBlock",
	author = "xDerpyx",
	description = "This plugin blocks the cheap guns of TF2",
	version = "1.0.0",
	url = "www.derpygamers.com"
}

#define WEP_RedTape 810
#define WEP_GRedTape 831

public OnPluginStart()
{
	//HookEvent("player_spawn", Event_player_spawn);
	CreateTimer(0.1, Timer_DoEquip, 0, TIMER_REPEAT);
}


public Action:Timer_DoEquip(Handle:timer, any:derp)
{
	for(new client=1; client <= MaxClients; client++)
	{		
		if(IsClientInGame(client) && IsPlayerAlive(client))
		{		
			new slot1 = GetPlayerWeaponSlot(client, 1);
						
			if(TF2_GetPlayerClass(client) == TFClass_Spy)
			{
				if(slot1 > MaxClients && IsValidEntity(slot1) && GetEntProp(slot1, Prop_Send, "m_iItemDefinitionIndex") == WEP_RedTape)
				{
					TF2_RemoveWeaponSlot(client, 1);
					PrintToChat(client, "The Red-Tape Recorder is temporarily banned as it causes server crashes.");
				}
			}
		}	
	}
}

public Action:Timer_DoEquip(Handle:timer, any:derp)
{
	for(new client=1; client <= MaxClients; client++)
	{		
		if(IsClientInGame(client) && IsPlayerAlive(client))
		{		
			new slot1 = GetPlayerWeaponSlot(client, 1);
						
			if(TF2_GetPlayerClass(client) == TFClass_Spy)
			{
				if(slot1 > MaxClients && IsValidEntity(slot1) && GetEntProp(slot1, Prop_Send, "m_iItemDefinitionIndex") == WEP_GRedTape)
				{
					TF2_RemoveWeaponSlot(client, 1);
					PrintToChat(client, "The Red-Tape Recorder is temporarily banned as it causes server crashes.");
				}
			}
		}	
	}
}
Attached Files
File Type: sp Get Plugin or Get Source (RedTapeBan.sp - 443 views - 1.7 KB)

Last edited by Grot; 08-04-2012 at 00:45.
Grot is offline
Flyflo
Senior Member
Join Date: Jun 2008
Location: Grenoble, France
Old 08-03-2012 , 11:25   Re: PLEASE HELP! Editing Enforcer Restriction to block Red-Tape Recorder instead
Reply With Quote #2

Sapper is in weapon slot 1, not 0.
__________________
Flyflo is offline
Grot
Member
Join Date: May 2012
Old 08-03-2012 , 11:47   Re: PLEASE HELP! Editing Enforcer Restriction to block Red-Tape Recorder instead
Reply With Quote #3

Quote:
Originally Posted by Flyflo View Post
Sapper is in weapon slot 1, not 0.
SO what do I need to edit? Do I need to change all slot0 into slot1 or do I need to change other stuff too?
Grot is offline
Horsedick
AlliedModders Donor
Join Date: Sep 2011
Old 08-03-2012 , 11:50   Re: PLEASE HELP! Editing Enforcer Restriction to block Red-Tape Recorder instead
Reply With Quote #4

Quote:
Originally Posted by Grot View Post
Hey guys, I need some help because this is causing server crashes!

little off topic here but what do you mean causing server crashes? Windows or Linux etc?
Horsedick is offline
Grot
Member
Join Date: May 2012
Old 08-03-2012 , 12:26   Re: PLEASE HELP! Editing Enforcer Restriction to block Red-Tape Recorder instead
Reply With Quote #5

Quote:
Originally Posted by Horsedick View Post
little off topic here but what do you mean causing server crashes? Windows or Linux etc?
It's a TF2 Bug, not a sourcemod bug.

Basically, when you use the new sapper to reduce a sentries level (say, level 3 to level 1), the sentry keeps it's Level 3 health. If the engie then re-upgrades the sentry, it gets the health buff for leveling up again (i.e. http://i.imgur.com/q01GZ.png).

Now, this is all well and good, but if a Regular Sapper is attached to one of these sentries with odd health values, the entire server crashes, hence my desperation to temporarily block this new sapper till Valve pull their collective thumbs out.
Grot is offline
Snach
Member
Join Date: Jul 2012
Old 08-03-2012 , 12:34   Re: PLEASE HELP! Editing Enforcer Restriction to block Red-Tape Recorder instead
Reply With Quote #6

Quote:
Originally Posted by Grot View Post
SO what do I need to edit? Do I need to change all slot0 into slot1 or do I need to change other stuff too?
Change those:
PHP Code:
new slot0 GetPlayerWeaponSlot(client0);
TF2_RemoveWeaponSlot(client0); 
to those:
PHP Code:
new slot0 GetPlayerWeaponSlot(client1);
TF2_RemoveWeaponSlot(client1); 
You don't have to change the variable's name if you don't want to.

Last edited by Snach; 08-03-2012 at 12:36.
Snach is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-03-2012 , 14:20   Re: PLEASE HELP! Editing Enforcer Restriction to block Red-Tape Recorder instead
Reply With Quote #7

Side note: If you consulted the TF2 Item Definition Indexes wiki page (which I updated yesterday shortly after the update), you would have noticed that the Red-Tape Recorder's Genuine version has a different weapon index: 831. Meaning that you need to block both 810 and 831.

PHP Code:
#define WEP_RedTape 810 
#define WEP_RedTape_Genuine 831

// snip

                
if(slot1 MaxClients && IsValidEntity(slot1))
                {
                    new 
weapon GetEntProp(slot1Prop_Send"m_iItemDefinitionIndex");
                    if (
weapon == WEP_RedTape || weapon == WEP_RedTape_Genuine)
                    {
                        
TF2_RemoveWeaponSlot(client1);
                         
PrintToChat(client"The Red-Tape Recorder is temporarily banned as it causes server crashes.");
                    }
                 } 
As for server crashes, I didn't see a server crash on my Windows server yesterday, and I'm sure a normal Spy sapped a sentry after I Red-Tape sapped it (and they unsapped it at level 1).

Having said that, hopefully this will be fixed today.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 08-03-2012 at 14:31.
Powerlord is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 08-03-2012 , 14:28   Re: PLEASE HELP! Editing Enforcer Restriction to block Red-Tape Recorder instead
Reply With Quote #8

Quote:
Originally Posted by Flyflo View Post
Sapper is in weapon slot 1, not 0.
OH WOW
I thought it is in slot 5 (building, eh?)
Leonardo is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-03-2012 , 14:32   Re: PLEASE HELP! Editing Enforcer Restriction to block Red-Tape Recorder instead
Reply With Quote #9

Quote:
Originally Posted by Leonardo View Post
OH WOW
I thought it is in slot 5 (building, eh?)
Remember the wiki page I just mentioned? It includes which weapons are in which slot based on my empirical testing.

P.S. The TFWeaponSlot constants in SourceMod's tf2_stocks.inc are wrong , don't bother with them. I filed a bug about this, but iirc it was closed as WONTFIX because it matches some of Valve's (unused?) constants. [Seriously, it's pretty clear they're wrong since they have TFC's Grenade slot.]

To be more specific, the slots are:
0 - "primary" / Spy "secondary" (i.e. his revolvers)
1 - "secondary" / Spy "building" (i.e. his sappers)
2 - "melee"
3 - "pda" = Engineer's Construction PDA / Spy's Disguise Kit
4 - "pda2" = Engineer's Destruction PDA / Spy's Cloaking Device
5 - Engineer "building" = TF_WEAPON_BUILDER: Hidden but Construction/Destruction PDA won't work without it
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 08-03-2012 at 14:54.
Powerlord is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 08-03-2012 , 14:43   Re: PLEASE HELP! Editing Enforcer Restriction to block Red-Tape Recorder instead
Reply With Quote #10

@Powerlord,
more issues with items_game.txt parsing.

item #28 - tf_weapon_builder - slot 'building' - actual slot #5
item #735 - tf_weapon_builder - slot 'building' - actual slot #1
item #810 - tf_weapon_sapper - slot 'building' - actual slot #1

oh god why...
Leonardo is offline
Reply



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 13:44.


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