AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   TF2 Class Restrictions 0.6 (Updated 08/13/09) (https://forums.alliedmods.net/showthread.php?t=73104)

DJ Tsunami 06-22-2008 17:14

TF2 Class Restrictions 0.6 (Updated 2020/08/05)
 
10 Attachment(s)
I know there's already a class restriction plugin, I just think this one works neater. Credits go to voogru for the idea, and for telling me how to show the class selection screen to players :) A video of his version can be found at http://www.youtube.com/watch?v=OgBt-KtjxyA, I just based it off of the video. The cvars are:

sm_classrestrict_enabled (0/1, default 1)
Enable/disable restricting classes in TF2.

sm_classrestrict_flags (default "")
Admin flags for restricted classes in TF2.

sm_classrestrict_immunity (0/1, default 0)
Enable/disable admins being immune for restricted classes in TF2.

sm_classrestrict_blu_demomen
sm_classrestrict_blu_engineers
sm_classrestrict_blu_heavies
sm_classrestrict_blu_medics
sm_classrestrict_blu_pyros
sm_classrestrict_blu_scouts
sm_classrestrict_blu_snipers
sm_classrestrict_blu_soldiers
sm_classrestrict_blu_spies

Limits for Blu classes in TF2. (-1 for no limit, anything higher will be the limit for that class. Default -1)

sm_classrestrict_red_demomen
sm_classrestrict_red_engineers
sm_classrestrict_red_heavies
sm_classrestrict_red_medics
sm_classrestrict_red_pyros
sm_classrestrict_red_scouts
sm_classrestrict_red_snipers
sm_classrestrict_red_soldiers
sm_classrestrict_red_spies

Limits for Red classes in TF2.

You can put any of these cvars in server.cfg or sourcemod.cfg, and then if you want map specific cvars you can make a file called mapname.cfg (for example cp_dustbowl.cfg) and put those cvars in there.

Changelog
  • 0.6
    • Fixed limits being off by 1.
    • Added percentage based limits.
    • Added class immunity.
  • 0.5
    • Fixed skin glitch.
    • Fixed admin immunity.
    • Fixed not blocking on first spawn on Arena maps.
  • 0.4
    • Added admin immunity.
    • Also blocked join_class command.
  • 0.3
    • Should actually work now, but I don't have the time anymore today to thoroughly test it. Will test tomorrow. No added features yet.
  • 0.2
    • Initial release.

bl4nk 06-22-2008 17:31

Re: TF2 Class Restrictions
 
Quote:

Originally Posted by DJ Tsunami (Post 642353)
Also, it doesn't have admin immunity yet, if enough people want that I'll add it later.

Do it. :D

BrutalGoerge 06-22-2008 17:45

Re: TF2 Class Restrictions
 
hey, it's trying to download sound files now that I have installed this...
did you forgot to add them to the post or something?

DJ Tsunami 06-22-2008 18:09

Re: TF2 Class Restrictions
 
No, they're already included with TF2, so I figured it wouldn't try to download them...

Edit: oh sorry, I think I see the problem. Hopefully fixed :)

BrutalGoerge 06-22-2008 18:39

Re: TF2 Class Restrictions
 
thank you sir

BrutalGoerge 06-22-2008 22:20

Re: TF2 Class Restrictions
 
there were 4 pyros, i set it to 3, if people change class thru console, does this plugin block it?

DJ Tsunami 06-23-2008 06:50

Re: TF2 Class Restrictions
 
Yes, the plugin blocks it too then. Unfortunately I can't reproduce what you're saying.

fattitj 06-23-2008 10:08

Re: TF2 Class Restrictions
 
i get this error when im using this plugin, and the plugin is not working
Code:

L 06/23/2008 - 16:07:02: [TF2] Could not locate CalcCritical - Disabling Critical Hit forward
L 06/23/2008 - 16:07:02: [TF2] Could not locate CalcCriticalMelee - Disabling Critical Hit forward
L 06/23/2008 - 16:07:02: [TF2] Could not locate CalcCriticalKnife - Disabling Critical Hit forward
L 06/23/2008 - 16:07:02: [TF2] No critical hit forwards could be initialised - Disabled critical hit hooks


