public void CenterPrint(coGameConnection client, string message, string time, string lines) { if (lines == "" || lines.AsInt() > 3 || lines.AsInt() < 1) lines = "1"; console.commandToClient(client, "centerPrint", new[] {message, time, lines}); }
public void Ban(coGameConnection client) { MessageAll("MsgAdminForce", console.ColorEncode(@"\c2The Admin has banned %1."), client["playerName"]); if (!client.isAIControlled()) console.Call_Classname("BanList", "add", new[] {client["guid"], client.getAddress(), sGlobal["$Pref::Server::BanTime"]}); client.delete("You have been banned from this server"); }
public void ServerCmdTogglePathCamera(coGameConnection client, bool val) { string control = val ? client["PathCamera"] : client["camera"]; client.setControlObject(control); console.Call("clientCmdSyncEditorGui"); }
private void SendLoadInfoToClient(coGameConnection client) { coLevelInfo theLevelInfo = "theLevelInfo"; MessageClient(client, "MsgLoadInfo", "", theLevelInfo["levelName"]); for (int i = 0; theLevelInfo["desc[" + i + "]"] != ""; i++) MessageClient(client, "MsgLoadDescripition", "", theLevelInfo["desc[" + i + "]"]); MessageClient(client, "MsgLoadInfoDone", ""); }
public void GameConnectionLoadMission(coGameConnection client) { // Send over the information that will display the server info // when we learn it got there, we'll send the data blocks client["currentPhase"] = "0"; if (client.isAIControlled()) GameConnectionOnClientEnterGame(client); else { if (client.isObject()) console.commandToClient(client, "MissionStartPhase1", new[] {sGlobal["$missionSequence"], sGlobal["$Server::MissionFile"], sGlobal["MissionGroup.musicTrack"]}); console.print("*** Sending mission load to client: " + sGlobal["$Server::MissionFile"]); } }
public void ServerCmdMissionStartPhase1Ack(coGameConnection client, string seq) { // Make sure to ignore calls from a previous mission load if (seq != sGlobal["$missionSequence"] || !missionRunning) return; if (client["currentPhase"].AsDouble() != 0.0) return; client["currentPhase"] = "1"; // Start with the CRC client.setMissionCRC(iGlobal["$missionCRC"]); // Send over the datablocks... // OnDataBlocksDone will get called when have confirmation // that they've all been received. console.print("Transmitting Datablocks"); client.transmitDataBlocks(iGlobal["$missionSequence"]); }
public void MessageTeamExcept(coGameConnection client, string msgType, string msgString, string a1 = "", string a2 = "", string a3 = "", string a4 = "", string a5 = "", string a6 = "", string a7 = "", string a8 = "", string a9 = "", string a10 = "", string a11 = "", string a12 = "", string a13 = "") { string team = client["team"]; foreach (coGameConnection clientid in ClientGroup.Where(clientid => client["team"] == team && (clientid != client))) MessageClient(clientid, msgType, msgString, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); }
public void MessageClient(coGameConnection client, string msgtype, string msgstring, string a1 = "", string a2 = "", string a3 = "", string a4 = "", string a5 = "", string a6 = "", string a7 = "", string a8 = "", string a9 = "", string a10 = "", string a11 = "", string a12 = "", string a13 = "") { string function = console.addTaggedString("ServerMessage"); string tmsgtype = ""; if (msgtype.Length > 0) tmsgtype = (byte) msgtype[0] == (byte) 1 ? msgtype : console.addTaggedString(msgtype); string tmsgstring = ""; if (msgstring.Length > 0) tmsgstring = (byte) msgstring[0] == (byte) 1 ? msgstring : console.addTaggedString(msgstring); //console.error("Sending " + client + " message '" + console.getTaggedString(function) + "' - ' " + console.getTaggedString(tmsgtype) + "' - '" + tmsgstring + "'"); if (console.isObject(client)) console.commandToClient(client, function, new[] {tmsgtype, tmsgstring, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13}); }
public void ChatMessageAll(coGameConnection sender, string msgString, string a1 = "", string a2 = "", string a3 = "", string a4 = "", string a5 = "", string a6 = "", string a7 = "", string a8 = "", string a9 = "", string a10 = "") { if ((msgString.Trim().Length == 0) || SpamAlert(sender)) return; foreach (coGameConnection obj in ClientGroup) { if (sender["team"].AsInt() != 0) ChatMessageClient(obj, sender, sender["voiceTag"], sender["voicePitch"], msgString, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); else { if (obj["team"] == sender["team"]) ChatMessageClient(obj, sender, sender["voiceTag"], sender["voicePitch"], msgString, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); } } }
public void ServerCmdcarUnmountObj(coGameConnection client, coPlayer obj) { obj.unmount(); obj.setControlObject(obj); TransformF ejectpos = obj.getTransform(); ejectpos += new TransformF(0, 0, 5); obj.setTransform(ejectpos); coVehicle mvehicle = obj["mVehicle"]; Point3F ejectvel = mvehicle.getVelocity(); ejectvel += new Point3F(0, 0, 10); ejectvel = ejectvel.vectorScale(((coSimDataBlock) (obj.getDataBlock()))["mass"].AsFloat()); obj.applyImpulse(ejectpos.MPosition, ejectvel); }
public void GameConnectionsyncClock(coGameConnection client, string time) { console.commandToClient(client, "syncClock", new[] {time}); }
public void GameConnectionstartMission(coGameConnection client) { // Inform the client the mission starting console.commandToClient(client, "MissionStart", new[] {sGlobal["$missionSequence"]}); }
public void GameConnectionSetPlayerName(coGameConnection client, string name) { client["sendGuid"] = "0"; // Minimum length requirements name = Util._strToPlayerName(name).Trim(); if (name.Length < 3) name = "Poser"; // Make sure the alias is unique, we'll hit something eventually if (!IsNameUnique(name)) { bool isUnique = false; string nametry = "NotSet"; for (int suffix = 1; !isUnique; suffix++) { nametry = name + "." + suffix; isUnique = IsNameUnique(nametry); } name = nametry; } client["nameBase"] = name; client["playerName"] = console.addTaggedString(console.ColorEncode(string.Format(@"\cp\c8{0}\co", name))); }
public void GameConnectSpamMessageTimeOut(coGameConnection thisobj) { if (thisobj["spamMessageCount"].AsInt() > 0) thisobj["spamMessageCount"] = (thisobj["spamMessageCount"].AsInt() - 1).AsString(); }
public void ClearBottomPrint(coGameConnection client) { console.commandToClient(client, "clearBottomPrint"); }
public void ClearCenterPrint(coGameConnection client) { console.commandToClient(client, "ClearCenterPrint"); }
public void ServerCmddismountVehicle(coGameConnection client) { coPlayer player = client["player"]; coVehicle car = player.getControlObject(); coPlayer passenger = car.getMountNodeObject(0); ((coSimDataBlock) passenger.getDataBlock()).call("doDismount", passenger, true.AsString()); client.setControlObject(player); }
public void ServerCmdsetPlayerControl(coGameConnection client) { coPlayer player = client["player"]; client.setControlObject(player); }
public void ServerCmdflipCar(coGameConnection client) { coPlayer player = client["player"]; coVehicle car = player.getControlObject(); if (car.getClassName() != "WheeledVehicle") return; TransformF carpos = car.getTransform(); carpos += new TransformF(0, 0, 3); car.setTransform(carpos); }
public void SendMsgClientKilledMineDamage(string msgType, coGameConnection client, coShapeBase sourceClient, string damLoc) { // Customized kill message for deaths caused by proximity mines if (sourceClient == 0) MessageAll(msgType, "%1 was blown up!", client["playerName"]); else if (sourceClient == client) MessageAll(msgType, "%1 stepped on his own mine!", client["playerName"]); else MessageAll(msgType, "%1 was blown up by %2!", client["playerName"], sourceClient["playerName"]); }
public void ServerCmdMissionStartPhase3Ack(coGameConnection client, string seq) { if (seq != sGlobal["$missionSequence"] || !missionRunning) return; if (client["currentPhase"].AsDouble() != 2.0) return; client["currentPhase"] = "3"; // Server is ready to drop into the game GameConnectionstartMission(client); GameConnectionOnClientEnterGame(client); }
public void GameConnectionspamReset(coGameConnection thisobj) { thisobj["isSpamming"] = false.AsString(); }
public void GameConnectiononDrop(coGameConnection client, string reason) { GameConnectionOnClientLeaveGame(client); RemoveFromServerGuidList(client["guid"]); MessageAllExcept(client, "-1", "MsgClientDrop", console.ColorEncode(@"\c1%1 has left the game."), client["playerName"], client); console.removeTaggedString(client["playerName"]); console.print(string.Format("CDROP: {0} {1}", client, client.getAddress())); Server__PlayerCount--; }
public string GameConnectionOnConnectRequest(coGameConnection client, string netAddress, string name) { console.print(string.Format("Connect request from:{0}", netAddress)); return Server__PlayerCount >= pref__Server__MaxPlayers ? "CR_SERVERFULL" : ""; }
public void GameConnectionendMission(coGameConnection client) { // Inform the client the mission is done. Note that if this is // called as part of the server destruction routine, the client will // actually never see this comment since the client connection will // be destroyed before another round of command processing occurs. // In this case, the client will only see the disconnect from the server // and should manually trigger a mission cleanup. console.commandToClient(client, "MissionEnd", new[] {sGlobal["$missionSequence"]}); }
public void OnGhostAlwaysObjectsReceived(coGameConnection client) { // Ready for next phase. console.commandToClient(client, "MissionStartPhase3", new[] {sGlobal["$missionSequence"], sGlobal["$Server::MissionFile"]}); }
public bool SpamAlert(coGameConnection client) { if (!bGlobal["$Pref::Server::FloodProtectionEnabled"]) return false; if (!client["isSpamming"].AsBool() && client["spamMessageCount"].AsInt() >= iGlobal["$SPAM_MESSAGE_THRESHOLD"]) { console.error("Client " + client + " is spamming, message count = " + client["spamMessageCount"]); client["spamProtectStart"] = console.getSimTime().AsString(); client["isSpamming"] = true.AsString(); client.schedule(console.GetVarString("$SPAM_PENALTY_PERIOD"), "spamReset"); } if (client["isSpamming"].AsBool()) { double wait = Math.Floor((console.GetVarInt("$SPAM_PENALTY_PERIOD") - (console.getSimTime() - client["spamProtectStart"].AsDouble())/1000)); MessageClient(client, "", sGlobal["$SPAM_MESSAGE"], wait.AsString()); return true; } client["spamMessageCount"] = (client["spamMessageCount"].AsInt() + 1).AsString(); client.schedule(sGlobal["$SPAM_PROTECTION_PERIOD"], "spamMessageTimeout"); return false; }
public void ChatMessageTeam(coGameConnection sender, string team, string msgString, string a1 = "", string a2 = "", string a3 = "", string a4 = "", string a5 = "", string a6 = "", string a7 = "", string a8 = "", string a9 = "", string a10 = "") { if ((msgString.Trim().Length == 0) || SpamAlert(sender)) return; foreach (coGameConnection obj in ClientGroup.Where(obj => ((coGameConnection) obj)["team"] == sender["team"])) ChatMessageClient(obj, sender, console.GetVarString(string.Format("{0}.voiceTag", sender)), console.GetVarString(string.Format("{0}.voicePitch", sender)), msgString, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); }
public void GameConnectionOnConnect(coGameConnection client, string name) { // Send down the connection error info, the client is // responsible for displaying this message if a connection // error occures. MessageClient(client, "MsgConnectionError", "", sGlobal["$Pref::Server::ConnectionError"]); // Send mission information to the client SendLoadInfoToClient(client); // Simulated client lag for testing... // %client.setSimulatedNetParams(0.1, 30); // Get the client's unique id: // %authInfo = %client.getAuthInfo(); // %client.guid = getField( %authInfo, 3 ); client["guid"] = "0"; AddToServerGuidList(client["guid"]); // Set admin status if (client.getAddress() == "local") { client["isAdmin"] = true.AsString(); client["isSuperAdmin"] = true.AsString(); } else { client["isAdmin"] = false.AsString(); client["isSuperAdmin"] = false.AsString(); } // Save client preferences on the connection object for later use. client["gender"] = "Male"; client["armor"] = "Light"; client["race"] = "human"; client["skin"] = console.addTaggedString("base"); GameConnectionSetPlayerName(client, name); client["team"] = ""; client["score"] = "0"; console.print("CADD: " + client + " " + client.getAddress()); // If the mission is running, go ahead download it to the client if (missionRunning) GameConnectionLoadMission(client); else if (Server__LoadFailMsg != "") MessageClient(client, "MsgLoadFailed", Server__LoadFailMsg); Server__PlayerCount++; }
public void ChatMessageClient(coGameConnection client, coGameConnection sender, string voiceTag, string voicePitch, string msgString, string a1 = "", string a2 = "", string a3 = "", string a4 = "", string a5 = "", string a6 = "", string a7 = "", string a8 = "", string a9 = "", string a10 = "") { if (console.isObject(client)) if (!client["muted[" + sender + "]"].AsBool()) console.commandToClient(client, "ChatMessage", new string[] {sender, voiceTag, voicePitch, console.addTaggedString(msgString), a1, a2, a3, a4, a5, a6, a7, a8, a9, a10}); }