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

[Tf2] Randomly force a player to medic?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ponco
Junior Member
Join Date: Nov 2012
Old 11-09-2012 , 06:16   [Tf2] Randomly force a player to medic?
Reply With Quote #1

Hey all!

I'm looking to make a plugin whereby, once a PUG server has 12 players, I can type 'sm_pickmedic' and it will pick one player at random (and thus swap them to medic or merely print in console repeatedly they're medic). Further, could I give immunity: 'sm_pickmedic_immunity <#userid|name>' ?


Players can also type '!medic' in chat to elect to be medic, they can also type '!whoismedic' to see who was randomly selected. How does one hook into what players type in chat?


I don't know where to start, is there any documentation that can steer me or could some nice soul give me some starting points?


Thanks

Last edited by Ponco; 11-09-2012 at 06:17.
Ponco is offline
waylaidwanderer
SourceMod Donor
Join Date: Aug 2012
Old 11-09-2012 , 12:54   Re: [Tf2] Randomly force a player to medic?
Reply With Quote #2

This seems like an interesting plugin. I could probably code the first part easily enough, but I'm not sure about the second part... I think I could probably do it too though.
waylaidwanderer is offline
happs
Junior Member
Join Date: Aug 2012
Old 11-09-2012 , 15:08   Re: [Tf2] Randomly force a player to medic?
Reply With Quote #3

Second part I think is something like the following..
PHP Code:
OnPluginStart()
{
... 
   
AddCommandListener(Listener_Say"say"); // maybe say_team as well
}

public 
Action:Listener_Say(client, const String:command[], argc)
{
   
decl sCmd[32]="";
   
GetCmdArg(1sCmdsizeof(sCmd));
   if(
StrEqual(sCmd,"!medic",false)) {
     
AddMedicCanidate(client);
   } else if(
StrEqual(sCmd,"!whoismedic"),false) {
     
DisplayMedicCanidates(client);
   } 
  return 
Plugin_Continue;


Last edited by happs; 11-09-2012 at 15:09.
happs is offline
waylaidwanderer
SourceMod Donor
Join Date: Aug 2012
Old 11-09-2012 , 15:18   Re: [Tf2] Randomly force a player to medic?
Reply With Quote #4

Instead of doing that, why not just create a new command? That way /whoismedic will work as well, for example.

Anyway, I'm still coding the plugin and I'm making good progress.
waylaidwanderer is offline
happs
Junior Member
Join Date: Aug 2012
Old 11-09-2012 , 15:30   Re: [Tf2] Randomly force a player to medic?
Reply With Quote #5

I imagine it would be easier for new users to just use the say channel. That way they won't have to open up the console (possibly enable first), and type a new command. Plus, not everyone reads the motd, and by hooking the say command, the existence of the new commands can be picked up from others.

best of both?
PHP Code:
DisplayMedicCanidates(client)
{
    
ClientCommand(client,"/whoismedic");


Last edited by happs; 11-09-2012 at 15:33.
happs is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 11-09-2012 , 16:55   Re: [Tf2] Randomly force a player to medic?
Reply With Quote #6

Quote:
Originally Posted by happs View Post
I imagine it would be easier for new users to just use the say channel. That way they won't have to open up the console (possibly enable first), and type a new command. Plus, not everyone reads the motd, and by hooking the say command, the existence of the new commands can be picked up from others.

best of both?
PHP Code:
DisplayMedicCanidates(client)
{
    
ClientCommand(client,"/whoismedic");

PHP Code:
RegConsoleCmd("whoismedic"Something); 
would automatically register !whoismedic and /whoismedic.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
waylaidwanderer
SourceMod Donor
Join Date: Aug 2012
Old 11-09-2012 , 18:03   Re: [Tf2] Randomly force a player to medic?
Reply With Quote #7

Here's what I cobbled together. I'm not sure if it works, but it compiles fine.

If someone could test it, that'd be great.

Description:
Forces a random player to medic.
Commands:
  • sm_pickmedic | Randomly chooses a player, and then forces them to become a medic. Can be also triggered by typing !pickmedic or /pickmedic into chat. | Default Flag: GENERIC | Override: sm_pickmedic

Cvars:
  • sm_pickmedic_version | Plugin version. Do not edit.
  • sm_pickmedic_enabled | 0 = Disable plugin, 1 = Enable plugin | Default Value: 1
  • sm_pickmedic_immune | Are admins immune to the plugin? | 0 = No, 1 = Yes | Default Value: 1 --- NOT WORKING CURRENTLY

Installation:
Place pickmedic.smx into your addons/sourcemod/plugins folder.

Oh, and I forgot to add an admin flag to the command (derp!), so I'll change it later when I have time, assuming the plugin works. If not, I'll have to fix up those errors first.

Edit: did some testing and the current way I tried writing in admin immunity breaks the code. However, without that code, picking and setting a random person to be medic works fine. Reuploaded plugin.

Edit 2: Question: Do you want to only pick a medic on the same team you are? Or just a medic from anyone on the server?
Attached Files
File Type: sp Get Plugin or Get Source (pickmedic.sp - 338 views - 2.5 KB)

Last edited by waylaidwanderer; 11-10-2012 at 00:58. Reason: Reuploaded pickmedic plugin, added admin flag. + a question!
waylaidwanderer is offline
Ponco
Junior Member
Join Date: Nov 2012
Old 11-10-2012 , 00:41   Re: [Tf2] Randomly force a player to medic?
Reply With Quote #8

Thank you all so much! I would thank you all individually, but I'm still getting used to using these forums.


I'll test out some of the things, and get back to you asap.
Ponco is offline
waylaidwanderer
SourceMod Donor
Join Date: Aug 2012
Old 11-10-2012 , 01:03   Re: [Tf2] Randomly force a player to medic?
Reply With Quote #9

Quote:
Originally Posted by Ponco View Post
Thank you all so much! I would thank you all individually, but I'm still getting used to using these forums.


I'll test out some of the things, and get back to you asap.
Let me know what you think of my plugin I can try to add additional features if requested, but for now I'm gonna try to figure out how to add admin immunity to it.

And oh yes, please let me know if you want to target just your team or everyone.

Last edited by waylaidwanderer; 11-10-2012 at 01:03.
waylaidwanderer is offline
Nano2e
SourceMod Donor
Join Date: Apr 2012
Location: Australia
Old 11-10-2012 , 02:51   Re: [Tf2] Randomly force a player to medic?
Reply With Quote #10

in my random medic system when ever a client is chosen i whitelist them (write them to a file) and when the random call is picked if it finds there steamid in the medic whtelist file it will choose another one, my problem is that it doesnt always work

do you think you could add a proper whitelist option, would be nice to play pugs were medics arnt chosen twice
__________________
Veni Vidi Vici
Nano2e 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 08:14.


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