void AdminForceBreak () { if( is_adm( self ) && self->ct != ctPlayer && !match_in_progress ) { k_force = 0; return; } if( !is_adm( self ) || !match_in_progress ) return; if( self->ct != ctPlayer && match_in_progress == 1 ) { k_force = 0; StopTimer( 1 ); return; } if( k_oldmaxspeed ) // huh??? cvar_fset( "sv_maxspeed", k_oldmaxspeed ); G_bprint(2, "%s forces a break!\n", self->netname); EndMatch( 0 ); }
void ToggleMapLock () { float tmp; if( !is_adm( self ) ) return; tmp = cvar( "k_lockmap" ); if( tmp ) { cvar_fset( "k_lockmap", 0 ); if( !match_in_progress ) G_bprint(2, "%s unlocks map\n", self->netname); else G_sprint(self, 2, "Map unlocked\n"); return; } cvar_fset( "k_lockmap", 1 ); if( !match_in_progress ) G_bprint(2, "%s locks map\n", self->netname); else G_sprint(self, 2, "Map is locked\n"); }
void antilag( ) { int votes; if ( match_in_progress ) { G_sprint(self, 2, "%s mode %s\n", redtext("Antilag"), OnOff(2 == cvar("sv_antilag"))); return; } // admin may turn this status alone on server... if ( !is_adm( self ) ) { // Dont need to bother if less than 2 players if ( CountPlayers() < 2 ) { G_sprint(self, 2, "You need at least 2 players to do this.\n"); return; } } self->v.antilag = !self->v.antilag; G_bprint(2, "%s %s!%s\n", self->s.v.netname, (self->v.antilag ? redtext(va("votes for antilag %s", OnOff(!(2 == cvar("sv_antilag"))))) : redtext(va("withdraws %s antilag vote", g_his(self)))), ((votes = get_votes_req( OV_ANTILAG, true )) ? va(" (%d)", votes) : "")); vote_check_antilag (); }
void nospecs( ) { int votes; if ( match_in_progress ) { G_sprint(self, 2, "%s mode %s\n", redtext("No spectators"), OnOff(cvar("_k_nospecs"))); return; } // admin may turn this status alone on server... if ( !is_adm( self ) ) { // Dont need to bother if less than 2 players if ( CountPlayers() < 2 ) { G_sprint(self, 2, "You need at least 2 players to do this.\n"); return; } } self->v.nospecs = !self->v.nospecs; G_bprint(2, "%s %s!%s\n", self->s.v.netname, (self->v.nospecs ? redtext(va("votes for nospecs %s", OnOff(!cvar("_k_nospecs")))) : redtext(va("withdraws %s nospecs vote", g_his(self)))), ((votes = get_votes_req( OV_NOSPECS, true )) ? va(" (%d)", votes) : "")); vote_check_nospecs (); }
void teamoverlay( ) { int votes; if ( match_in_progress ) { G_sprint(self, 2, "%s %s\n", redtext("Teamoverlay"), OnOff(cvar("k_teamoverlay"))); return; } // admin may turn this status alone on server... if ( !is_adm( self ) ) { // Dont need to bother if less than 2 players if ( CountPlayers() < 2 ) { G_sprint(self, 2, "You need at least 2 players to do this.\n"); return; } } self->v.teamoverlay = !self->v.teamoverlay; G_bprint(2, "%s %s!%s\n", self->netname, (self->v.teamoverlay ? redtext(va("votes for teamoverlay %s", OnOff(!cvar("k_teamoverlay")))) : redtext(va("withdraws %s teamoverlay vote", g_his(self)))), ((votes = get_votes_req( OV_TEAMOVERLAY, true )) ? va(" (%d)", votes) : "")); vote_check_teamoverlay (); }
int is_admins_vote( int fofs ) { int votes = 0; gedict_t *p; for ( p = world; (p = find_client( p )); ) if ( *(int*)((byte*)(&p->v)+fofs) && is_adm( p ) ) votes++; return votes; }
void AdminForceStart () { gedict_t *mess; if (match_in_progress || match_over || !is_adm(self)) { return; } // no forcestart in practice mode if ( k_practice ) { G_sprint(self, 2, "%s\n", redtext("Server in practice mode")); return; } if( self->ct == ctPlayer && !self->ready ) { PlayerReady(); if ( !self->ready ) { G_sprint(self, 2, "Ready yourself first\n"); return; } } if( find(world, FOFCLSN, "mess") ) { G_sprint(self, 2, "forcestart already in progress!\n"); return; } k_attendees = CountPlayers(); if ( !isCanStart( self, true ) ) { G_sprint(self, 2, "Can't issue!\n"); return; } if( k_attendees ) { G_bprint(2, "%s forces matchstart!\n", self->netname); k_force = 1; mess = spawn(); mess->classname = "mess"; mess->s.v.owner = EDICT_TO_PROG( self ); mess->think = ( func_t ) ReadyThink; mess->s.v.nextthink = g_globalvars.time + 0.1; mess->attack_finished = 10 + 1; } else G_sprint(self, 2, "Can't issue! More players needed.\n"); }
void KickThink () { if( !self->k_kicking ) return; if ( self->k_kicking + 60 < g_globalvars.time ) { // Check the 1 minute timeout for kick mode G_sprint( self, 2, "Your %s mode has timed out\n", redtext("kick")); ExitKick( self ); return; } if ( !is_adm( self ) ) { ExitKick( self ); // not admin now, so cancel kick mode, just for sanity return; } }
// fill maps_voted[] with data, // return the index in maps_voted[] of most voted map // return -1 inf no votes at all or some failures // if admin votes for map - map will be treated as most voted int vote_get_maps () { int best_idx = -1, i; gedict_t *p; memset(maps_voted, 0, sizeof(maps_voted)); maps_voted_idx = -1; if ( !get_votes( OV_MAP ) ) return -1; // no one votes at all for( p = world; (p = find_client( p )); ) { if ( !p->v.map ) continue; // player is not voted if (!race_allow_map_vote(p)) continue; for ( i = 0; i < MAX_CLIENTS; i++ ) { if ( !maps_voted[i].map_id ) break; // empty if ( maps_voted[i].map_id == p->v.map ) break; // already count votes for this map } if ( i >= MAX_CLIENTS ) continue; // heh, all slots is full, just for sanity maps_voted[i].map_id = p->v.map; maps_voted[i].map_votes += 1; maps_voted[i].admins += (is_adm( p ) ? 1 : 0); // find the most voted map if ( best_idx < 0 || maps_voted[i].map_votes > maps_voted[best_idx].map_votes ) best_idx = i; // admin voted maps have priority if ( maps_voted[i].admins > maps_voted[best_idx].admins ) best_idx = i; } return (maps_voted_idx = best_idx); }
// ktpro (c) void force_spec() { qbool found = false; gedict_t *p = NULL; char *c_fs, arg_2[1024]; int i_fs, argc = trap_CmdArgc(); if ( !is_adm( self ) ) return; trap_CmdArgv( 1, arg_2, sizeof( arg_2 ) ); c_fs = (argc >= 2 ? arg_2 : ezinfokey(self, "fs")); if ( strnull( c_fs ) ) { G_sprint(self, 2, "set setinfo \"fs\" properly\n"); G_sprint(self, 2, "to force spec all not ready players\n"); G_sprint(self, 2, "type: %s\n", redtext("setinfo fs \"*\"")); G_sprint(self, 2, "or: %s to force spec specified player\n", redtext("setinfo fs \"playername\"")); G_sprint(self, 2, "or just: %s\n", redtext("/force_spec \"playername\"")); return; } if ( streq( c_fs, "*") || streq( c_fs, "* ") ) { //ok move all not ready players to specs for( p = world; (p = find_plr( p )); ) { if ( p->ready || p == self ) continue; found = true; do_force_spec(p, self, true); } } else { p = ( (i_fs = atoi( c_fs ) ) < 0 ? spec_by_id( -i_fs ) : SpecPlayer_by_IDorName( c_fs )); if ( p ) { found = true; do_force_spec(p, self, p->ct != ctSpec); } } if ( !found ) G_sprint(self, 2, "can't find specified players\n"); }
// multi kick void m_kick () { int i, k; gedict_t *p; char arg_x[1024], *str; int argc = trap_CmdArgc(); if( !is_adm( self ) ) { G_sprint(self, 2, "You are not an admin\n"); return; } trap_CmdArgv( 1, arg_x, sizeof( arg_x ) ); if ( argc < 2 || !only_digits(arg_x) ) { G_sprint(self, 2, "mkick <id1 [id2 [id3 ...]] [reason]>\n"); return; } for ( k = 0, i = 1; i < argc; i++ ) { trap_CmdArgv( i, arg_x, sizeof( arg_x ) ); if ( !only_digits(arg_x) ) break; if ( !(p = SpecPlayer_by_id( atoi(arg_x) )) && !(p = not_connected_by_id( atoi(arg_x) )) ) { G_sprint(self, 2, "mkick: client %s not found\n", arg_x); continue; } if( !DoKick( p, self ) ) continue; k++; } if ( !k ) return; if ( !strnull( str = params_str(i, -1) ) ) // show reason G_bprint(2, "\x90%s\x91\n", str); }
void TogglePreWar () { int k_prewar = bound(0, cvar( "k_prewar" ), 2); if (!is_adm(self)) { return; } if (++k_prewar > 2) { k_prewar = 0; } switch ( k_prewar ) { case 1: if( !match_in_progress ) G_bprint(2, "Players may fire before match\n"); else G_sprint(self, 2, "Players may fire before match\n"); break; case 2: if ( !match_in_progress ) { G_bprint(2, "Players may fire and jump when %s\n", redtext("ready")); PlayersStopFire(); } else G_sprint(self, 2, "Players may fire and jump when %s\n", redtext("ready")); break; case 0: default: if ( !match_in_progress ) { G_bprint(2, "Players may %s fire before match\n", redtext("not")); PlayersStopFire(); } else G_sprint(self, 2, "Players may %s fire before match\n", redtext("not")); break; } cvar_fset( "k_prewar", k_prewar ); }
void AdminKick () { int argc = trap_CmdArgc(); if( !is_adm( self ) ) { G_sprint(self, 2, "You are not an admin\n"); return; } if( self->k_kicking ) { ExitKick( self ); return; } if ( argc >= 2 ) { gedict_t *p; char arg_2[1024], *str; trap_CmdArgv( 1, arg_2, sizeof( arg_2 ) ); if ( !(p = SpecPlayer_by_IDorName( arg_2 )) && !(p = not_connected_by_IDorName( arg_2 )) ) { G_sprint(self, 2, "kick: client %s not found\n", arg_2); return; } if ( DoKick( p, self ) && !strnull( str = params_str(2, -1) ) ) // show reason G_bprint(2, "\x90%s\x91\n", str); return; } G_sprint(self, 2, "Kicking process started\n" "�����������������������\n" "Type \371 to kick, \356 for next, %s to leave\n", redtext("kick")); self->k_kicking = g_globalvars.time; self->k_playertokick = world; NextClient(); }
// convienence command for ctf admins // often times you play a game on non-symmetrical map as one color then swap teams and play again to be fair void AdminSwapAll() { gedict_t *p; if ( !is_adm( self ) ) return; if ( match_in_progress ) return; if ( !isCTF() ) return; for( p = world; (p = find_plr( p )); ) { if ( streq( getteam(p), "blue" ) ) stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "team \"red\"\ncolor 4\n"); else if ( streq( getteam(p), "red" ) ) stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "team \"blue\"\ncolor 13\n"); } G_bprint(2, "%s swapped the teams\n", getname( self ) ); }
void VoteAdmin() { gedict_t *p; int till; gedict_t *electguard; // Can't allow election and code entering for the same person at the same time if( self->k_adminc ) { G_sprint(self, 2, "Finish entering the code first\n"); return; } if( is_adm( self ) ) { G_sprint(self, 2, "You are already an admin\n"); return; } if( is_elected( self, etAdmin ) ) { G_bprint(2, "%s %s!\n", self->netname, redtext("aborts election")); AbortElect(); return; } // Only one election per server because otherwise we wouldn't know how to count // "yes"s or "no"s if( get_votes( OV_ELECT ) ) { G_sprint(self, 2, "An election is already in progress\n"); return; } if( !cvar( "k_admins" ) ) { G_sprint(self, 2, "%s on this server!\n", redtext("NO admins")); return; } // Check if voteadmin is allowed if( !cvar( "k_allowvoteadmin" ) ) { G_sprint(self, 2, "Admin election is not allowed on this server\n"); return; } if( (till = Q_rint( self->v.elect_block_till - g_globalvars.time)) > 0 ) { G_sprint(self, 2, "Wait %d second%s!\n", till, count_s(till) ); return; } if( self->ct == ctSpec && match_in_progress ) return; G_bprint(2, "%s has %s rights!\n", self->netname, redtext("requested admin")); for( p = world; (p = find_client( p )); ) if ( p != self && p->ct == ctPlayer ) G_sprint(p, 2, "Type %s in console to approve\n", redtext("yes")); G_sprint(self, 2, "Type %s to abort election\n", redtext("elect")); // announce the election self->v.elect = 1; self->v.elect_type = etAdmin; electguard = spawn(); // Check the 1 minute timeout for election electguard->s.v.owner = EDICT_TO_PROG( world ); electguard->classname = "electguard"; electguard->think = ( func_t ) ElectThink; electguard->s.v.nextthink = g_globalvars.time + 60; }
void ReqAdmin () { // check for election if( is_elected(self, etAdmin) ) { G_sprint(self, 2, "Abort %sion first\n", redtext("elect")); return; } if( is_adm( self ) ) { G_bprint(2, "%s is no longer an %s\n", self->netname, redtext("admin")); if( self->k_kicking ) ExitKick( self ); self->k_admin = 0; // ok, remove all admin flags on_unadmin( self ); return; } if( self->k_adminc ) { G_sprint(self, 2, "%s code canceled\n", redtext("admin")); self->k_adminc = 0; return; } if( !cvar( "k_admins" ) ) { G_sprint(self, 2, "%s on this server!\n", redtext("NO admins")); return; } if ( VIP_IsFlags( self, VIP_ADMIN ) ) // this VIP does't required pass { BecomeAdmin(self, AF_REAL_ADMIN); return; } // parse /admin <pass> if ( trap_CmdArgc() == 2 ) { char arg_2[1024]; char *pass = cvar_string( "k_admincode" ); int till = Q_rint(self->k_adm_lasttime + 5 - g_globalvars.time); if( self->k_adm_lasttime && till > 0 ) { // probably must help against brute force G_sprint(self, 2, "Wait %d second%s!\n", till, count_s(till) ); return; } trap_CmdArgv( 1, arg_2, sizeof( arg_2 ) ); if ( !strnull(pass) && strneq(pass, "none") && streq(arg_2, pass) ) BecomeAdmin(self, AF_REAL_ADMIN); else { G_sprint(self, 2, "%s...\n", redtext("Access denied")); self->k_adm_lasttime = g_globalvars.time; } return; } self->k_adminc = 6; self->k_added = 0; // You can now use numbers to enter code G_sprint(self, 2, "Use %s or %s to enter code\n", redtext("numbers"), redtext("impulses") ); }