DontWannaName 06-23-2008 11:08

Re: TF2 Class Restrictions
 
I can already see players being like wtf why cant i be a pyro since theres no message at the time of selection that tells them its full. Can you redirect them to chat when they select? Immunity is also nice :D

DJ Tsunami 06-23-2008 14:42

Re: TF2 Class Restrictions
 
Well, chat hides behind the class selection screen, so I think I can only do something like center or hint text. But that's what I liked about this plugin, it plays the sound of the class you selected saying No, so that's the notification that you can't select the class :)

@fattitj: I'm not using any of those forwards, so I'm not sure why it's giving those errors.

@bl4nk: I compiled it with 1.0.4 and it worked for me, I don't know if 1.1.0 would give those errors.

bl4nk 06-23-2008 14:43

Re: TF2 Class Restrictions
 
Did you compile it on 1.1?

fattitj 06-23-2008 15:15

Re: TF2 Class Restrictions
 
i recompiled it in 1.2 now, and no errors this time

bl4nk 06-23-2008 16:00

Re: TF2 Class Restrictions
 
I believe you mean 1.0.2.

r3dh3adkid 06-23-2008 16:29

Re: TF2 Class Restrictions
 
Any way you could add random?

DJ Tsunami 06-23-2008 18:04

Re: TF2 Class Restrictions
 
You mean make it choose a random team and class for a player that just connected?

r3dh3adkid 06-23-2008 18:34

Re: TF2 Class Restrictions
 
No No like if I wanted 5 maps where each team is set to a random class each time u go to the map...

Like...the cvar would be like

sm_classrestrict_red_random
sm_classrestrict_blue_random

It would do exactly the same as the other cvars except randomly choose a class.

Er...hope that makes sense?

Freelancer 06-23-2008 20:11

Re: TF2 Class Restrictions
 
Quote:

Originally Posted by DJ Tsunami (Post 642895)
You mean make it choose a random team and class for a player that just connected?

Good idea, would it still be possable to make them join even with restrictions? and still be random team and random class?

ratty 06-23-2008 20:39

Re: TF2 Class Restrictions
 
Thanks for this plugin, its awesome.

However, my error logs are filling with
Native "GetClientTeam" reported: Client 16 is not in game
possibly due to the bots on my server

One thing you should do is call IsFakeClient(client) with your other error checks to filter out bots, such as SourceTV. I'll fix up my own copy, but I just wanted to suggest it.

chundo 06-24-2008 02:08

Re: TF2 Class Restrictions
 
Works great, thanks. Will be nice to have around when the next TF2 unlockables come out.

Any chance you can add a cvar that lets me specify I want the limits interpreted as percentages rather than hard numbers? If I have 12 players on the team, I might want to limit it to 3 pyros, but for 6 on 6, 3 is still too many.

DJ Tsunami 06-24-2008 04:17

Re: TF2 Class Restrictions
 
@r3dh3adkid: yeah, that kind of makes sense :) I'll look into it.

@Freelancer: well, I would have them join a team that's not restricted, right?

@ratty: you're right, I don't check for bots yet. Will add that.

@chundo: sounds like a sexy idea :) Will add.

ColdFire 06-24-2008 04:27

Re: TF2 Class Restrictions
 
Hi

Would it be possible to add this kind of cvar:

sm_classrestrict_enabled_on_suddendeath so if used on the same time with suddendeath melee redux plugin, classrestrict can be disabled, and we can have all players in the same class during sudden death?

willy1234x1 06-24-2008 05:16

Re: TF2 Class Restrictions
 
Ran into a problem. I tried setting it so that each team can have only six pyros and six soldiers in a map config file (the map is pyro_tennis_a1) but people can still go as any other class if they want I had set each one to 0 but it ignored the value as a null I think

DJ Tsunami 06-24-2008 12:00

Re: TF2 Class Restrictions
 
ColdFire: sudden death melee redux already has a feature to set everyone's class to the same class. In fact, it sets everyone's class to scout by default...

