void ReadyCount(); void(entity e) DropFlag; string MapVote_Suggest(string m); .float floodcontrol_chat; .float floodcontrol_team; void Say(entity source, float teamsay, string msgin) { string msgstr, colorstr, cmsgstr, namestr; float flood; entity head; if(!teamsay) if(substring(msgin, 0, 1) == " ") msgin = substring(msgin, 1, strlen(msgin) - 1); // work around DP say bug (say_team does not have this!) msgin = formatmessage(msgin); if(msgin == "") return; if(source.classname != "player") colorstr = "^0"; // black for spectators else if(teams_matter) colorstr = Team_ColorCode(source.team); else teamsay = FALSE; if(intermission_running) teamsay = FALSE; /* * using bprint solves this... me stupid // how can we prevent the message from appearing in a listen server? // for now, just give "say" back and only handle say_team if(!teamsay) { clientcommand(self, strcat("say ", msgin)); return; } */ if(cvar("g_chat_teamcolors")) namestr = playername(source); else namestr = source.netname; if(teamsay) { msgstr = strzone(strcat("\{1}\{13}", colorstr, "(^3", namestr, colorstr, ") ^7", msgin, "\n")); cmsgstr = strcat(colorstr, "(^3", namestr, colorstr, ")\n^7", wordwrap(msgin, 50)); } else msgstr = strzone(strcat("\{1}", namestr, "^7: ", msgin, "\n")); // FLOOD CONTROL flood = 0; { float flood_spl; float flood_burst; float flood_lmax; var .float flood_field; float lines; if(teamsay) { flood_spl = cvar("g_chat_flood_spl_team"); flood_burst = cvar("g_chat_flood_burst_team"); flood_lmax = cvar("g_chat_flood_lmax_team"); flood_field = floodcontrol_team; } else { flood_spl = cvar("g_chat_flood_spl"); flood_burst = cvar("g_chat_flood_burst"); flood_lmax = cvar("g_chat_flood_lmax"); flood_field = floodcontrol_chat; } flood_burst = max(0, flood_burst - 1); // to match explanation in default.cfg, a value of 3 must allow three-line bursts and not four! lines = ceil(strlennocol(msgstr) / 75); if(flood_lmax && lines > flood_lmax) flood = 2; else if(time >= self.flood_field) self.flood_field = max(time - flood_burst * flood_spl, self.flood_field) + lines * flood_spl; else flood = 1; } if(flood) { if(cvar("g_chat_flood_notify_flooder")) { if(flood == 1) sprint(self, strcat("^3FLOOD CONTROL: ^7wait ^1", ftos(self.flood_field - time), "^3 seconds\n")); else if(flood == 2) sprint(self, "^3FLOOD CONTROL: ^7message too long\n"); } else sprint(self, msgstr); ServerConsoleEcho(strcat("NOTE: ", playername(self), "^7 is flooding."), TRUE); } else if(teamsay) { if(source.classname == "player") { FOR_EACH_REALPLAYER(head) { if(head.team == source.team) { sprint(head, msgstr); centerprint(head, cmsgstr); } } } else { FOR_EACH_REALCLIENT(head) if(head.classname != "player") { sprint(head, msgstr); centerprint(head, cmsgstr); } } } else { //when g_tourney is active and g_tourney_disable_spec_chat is set and game is in matchstage //don't print the text from specs/observers to the players but only the other spectators if(g_tourney && cvar("g_tourney_disable_spec_chat") && tourneyInMatchStage && source.classname != "player") { FOR_EACH_REALCLIENT(head) if(head.classname != "player") { sprint(head, msgstr); } } else bprint(msgstr); //ServerConsoleEcho(substring(msgstr, 1, strlen(msgstr) - 2), TRUE); } strunzone(msgstr); } entity GetPlayer(string name) { float num; entity e; string ns; if(substring(name, 0, 1) == "#") { num = stof(substring(name, 1, 999)); if(num >= 1 && num <= maxclients) { for((e = world); num > 0; --num, (e = nextent(e))) ; //if(clienttype(e) == CLIENTTYPE_REAL) if(e.classname == "player") return e; } } else { ns = strdecolorize(name); FOR_EACH_REALPLAYER(e) { if(!strcasecmp(strdecolorize(e.netname), ns)) { return e; } } } return world; } //float ctf_clientcommand(); void SV_ParseClientCommand(string s) { local string cmd; local float i; tokenize(s); if(GameCommand_Vote(s, self)) { return; } else if(GameCommand_MapVote(argv(0))) { return; } else if(argv(0) == "autoswitch") { // be backwards compatible with older clients (enabled) self.autoswitch = ("0" != argv(1)); local string autoswitchmsg; if (self.autoswitch) { autoswitchmsg = "on"; } else { autoswitchmsg = "off"; } sprint(self, strcat("^1autoswitch turned ", autoswitchmsg, "\n")); } else if(argv(0) == "clientversion") { if not(self.flags & FL_CLIENT) return; if (argv(1) == "$gameversion") { //versionmsg = "^1client is too old to get versioninfo.\nUPDATE!!! (http://www.nexuiz.com)^8"; // either that or someone wants to be funny self.version = 1; } else { self.version = stof(argv(1)); } if(self.version != cvar("gameversion")) { self.classname = "observer"; self.version_mismatch = 1; PutClientInServer(); } else if(cvar("g_campaign") || cvar("g_balance_teams") || cvar("g_balance_teams_force")) { //JoinBestTeam(self, FALSE, TRUE); } else if(cvar("teamplay") && !cvar("sv_spectate")) { self.classname = "observer"; stuffcmd(self,"menu_showteamselect\n"); } } else if(argv(0) == "reportcvar") { // old system GetCvars(1); } else if(argv(0) == "sentcvar") { // new system GetCvars(1); } else if(argv(0) == "spectate") { if not(self.flags & FL_CLIENT) return; if(g_lms || g_arena) return; // don't allow spectating in lms, unless player runs out of lives if(self.classname == "player" && cvar("sv_spectate") == 1) { if(self.flagcarried) DropFlag(self.flagcarried); kh_Key_DropAll(self, TRUE); WaypointSprite_PlayerDead(); self.classname = "observer"; if(blockSpectators) sprint(self, strcat("^7You have to become a player within the next ", ftos(cvar("g_maxplayers_spectator_blocktime")), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n")); PutClientInServer(); } } else if(argv(0) == "join") { if not(self.flags & FL_CLIENT) return; if(!g_arena) if (self.classname != "player" && !lockteams) { if(isJoinAllowed()) { self.classname = "player"; PlayerScore_Clear(self); bprint ("^4", self.netname, "^4 is playing now\n"); PutClientInServer(); } else { //player may not join because of g_maxplayers is set centerprint_atprio(self, CENTERPRIO_MAPVOTE, PREVENT_JOIN_TEXT); } } } else if( argv(0) == "selectteam" ) { if not(self.flags & FL_CLIENT) return; if( !cvar("teamplay") ) { sprint( self, "selecteam can only be used in teamgames\n"); } else if(cvar("g_campaign")) { //JoinBestTeam(self, 0); } else if(lockteams) { sprint( self, "^7The game has already begun, you must wait until the next map to be able to join a team.\n"); } else if( argv(1) == "red" ) { DoTeamChange(COLOR_TEAM1); } else if( argv(1) == "blue" ) { DoTeamChange(COLOR_TEAM2); } else if( argv(1) == "yellow" ) { DoTeamChange(COLOR_TEAM3); } else if( argv(1) == "pink" ) { DoTeamChange(COLOR_TEAM4); } else if( argv(1) == "auto" ) { DoTeamChange(-1); } else { sprint( self, strcat( "selectteam none/red/blue/yellow/pink/auto - \"", argv(1), "\" not recognised\n" ) ); } } else if(argv(0) == "ready") { if not(self.flags & FL_CLIENT) return; if(cvar("sv_ready_restart")) { if(timeoutStatus) { return sprint(self, "^1You cannot reset the game while a timeout is active!\n"); } if(!restart_countdown || cvar("sv_ready_restart_repeatable")) { self.ready = TRUE; bprint(self.netname, "^2 is ready\n"); ReadyCount(); } else { sprint(self, "^1game has already been restarted\n"); } } } else if(argv(0) == "maplist") { local float n, j; local string col; n = tokenize(cvar_string("g_maplist")); sprint(self, "^7Maps in list: "); for(i = 0, j = 0; i < n; ++i) { if(MapInfo_CheckMap(argv(i))) { if(mod(j, 2)) col = "^2"; else col = "^3"; sprint(self, strcat(col, argv(i), " ")); ++j; } } sprint(self, "\n"); #ifdef MAPINFO } else if(argv(0) == "lsmaps") { sprint(self, "^7Maps available: "); for(i = 0; i < MapInfo_count; ++i) { if(mod(i, 2)) col = "^2"; else col = "^3"; sprint(self, strcat(col, MapInfo_BSPName_ByID(i), " ")); } sprint(self, "\n"); #endif } else if(argv(0) == "voice") { VoiceMessage(argv(1)); } else if(argv(0) == "say") { Say(self, FALSE, substring(s, 4, strlen(s) - 4)); //clientcommand(self, formatmessage(s)); } else if(argv(0) == "say_team") { Say(self, TRUE, substring(s, 9, strlen(s) - 9)); //clientcommand(self, formatmessage(s)); } else if(argv(0) == "info") { cmd = cvar_string(strcat("sv_info_", argv(1))); if(cmd == "") sprint(self, "ERROR: unsupported info command\n"); else wordwrap_sprint(cmd, 1111); } else if(argv(0) == "suggestmap") { sprint(self, strcat(MapVote_Suggest(argv(1)), "\n")); } else if(argv(0) == "calltimeout") { if not(self.flags & FL_CLIENT) return; if(cvar("sv_timeout")) { if(self.classname == "player") { if(votecalled) sprint(self, "^7Error: you can not call a timeout while a vote is active!\n"); else evaluateTimeoutCall(); } else sprint(self, "^7Error: only players can call a timeout!\n"); } } else if(argv(0) == "resumegame") { if not(self.flags & FL_CLIENT) return; if(cvar("sv_timeout")) { evaluateResumeGame(); } } else { //if(ctf_clientcommand()) // return; cmd = argv(0); /* checks not needed any more since DP has separated clientcommands and regular commands if(cmd != "status") if(cmd != "name") //if(cmd != "say") // handled above //if(cmd != "say_team") // handled above if(cmd != "tell") if(cmd != "color") if(cmd != "kill") if(cmd != "pause") if(cmd != "kick") if(cmd != "ping") if(cmd != "pings") if(cmd != "ban") if(cmd != "pmodel") if(cmd != "rate") if(cmd != "playermodel") if(cmd != "playerskin") if(cmd != "god") if(cmd != "notarget") if(cmd != "fly") if(cmd != "give") if(cmd != "noclip") { ServerConsoleEcho(strcat("WARNING: Invalid clientcommand by ", self.netname, ": ", s), TRUE); return; } */ clientcommand(self,s); } } void ReadyRestart() { local entity e; bprint("^1Server is restarting...\n"); // no arena, assault support yet... if(g_arena | g_assault | gameover | intermission_running | race_completing) localcmd("restart\n"); if(readyNagActive) { //if every player is ready, remove the ready-nagger again readyNagActive = 0; remove(readyNagger); } if(g_tourney) { tourneyInMatchStage = 1; //once the game is restarted the game is in match stage //reset weapons and ammo, health and armor to default: start_items = IT_LASER | IT_SHOTGUN; start_switchweapon = WEP_SHOTGUN; start_ammo_shells = cvar("g_start_ammo_shells"); start_ammo_nails = cvar("g_start_ammo_nails"); start_ammo_rockets = cvar("g_start_ammo_rockets"); start_ammo_cells = cvar("g_start_ammo_cells"); start_health = cvar("g_balance_health_start"); start_armorvalue = cvar("g_balance_armor_start"); } restart_countdown = time + RESTART_COUNTDOWN; restart_mapalreadyrestarted = 0; //reset this var, needed when cvar sv_ready_restart_repeatable is in use //reset the .ready status of all players (also spectators) FOR_EACH_CLIENT(e) { e.ready = 0; } if(0 (cvar("sv_timeout_resumetime") + 1) ) { bprint(strcat("^1Attention: ^7", self.netname, " resumed the game! Prepare for battle!\n")); remainingTimeoutTime = cvar("sv_timeout_resumetime"); timeoutHandler.nextthink = time; //timeoutHandler has to take care of it immediately } else sprint(self, "^7Error: Your resumegame call was discarded!\n"); } }