AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Unapproved/Old Plugins (https://forums.alliedmods.net/forumdisplay.php?f=27)
-   -   /team switcher (https://forums.alliedmods.net/showthread.php?t=25907)

SweatyBanana 03-23-2006 08:10

/team switcher
 
2 Attachment(s)
I created this plugin with the help of our many scriptykiddys and hope it will help people..

PURPOSE:
Allows players to type these commands in say or say_team:
  • /ct
    /spec
    /t
and it will place that player on the team they typed if they are not already on that team.

Works fine. (January 2007)

Brad 03-23-2006 08:58

a)

If you find yourself calling a specific function more than once in your own function, you're doing something wrong.

Sample of your code:
Code:
public TEAMCT( id ) {     if(cs_get_user_team(id) == CS_TEAM_CT)     {         client_print(1, print_chat, "[TEAMS] You are already on the CT team.")         return PLUGIN_HANDLED     }           if(cs_get_user_team(id) != CS_TEAM_CT)     {         return PLUGIN_CONTINUE     }           else     {         new name[32]         get_user_name(id,name,31)         if(is_user_alive(id)) user_kill(id)         cs_set_user_team ( id, CS_TEAM_CT, CS_CT_URBAN)         client_print(0, print_chat, "[TEAMS] %s has switched himself to the CT team.", name)     }     return PLUGIN_CONTINUE }
Revised, calling cs_set_user_team() only once:
Code:
public TEAMCT( id ) {     new CsTeams:team = cs_get_user_team(id);     if(team == CS_TEAM_CT)     {         client_print(1, print_chat, "[TEAMS] You are already on the CT team.")         return PLUGIN_HANDLED     }           if(team != CS_TEAM_CT)     {         return PLUGIN_CONTINUE     }           else     {         new name[32]         get_user_name(id,name,31)         if(is_user_alive(id)) user_kill(id)         cs_set_user_team ( id, CS_TEAM_CT, CS_CT_URBAN)         client_print(0, print_chat, "[TEAMS] %s has switched himself to the CT team.", name)     }     return PLUGIN_CONTINUE }
Apparently v3x tried in vain to make you aware of this earlier...
Quote:

Originally Posted by v3x
Code:
new CsTeams:team = cs_get_user_team(id); if(team == CS_TEAM_CT /* or whatever */) {   // }

b)

You have 3 separate functions that all do, more or less, the same thing. One for CTs, one for Ts, and one for Spectators. Your code could be a third of it's current size if you merge the three together so that you have only one code base instead of 3 copies with only certain variables changing.

c)

I strongly suggest you use the ML system that AMXX provides. Not only for easy translations but also so people can easily alter the English messages if they choose.

d)

Let's return to that sample function of yours that I quoted earlier...
Code:
public TEAMCT( id ) {     if(cs_get_user_team(id) == CS_TEAM_CT)     {         client_print(1, print_chat, "[TEAMS] You are already on the CT team.")         return PLUGIN_HANDLED     }           if(cs_get_user_team(id) != CS_TEAM_CT)     {         return PLUGIN_CONTINUE     }           else     {         new name[32]         get_user_name(id,name,31)         if(is_user_alive(id)) user_kill(id)         cs_set_user_team ( id, CS_TEAM_CT, CS_CT_URBAN)         client_print(0, print_chat, "[TEAMS] %s has switched himself to the CT team.", name)     }     return PLUGIN_CONTINUE }
Your else statement will NEVER get run. First, you check if it's a CT and you return. Next, you check if it is not a CT and you return. Guess what? The team will always be one of those two values. You couldn't have possibly tested this plugin or you would have found this out already.

Apparently VEN tried in vain to make you aware of this earlier...
Quote:

Originally Posted by VEN
Do you aware that your "else" statements contain unreachable code?

e)

Quote:

Originally Posted by Gender Specific Code
client_print(0, print_chat, "[TEAMS] %s has switched himself to the CT team.", name)

I recommend that you find a gender neutral way of indicating someone has switched to another team. While CS is dominated by males, there are a large number of females that play too.

f)

Care to compare/constrast this with the standard way of changing your team?

Hawk552 03-23-2006 09:25

This can be made better:

Code:
public TEAMCT( id )   {       if(cs_get_user_team(id) == CS_TEAM_CT)       {           client_print(id, print_chat, "[TEAMS] You are already on the CT team.")           return PLUGIN_HANDLED       }       else       {           new name[32]           get_user_name(id,name,31)           if(is_user_alive(id)) user_kill(id)           cs_set_user_team ( id, CS_TEAM_CT, CS_CT_URBAN)           client_print(0, print_chat, "[TEAMS] %s has switched himself to the CT team.", name)       }       return PLUGIN_CONTINUE   }

SweatyBanana 03-23-2006 17:05

a.) OK FIXING.
b.) Workin on it.
c.) how does that work? where do i get the code for that?
d.) didnt realize that.
e.) eh...ok...didnt think it was that big a deal
f.)

MINE:
easier...lets a player change their team regardless of team balancer.
easy to use.
etc..etc...

The built in version is bad in my opinion.

Hawk552 03-23-2006 17:10