@willy: setting it to 0 worked fine for me while testing, so.

chundo 06-25-2008 00:40

Re: TF2 Class Restrictions
 
Something funny is happening with this on my server. It must be missing some events somewhere that's screwing up the running class tally. At one point tonight one team was limited to 1 pyro, and the other 2, even though they were both set to 3. It would probably be more reliable to just recalculate the class counts every time someone joins/changes class rather than keep a running tally. A little more computation, but worth it given how infrequently it will be run.

Also, hooking "joinclass" may be better than "equip" - joinclass only gets called once, equip gets called three or more times on spawn.

ColdFire 06-25-2008 05:19

Re: TF2 Class Restrictions
 
Quote:

Originally Posted by DJ Tsunami (Post 643166)
ColdFire: sudden death melee redux already has a feature to set everyone's class to the same class. In fact, it sets everyone's class to scout by default...

@willy: setting it to 0 worked fine for me while testing, so.

Yes, but I wanted to know if your plugin will force restrictions when SDMR sets everyone in the same class or if there will be no problem

bl4nk 06-25-2008 06:16

Re: TF2 Class Restrictions
 
SDMR forces the class, when his plugin blocks the client trying to change class. There shouldn't be any problems.

[edit]

Actually, now that I look at the source of his plugin, there might be some problems. You can always try it out and see how it works.

ColdFire 06-25-2008 07:19

Re: TF2 Class Restrictions
 
Guess I'll have to try, thank you bl4nk!

ColdFire 06-26-2008 04:12

Re: TF2 Class Restrictions
 
I was wondering (I did not have time to test ClassRestrict with SDMR and see what happens in sudden death)

Would it work if:

- I add this global var: decl g_iSuddenDeath = 0 ;
- I hook teamplay_suddendeath_begin and set g_iSuddenDeath = 1
- I hook teamplay_suddendeath_end and set g_iSuddenDeath = 0
- Add a check in Event_ChangeClass and make it do nothing if g_iSuddenDeath = 1?
- and add a cvar saying if we want to do no-class-restrict in sudden death

Edit: or maybe check g_iSuddenDeath in "PickClass (iTeam)" instead of Event_ChangeClass ?

flubber 06-26-2008 13:05

Re: TF2 Class Restrictions
 
Quote:

Originally Posted by chundo (Post 643429)
Something funny is happening with this on my server. It must be missing some events somewhere that's screwing up the running class tally. At one point tonight one team was limited to 1 pyro, and the other 2, even though they were both set to 3. It would probably be more reliable to just recalculate the class counts every time someone joins/changes class rather than keep a running tally. A little more computation, but worth it given how infrequently it will be run.

Also, hooking "joinclass" may be better than "equip" - joinclass only gets called once, equip gets called three or more times on spawn.

Same problem here, one team had 1 pyro no sniper. The other had 2 pyro and 1 sniper (which is the authorized limit for us).

willy1234x1 06-27-2008 04:16

Re: TF2 Class Restrictions
 
So for a map config such as rocket_tennis_beta.cfg I'd place it in the /tf/cfg folder and it'd look like this
Code:

//Restriction settings for the map rocket_tennis_beta

//Restriction command 0 default for the map
sm_classrestrict_enabled 1

// Restrictions per class

sm_classrestrict_red_demomen 0
sm_classrestrict_red_engineers 0
sm_classrestrict_red_heavies 0
sm_classrestrict_red_medics 0
sm_classrestrict_red_pyros 6
sm_classrestrict_red_scouts 0
sm_classrestrict_red_snipers 0
sm_classrestrict_red_soldiers 6
sm_classrestrict_red_spies 0

sm_classrestrict_blu_demomen 0
sm_classrestrict_blu_engineers 0
sm_classrestrict_blu_heavies 0
sm_classrestrict_blu_medics 0
sm_classrestrict_blu_pyros 6
sm_classrestrict_blu_scouts 0
sm_classrestrict_blu_snipers 0
sm_classrestrict_blu_soldiers 6
sm_classrestrict_blu_spies 0

