AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [Tf2] Randomly force a player to medic? (https://forums.alliedmods.net/showthread.php?t=200461)

Ponco 11-09-2012 06:16

[Tf2] Randomly force a player to medic?
 
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

waylaidwanderer 11-09-2012 12:54

Re: [Tf2] Randomly force a player to medic?
 
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.

happs 11-09-2012 15:08

Re: [Tf2] Randomly force a player to medic?
 
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;



waylaidwanderer 11-09-2012 15:18

Re: [Tf2] Randomly force a player to medic?
 
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.

happs 11-09-2012 15:30

Re: [Tf2] Randomly force a player to medic?
 
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");



Powerlord 11-09-2012 16:55

Re: [Tf2] Randomly force a player to medic?
 
Quote:

Originally Posted by happs (Post 1835342)
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.

waylaidwanderer 11-09-2012 18:03

Re: [Tf2] Randomly force a player to medic?
 
1 Attachment(s)
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?

Ponco 11-10-2012 00:41

Re: [Tf2] Randomly force a player to medic?
 
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.

waylaidwanderer 11-10-2012 01:03

Re: [Tf2] Randomly force a player to medic?
 
Quote:

Originally Posted by Ponco (Post 1835552)
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.

Nano2e 11-10-2012 02:51

Re: [Tf2] Randomly force a player to medic?
 
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


All times are GMT -4. The time now is 06:35.

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