Quote:

Originally Posted by SweatyBanana
a.) OK FIXING.
b.) Workin on it.
c.) how does that work? where do i get the code for that?
d.) didnt realize that.
e.) eh...ok...didnt think it was that big a deal
f.)

MINE:
easier...lets a player change their team regardless of team balancer.
easy to use.
etc..etc...

The built in version is bad in my opinion.

If this gets approved I will smash my head into the wall. And Brad, that doesn't mean approve this so I injure myself.

Brad 03-23-2006 17:11

c) http://wiki.amxmodx.org/index.php/Ad...ingual_Support
e) It's not a big deal. Just a suggestion.

If a server doesn't want the team balancer to affect players switching, why would they enable the team balancer?

SweatyBanana 03-23-2006 17:12

idk lol...but hawk this shud be approved just so u do :)

working on it :)

Brad 03-23-2006 17:16

As tempting as it is to approve it just for the resultant head injury... Banana has yet to convince me how this is any better than how players can do it normally.

SweatyBanana 03-23-2006 17:18

OK...

1.) FASTER SWITCH
2.) Doesnt have to pick a model
3.) spec switching without having to be dead to switch.(or typing kill in console)

4.) You love me :)

SweatyBanana 03-23-2006 17:21

hmmm...hows that?

ill work on the multilingual..

anyway, ill also work on making it smaller.

Jordan 03-23-2006 18:24

If you switch teams you can do it at spawn + kill people. This is basically for people who are just lazy and can't push m, 1, 1.

SweatyBanana 03-24-2006 14:31

I know that...but this is still simply easier.

v3x 03-24-2006 19:56

Great for stackers. Maybe check the mp_limitteams cvar and integrate some sort of code in there to prevent stacking.

Brad 03-24-2006 20:14

Did you plan on fixing this plugin or should it be trashed?

SweatyBanana 03-24-2006 20:14

Planning :)

bmann_420 03-31-2006 18:15

Good Job, but isnt this a lil redundant. I have a team switch plugin from jghj that works perfectly when allied with admin slash. All you do is type y for chat then /team blah ct and it instantly puts you their with no deaths and with your weapons alive. But i guess it got trashed! since i cant find it. :x

SweatyBanana 04-01-2006 19:33

that stinks...

you should post it up :)


or *cough* give me the code *cough* and let me *Cough* post it up *cough*

capndurk 04-02-2006 16:16

Quote:

Originally Posted by bmann_420
Good Job, but isnt this a lil redundant. I have a team switch plugin from jghj that works perfectly when allied with admin slash. All you do is type y for chat then /team blah ct and it instantly puts you their with no deaths and with your weapons alive. But i guess it got trashed! since i cant find it. :x

The only problem with JGHG's plugin (or, at least, from what you describe) is that a person could do this in the middle of a round and kill his former teammates. Even if the person was somehow teleported to the opposite team's spawn... he could do this at the end of a round when the CT's are getting the hostages or whatever (while in the T spawn) and he'll become T and have an edge over them. No, I think the player should die, even if he does have his weapons and ammo intact the next round.

bmann_420 04-03-2006 07:23

Well, if you have people you dont trust, then thats an issue. I dont, so its not an issue. Nobody likes switching teams anyway, only if you ahve to and this is much easier to me and many others to just type in a few letters and be on the other team than opening a menu and dying and switching.

SweatyBanana 04-03-2006 09:10

yay im loved. :)

SubStream 06-30-2006 20:30

Re: /team switcher
 
Any update on this plugin Banana??? This is definetly useful since you can only change teams once per round and for admin to be able to switch from team to spec and back to a team within one round using a chat command is quicker...

And some will say "spec them when y ou're dead... " or something like that.. but in my server we have mp_forcecamera and stuff like that set up so you only view your team in first person when you're dead.. so to be able to go spec then back to my team within the same round just to spec someone else for hacking etc or to take a quick break to the bathroom or something is very convienent and quick...

this is a very useful plugin IMHO and definetly would be used by many people... at least that's my view ... and I think I will use it as well... Very useful and helpful and quick..

When you're in a big server and you have lots of people to spec and lots of people trying to talk to you.. that little bit of time waiting for the next round to switch teams or waiting for something to do something else... having a quick instant team change through chat is extremely helpful...

Between Vent, my clan, and all the other things going on simultaneously.. this will spead that little part of the game down.

Very useful.

Any updates sweaty?

GHW_Chronic 08-08-2006 23:15

Re: /team switcher
 
I'm sorry to say, but this plugin has been sitting here for a while and I cannot find any reason to approve this. unnaproved.

SweatyBanana 08-08-2006 23:23

Re: /team switcher
 
ooo I forgot about this..I may finish it when Im less busy in life.

pulpy 11-17-2006 02:19

Re: /team switcher
 
was searching around for something similar to this... is it possible to do admin restrictions to this? So only admins can switch teams? Also have it kill the user when they switch (or a cvar).. just be nice to have for my admins, i run a csdm uwc3 server, and once u join spec, u cant do nething without reconnecting.. kind of a hassle, just u said umight finish it, so im giving u some pointers, and like substream said, it has potential


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

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