Or is there something I'm doing wrong? This is a fun map I throw in every so often and it gets ruined by jackasses going other classes (even demoman.)

DontWannaName 06-27-2008 13:48

Re: TF2 Class Restrictions
 
I wouldnt know why it doesnt work unless its name isnt exactly what the map name is, inlcuding cp_ ctf_ etc.

BrutalGoerge 06-28-2008 19:44

Re: TF2 Class Restrictions
 
sometimes it only allows 2 pyros when it's set to 3

ColdFire 06-29-2008 03:58

Re: TF2 Class Restrictions
 
I have some problems too: I've set in sourcemod.cfg a restrict I want for every map:
sm_classrestrict_red_snipers 2
sm_classrestrict_blu_snipers 2
And each team cannot have more than 1 sniper
I've set in cp_oilrig_b3.cfg sm_classrestrict_red_engineers 2 and the reds can have only one engy

Houston, we have a problem!

BrutalGoerge 06-29-2008 12:46

Re: TF2 Class Restrictions
 
I've been getting some error logs with it.

I'll run debug for ya, maybe that will help.

BrutalGoerge 06-29-2008 18:10

Re: TF2 Class Restrictions
 
Code:

L 06/29/2008 - 11:59:17: [SM] Native "GetClientTeam" reported: Client 15 is not in game
L 06/29/2008 - 11:59:17: [SM] Displaying call stack trace for plugin "classrestrict.smx":
L 06/29/2008 - 11:59:17: [SM]  [0]  Line 69, /home/groups/alliedmodders/forums/files/3/4/6/6/8/27957.attach::OnClientDisconnect()
L 06/29/2008 - 11:59:20: [SM] Native "GetClientTeam" reported: Client 18 is not in game
L 06/29/2008 - 11:59:20: [SM] Displaying call stack trace for plugin "classrestrict.smx":
L 06/29/2008 - 11:59:20: [SM]  [0]  Line 69, /home/groups/alliedmodders/forums/files/3/4/6/6/8/27957.attach::OnClientDisconnect()
L 06/29/2008 - 12:51:33: Error log file session closed.

there you go, hope it helps

DJ Tsunami 06-30-2008 12:22

Re: TF2 Class Restrictions
 
Nican's MaxClass runs sudden death rounds fine with SDMR, but if it was a restricted class, for some reason everyone stays that class the next round, instead of switching back to their old class. I have this plugin with SDMR on my server now, so I'll have to check if mine does the same.

@chundo: does joinclass fire on spawn? The reason that I'm hooking equip is because if you choose the new class twice, apparently player_changeclass doesn't fire the second time (even though I set their class back to their old class), so you can still go that class. Hooking equip prevents that, but I did notice it runs for every weapon.

chundo 07-02-2008 18:23

Re: TF2 Class Restrictions
 
Yeah, joinclass fires on spawn, but only once per spawn. And it fires even if you change to the same class you already are. I explored this as an alternative in my meleemode plugin, but went back to equip because I didn't want users manually equipping stripped weapons after spawn. For this plugin it should be perfect though.

For debugging just add an "OnClientCommand" forward that dumps GetCmdArg(0) to the server console, and you'll see all the commands the client executes during play, to verify that it's getting fired every time.

BrutalGoerge 07-02-2008 23:36

Re: TF2 Class Restrictions
 
yah, earlier it was allowing only 1 pyro (set to 3)

I am removing this plugin till it gets fixed.

DontWannaName 07-02-2008 23:37

Re: TF2 Class Restrictions
 
I think Valve should make it part of TF2, like DODS. Same reason, some classes are too popular.

willy1234x1 07-02-2008 23:53

Re: TF2 Class Restrictions
 
Quote:

Originally Posted by DontWannaName (Post 647065)
I think Valve should make it part of TF2, like DODS. Same reason, some classes are too popular.

I tried suggesting that in the Steam Powered forums and got a hell storm of flaming. I suggested the commands that this guy has for sm but with sv instead.


All times are GMT -4. The time now is 14:21.

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