Jump to content

!stfu "power-mute" command


Weedkiller

Recommended Posts

This is the mighty !sftu command. It is intended for high level admins. It has precedence over !mute. !stfu'd players can not be !unmute'd; only !unstfu will lift the curse.

Feel free to use it, abuse it, destroy, erase, improve it.

 

 

///////////////////////////

// g_local.h

///////////////////////////

 

	// pheno: used for shrubbot freeze/unfreeze command
qboolean frozen;
// Weedkiller: used for shrubbot stfu command for precedence over mute
qboolean stfu;

 

 

 

 

///////////////////////////

// g_shrubbot.c

///////////////////////////

 

qboolean G_shrubbot_stfu(gentity_t *ent, int skiparg)
{
int pids[MAX_CLIENTS], seconds, modifier = 1;
char *reason, secs[8];
char name[MAX_NAME_LENGTH], err[MAX_STRING_CHARS];
char command[MAX_SHRUBBOT_CMD_LEN], *cmd;
gentity_t *vic;

Q_SayArgv(skiparg, command, sizeof(command));
cmd = command;
if(*cmd == '!'){
	cmd++;
}

if(Q_SayArgc() < 2+skiparg) {
	if(!Q_stricmp(cmd, "stfu")){
		SPC("^/stfu usage: ^7!stfu [name|slot#] [time] [reason]");
	}
	return qfalse;
}

Q_SayArgv(1+skiparg, name, sizeof(name));
if(ClientNumbersFromString(name, pids) != 1) {
	G_MatchOnePlayer(pids, err, sizeof(err));
	SPC(va("^/%sstfu: ^7%s",
		Q_stricmp(cmd, "stfu")? "un":"",
		err));
	return qfalse;
}

Q_SayArgv(2+skiparg, secs, sizeof(secs));
if(secs[0]) {
	int lastchar = strlen(secs) - 1;

	if(secs[lastchar] == 'w')
		modifier = 60*60*24*7;
	else if(secs[lastchar] == 'd')
		modifier = 60*60*24;
	else if(secs[lastchar] == 'h')
		modifier = 60*60;
	else if(secs[lastchar] == 'm')
		modifier = 60;

	if (modifier != 1)
		secs[lastchar] = '\0';
}
seconds = atoi(secs);
if(seconds > 0){
	seconds *= modifier;
}

if(seconds <= 0){
	reason = Q_SayConcatArgs(2+skiparg);
}else{
	reason = Q_SayConcatArgs(3+skiparg);
}

vic = &g_entities[pids[0]];
if(!_shrubbot_admin_higher(ent, vic)) {
	SPC(va("^/%sstfu: ^7sorry, but your intended victim has a higher admin"
		" level than you do", Q_stricmp(cmd, "mute")? "un":""));
	return qfalse;
}
if(_shrubbot_immutable(ent, vic)) {
       SPC(va("^/%sstfu: ^7sorry, but your intended victim is immune to shrubbot commands",
		Q_stricmp(cmd, "stfu")? "un":""));
       return qfalse;
   }
if(vic->client->sess.auto_unmute_time != 0) {
	if(!Q_stricmp(cmd, "stfu")) {
		if(vic->client->sess.auto_unmute_time == -1){
			seconds = 0;
		}else{
			seconds = (vic->client->sess.auto_unmute_time - level.time)/1000;
		}
		SPC(va("^/stfu: ^7player is already muted%s",
			seconds ? va(" for %i seconds", seconds) : ""));
		return qtrue;
	}
	vic->client->sess.auto_unmute_time = 0;
	vic->client->stfu = qfalse;
	CPx(pids[0], "cp \"^5You've been un-stfu'd\n\"" );
	AP(va("chat \"%s^7 has been un-stfu'd\" -1",
		vic->client->pers.netname ));
}else{
	if(!Q_stricmp(cmd, "unstfu")) {
		SPC("^/unstfu: ^7player is not currently muted");
		return qtrue;
	}
	if(seconds<=0){
		vic->client->sess.auto_unmute_time = -1;
		vic->client->stfu = qtrue;
	}else{
		vic->client->sess.auto_unmute_time = (level.time + 1000*seconds);
		vic->client->stfu = qtrue;
	}
	CPx(pids[0], va("cp \"^5You've been power-muted%s%s\n\"",
		(seconds > 0) ? va(" for %i seconds",seconds): "",
		*reason ? va(" because: %s", reason): ""));
	AP(va("chat \"%s^7 has been power-muted%s\" -1",
		vic->client->pers.netname,
		(seconds > 0) ? va(" for %i seconds",seconds): ""));
}
ClientUserinfoChanged(pids[0]);
return qtrue;
}

 

 

 

///////////////////////////

// g_shrubbot.c

///////////////////////////

 

	{"unpause",	G_shrubbot_unpause,	'Z', 0,
	"unpauses the game", ""},
{"unstfu",	G_shrubbot_stfu,	'e', 0,
	"unmute a stfu'd player", "[^3name|slot#^7]"},

 

 

 

///////////////////////////

// g_shrubbot_mute in g_shrubbot.c

///////////////////////////

if(_shrubbot_immutable(ent, vic)) {
       SPC(va("^/%smute: ^7sorry, but your intended victim is immune to shrubbot commands",
		Q_stricmp(cmd, "mute")? "un":""));
       return qfalse;
   }

if(vic->client->stfu) {
       SPC(va("^/%smute: ^7Sorry, your victim is power-muted",
		Q_stricmp(cmd, "mute")? "un":""));
       return qfalse;
   }

 

 

 

///////////////////////////

// G_UnMute_v in g_vote.c

///////////////////////////

 

 

		if((!vote_allow_muting.integer && ent && !ent->client->sess.referee)	
	 ||
(!ent->client->stfu) ) {

	G_voteDisableMessage(ent, arg);

	return(G_INVALID);

 

Don't forget to do the shrubbot copy/paste drill.

I made it just now, but it seems to work fine.

 

post-6101-0-36363100-1306331678_thumb.jpg

Link to comment
Share on other sites

Thank you. I got the idea from playing on your servers.

Somehow the !mute command are often used in a different way, on busy servers. In a more "light" or "light-weight" way.

 

 

 

 

Of course, you will have to hard-code my example. You will have to create a new mod. Nudge nudge.

Edit: It would also work with minimum etpub 0.9.1 client .pk3s since the only file affected is qagame_mp_x86.dll.

 

 

*boy, I'm so cool!*

No, not at all. More or less, all I did was to copy g_shrubbot_mute & take a good look at ...let me find it again...vs2k8.sln....There it is: "sess.auto_unmute_time"

Edited by Weedkiller
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.