Exemplo n.º 1
0
        public static void BottomPrint(GameConnection client, string message, string time, string lines)
        {
            if (lines == "" || lines.AsInt() > 3 || lines.AsInt() < 1)
                lines = "1";

            t3d.console.commandToClient(client, "bottomPrint", new[] {message, time, lines});
        }
Exemplo n.º 2
0
 public static void Ban(GameConnection client)
 {
     message.MessageAll("MsgAdminForce", omni.console.ColorEncode(@"\c2The Admin has banned %1."), client["playerName"]);
     if (!client.isAIControlled())
         omni.console.Call_Classname("BanList", "add", new[] {client["guid"], client.getAddress(), omni.sGlobal["$Pref::Server::BanTime"]});
     client.delete("You have been banned from this server");
 }
Exemplo n.º 3
0
        static public bool SpamAlert(GameConnection client)
            {
            if (!tst.bGlobal["$Pref::Server::FloodProtectionEnabled"])
                return false;

            if (!client["isSpamming"].AsBool() && client["spamMessageCount"].AsInt() >= SPAM_MESSAGE_THRESHOLD)
                {
                tst.console.error("Client " + client + " is spamming, message count = " + client["spamMessageCount"]);
                client["spamProtectStart"] = tst.console.getSimTime().AsString();
                client["isSpamming"] = true.AsString();
                using (BackgroundWorker bwr_SPAM_PENALTY_PERIOD = new BackgroundWorker())
                    {
                    bwr_SPAM_PENALTY_PERIOD.DoWork += new DoWorkEventHandler(bwr_SPAM_PENALTY_PERIOD_DoWork);
                    bwr_SPAM_PENALTY_PERIOD.RunWorkerAsync(client);
                    }
                }

            if (client["isSpamming"].AsBool())
                {
                double wait = Math.Floor((SPAM_PENALTY_PERIOD - (tst.console.getSimTime() - client["spamProtectStart"].AsDouble()) / 1000));
                MessageClient(client, "", SPAM_MESSAGE, wait.AsString());
                return true;
                }
            client["spamMessageCount"] = (client["spamMessageCount"].AsInt() + 1).AsString();

            using (BackgroundWorker bwrSPAM_PROTECTION_PERIOD = new BackgroundWorker())
                {
                bwrSPAM_PROTECTION_PERIOD.DoWork += new DoWorkEventHandler(bwrSPAM_PROTECTION_PERIOD_DoWork);
                }

            


            return false;
            }
Exemplo n.º 4
0
        public static void sendMsgClientKilled_Impact(string msgtype, GameConnection client, GameConnection sourceclient, string damloc)
        {
            if (client.isObject())

                message.MessageAll(msgtype, "%1 fell to his death!", client["playerName"]);
            // console.GetVarString(string.Format("{0}.playerName", client)));
        }
Exemplo n.º 5
0
 public static void sendMsgClientKilled_TurretDamage(string msgtype, GameConnection client, GameConnection sourceclient, string damloc)
 {
     if (sourceclient == 0)
         message.MessageAll(msgtype, "%1 was shot down by a turret!", client["playerName"] + ");");
     else if (sourceclient == client)
         message.MessageAll(msgtype, "%1 kill by his own turret!", client["playerName"] + ");");
     else
         message.MessageAll(msgtype, "%1 was killed by a turret of %2!", client["playerName"] + ");", sourceclient["playerName"]);
 }
Exemplo n.º 6
0
 public static void sendMsgClientKilled_MineDamage(string msgType, GameConnection client, GameConnection sourceClient, string damLoc)
 {
     // Customized kill message for deaths caused by proximity mines
     if (sourceClient == 0)
         message.MessageAll(msgType, "%1 was blown up!", client["playerName"]);
     else if (sourceClient == client)
         message.MessageAll(msgType, "%1 stepped on his own mine!", client["playerName"]);
     else
         message.MessageAll(msgType, "%1 was blown up by %2!", client["playerName"], sourceClient["playerName"]);
 }
Exemplo n.º 7
0
        public static void sendMsgClientKilled_Default(string msgtype, GameConnection client, GameConnection sourceclient, string damloc)
        {
            if (!client.isObject())
                return;
            if (sourceclient == client)
                sendMsgClientKilled_Suicide(msgtype, client, sourceclient, damloc);

            else if (omni.console.GetVarString(sourceclient["team"]) != string.Empty && sourceclient["team"] != client["team"])
                message.MessageAll(msgtype, "%1 killed by %2 - friendly fire!", client["playerName"], sourceclient["playerName"]);
            else
                message.MessageAll(msgtype, "%1 gets nailed by %2!", client["playerName"], sourceclient.isObject() ? sourceclient["playerName"] : "a Bot!");
        }
        public static void serverCmdcarUnmountObj(GameConnection client, Player obj)
        {
            obj.unmount();
            obj.setControlObject(obj);

            TransformF ejectpos = obj.getTransform();
            ejectpos += new TransformF(0, 0, 5);
            obj.setTransform(ejectpos);

            Vehicle mvehicle = obj["mVehicle"];

            Point3F ejectvel = mvehicle.getVelocity();
            ejectvel += new Point3F(0, 0, 10);

            ejectvel = ejectvel.vectorScale(((SimDataBlock) (obj.getDataBlock()))["mass"].AsFloat());

            obj.applyImpulse(ejectpos.GetPosition(), ejectvel);
        }
Exemplo n.º 9
0
 public virtual void IncScore(GameConnection client, string score, string dontmessageall)
 {
     if (!console.isObject(client))
         return;
     console.SetVar(client + ".score", console.GetVarInt(client + ".score") + int.Parse(score));
     if (dontmessageall == "0")
         message.MessageAll("MsgClientScoreChanged", "", console.GetVarString(client + ".score"), console.GetVarString(client + "kills"), console.GetVarString(client + ".deaths"), client);
 }
Exemplo n.º 10
0
 public virtual int GetScore(GameConnection client)
 {
     return client["score"].AsInt();
 }
Exemplo n.º 11
0
        public static void serverCmdsetPlayerControl(GameConnection client)
        {
            Player player = client["player"];

            client.setControlObject(player);
        }
Exemplo n.º 12
0
 public virtual void IncDeaths(GameConnection client, string death, string dontmessageall)
 {
     if (!console.isObject(client))
         return;
     console.SetVar(string.Format("{0}.deaths", client), console.GetVarInt(string.Format("{0}.deaths", client)) + int.Parse(death));
     if (dontmessageall == "0")
         message.MessageAll("MsgClientScoreChanged", "", console.GetVarString(client + ".score"), console.GetVarString(client + ".kills"), console.GetVarString(client + ".deaths"), client);
 }
Exemplo n.º 13
0
 public virtual string onConnectRequest(GameConnection client, string netAddress, string name)
 {
     console.print(string.Format("Connect request from:{0}", netAddress));
     return iGlobal["$Server::PlayerCount"] >= iGlobal["$Pref::Server::MaxPlayers"] ? "CR_SERVERFULL" : "";
 }
Exemplo n.º 14
0
 public static void serverCmdMissionStartPhase2Ack(GameConnection client, string seq, PlayerData playerDB)
 {
     _missionLoadBase.serverCmdMissionStartPhase2Ack(client, seq, playerDB);
 }
Exemplo n.º 15
0
        public virtual void serverCmdMissionStartPhase2Ack(GameConnection client, string seq, PlayerData playerDB)
        {
            // Make sure to ignore calls from a previous mission load
            if (seq != sGlobal["$missionSequence"] || !bGlobal["$MissionRunning"])
                return;
            if (client["currentPhase"].AsDouble() != 1.5)
                return;

            client["currentPhase"] = "2";
            // Set the player datablock choice

            client["playerDB"] = playerDB;

            // Update mod paths, this needs to get there before the objects.
            client.transmitPaths();

            // Start ghosting objects to the client
            client.activateGhosting();
        }
Exemplo n.º 16
0
 public void clientWantsGhostAlwaysRetry(GameConnection client)
 {
     if (bGlobal["$MissionRunning"])
         client.activateGhosting();
 }
Exemplo n.º 17
0
        public static void serverCmdflipCar(GameConnection client)
        {
            Player player = client["player"];

            Vehicle car = player.getControlObject();
            if (car.getClassName() != "WheeledVehicle")
                return;
            TransformF carpos = car.getTransform();
            carpos += new TransformF(0, 0, 3);
            car.setTransform(carpos);
        }
Exemplo n.º 18
0
        public virtual void serverCmdMissionStartPhase1Ack(GameConnection client, int seq)
        {
            // Make sure to ignore calls from a previous mission load
            if (seq != iGlobal["$missionSequence"] || !bGlobal["$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"]);
        }
Exemplo n.º 19
0
 public static void serverCmdUse(GameConnection client, ItemData data)
 {
     if (((Player) client.getControlObject()).isObject())
         ((Player) client.getControlObject()).Use(data);
 }
Exemplo n.º 20
0
 public static void serverCmdMissionStartPhase2CacheAck(GameConnection client)
 {
     _missionLoadBase.serverCmdMissionStartPhase2CacheAck(client);
 }
Exemplo n.º 21
0
        public static void sendMsgClientKilled_Suicide(string msgtype, GameConnection client, GameConnection sourceclient, string damloc)
        {
            if (client.isObject())

                message.MessageAll(msgtype, "%1 takes his own life!", client["playerName"]);
        }
Exemplo n.º 22
0
 public virtual int GetKills(GameConnection client)
 {
     return client["kills"].AsInt();
 }
Exemplo n.º 23
0
 public static void sendMsgClientKilled_Telefrag(string msgType, GameConnection client, GameConnection sourceClient, string damLoc)
 {
     message.MessageAll(msgType, "%1 was telefragged by %2!", client["playerName"], sourceClient["playerName"]);
 }
Exemplo n.º 24
0
 public virtual int GetDeaths(GameConnection client)
 {
     return client["deaths"].AsInt();
 }
Exemplo n.º 25
0
        public static void ServerCmdtoggleBrakeLights(GameConnection client)
        {
            Player player = client["player"];
            //Remember to pay attention to what type of object your looking at.
            WheeledVehicle vehicle = player.getControlObject().AsString();
            if (vehicle.getClassName() != "WheeledVehicle")
                return;

            if (vehicle["rightBrakeLight.isEnabled"].AsBool())
                {
                ((PointLight) vehicle["rightBrakeLight"]).setLightEnabled(false);
                ((PointLight) vehicle["leftBrakeLight"]).setLightEnabled(false);
                }
            else
                {
                ((PointLight) vehicle["rightBrakeLight"]).setLightEnabled(true);
                ((PointLight) vehicle["leftBrakeLight"]).setLightEnabled(true);
                }
        }
Exemplo n.º 26
0
        public virtual void onDeath(GameBase sourceobject, GameConnection sourceclient, string damagetype, string damloc)
        {
            if (this.isObject())
                {
                if (this["ownedTurrets"] == string.Empty)
                    this["ownedTurrets"] = new ObjectCreator("SimSet").Create().AsString();

                SimSet simSet = this["ownedTurrets"];

                for (uint i = 0; i < simSet.getCount(); i++)
                    ((SimObject) simSet.getObject(i)).schedule("10", "delete");
                }

            // clear the weaponHUD
            this.refreshWeaponHud(0, string.Empty, string.Empty, string.Empty, 0);

            Player player = this["player"];

            // Clear out the name on the corpse
            player.setShapeName(string.Empty);

            // Update the numerical Health HUD

            //PlayerUpdateHealth(player);

            // Switch the client over to the death cam and unhook the player object.
            Camera camera = this["camera"];

            if (camera.isObject() && player.isObject())
                {
                camera.setMode("Corpse", player, string.Empty, string.Empty);
                //camera.call("setMode", "Corpse", player, string.Empty, string.Empty);
                this.setControlObject(camera);
                }
            else
                console.print("------------>Failed to Switch the client over to the death cam.");

            this["player"] = "0";

            // Display damage appropriate kill message
            string sendMsgFunction = "sendMsgClientKilled_" + damagetype;
            //if (!console.isFunction(sendMsgFunction))
            //    {
            //    sendMsgFunction = "sendMsgClientKilled_Default";
            //    }

            console.Call(sendMsgFunction, new string[] {"MsgClientKilled", this, sourceclient, damloc});
            // Dole out points and check for win
            if ((damagetype == "Suicide") || (sourceclient == this))
                {
                IncDeaths(this, "1", "1");
                IncScore(this, "-1", "0");
                }
            else
                {
                IncDeaths(this, "1", "0");
                IncScore(sourceclient, "1", "1");
                IncKills(sourceclient, "1", "0");
                }

            if (iGlobal["$Game::EndGameScore"] > 0 && sourceclient["kills"].AsInt() >= iGlobal["$Game::EndGameScore"])
                missionLoad.cycleGame();
        }
Exemplo n.º 27
0
        public void checkWinner(GameConnection client)
        {
            for (int i = 0; i < 4; i++)
                {
                if (!client["touchedPlatform[" + i + "]"].AsBool())
                    return; // Skipped a platform, no winner message for you!
                }
            // Get the total time it took them
            double totalTime = Util.getSimTime() - client["miniStartTime"].AsDouble();
            string timeStr = timeToText(totalTime);

            // See if they beat the best time
            if (sGlobal["$Pref::Server::miniWalkableBest"] == "")
                dGlobal["$Pref::Server::miniWalkableBest"] = totalTime;
            else if (totalTime < dGlobal["$Pref::Server::miniWalkableBest"])
                {
                dGlobal["$Pref::Server::miniWalkableBest"] = totalTime;
                timeStr += "\nA new best time!";
                }

            message.MessageClient(client, "MsgItemPickup", "\\c1Congratulations! You reached the platform in %1", timeStr);
            message.MessageAllExcept(client, "-1", "MsgItemPickup", "\\c1%1 reached the platform in %2", client["PlayerName"], timeStr);

            // Reset so they can play again
            client["miniStartTime"] = "";
        }
Exemplo n.º 28
0
 public static void serverCmdsetPlayerControl(GameConnection client)
 {
     Player player = client["player"];
     client.setControlObject(player);
 }
Exemplo n.º 29
0
 public static void serverCmdMissionStartPhase3Ack(GameConnection client, string seq)
 {
     _missionLoadBase.serverCmdMissionStartPhase3Ack(client, seq);
 }
Exemplo n.º 30
0
 public virtual void serverCmdMissionStartPhase2CacheAck(GameConnection client)
 {
     client["currentPhase"] = "1.5";
 }
Exemplo n.º 31
0
        public static void serverCmddismountVehicle(GameConnection client)
        {
            Player player = client["player"];
            Vehicle car = player.getControlObject();
            Player passenger = car.getMountNodeObject(0);

            ((PlayerData) passenger.getDataBlock()).doDismount(passenger);
            client.setControlObject(player);
        }
Exemplo n.º 32
0
        public virtual void serverCmdMissionStartPhase3Ack(GameConnection client, string seq)
        {
            if (seq != sGlobal["$missionSequence"] || !bGlobal["$MissionRunning"])
                return;
            if (client["currentPhase"].AsDouble() != 2.0)
                return;

            client["currentPhase"] = "3";
            // Server is ready to drop into the game

            if (iGlobal["$Pref::Server::MinPlayers"] > 1)

                console.Call("PlayerReady", new string[] {client});
            else
                {
                client.startMission();
                client.onClientEnterGame();
                }
        }
Exemplo n.º 33
0
        public override void onCollision(ShapeBase obj, SceneObject col, Point3F vec, float len)
        {
            Player player = obj.getId();

            if (player.getState() == "Dead")
            {
                return;
            }
            // Try and pickup all items
            if (col.getClassName() == "Item")
            {
                player.pickup(col.ID, 1);
                return;
            }

            if (col.GetType() != typeof(WheeledVehicle))
            {
                return;
            }

            WheeledVehicle vcol = (WheeledVehicle)col;

            //AI are not allowed to drive they are lousey drivers....
            GameConnection client = player["client"];

            if (!client.isObject())
            {
                return;
            }
            //Mount Vehicle.
            if ((console.getTypeMask(col) & (UInt32)SceneObjectTypesAsUint.GameBaseObjectType) != (UInt32)SceneObjectTypesAsUint.GameBaseObjectType)
            {
                return;
            }
            VehicleData db = vcol.getDataBlock();

            if (!(((db.getClassName() == "WheeledVehicleData") || player["mountVehicle"].AsBool() || player.getState() == "Move" || col["mountable"].AsBool())))
            {
                return;
            }
            // Only mount drivers for now.

            // For this specific example, only one person can fit
            // into a vehicle
            int mount = vcol.getMountNodeObject(0);

            if (mount > 0)
            {
                try
                {
                    Player p = mount;
                    return;
                }
                catch (Exception err)
                {
                    //Water particle emitters seem to take up the seat when the vehicle is in water.
                    vcol.unmountObject(mount.AsString());
                    vcol.mountObject(player, 0, new TransformF());
                    ((GameConnection)player["client"]).setFirstPerson(false);
                    console.commandToClient(client, "PushVehicleMap");
                }
            }
            else
            {
                vcol.mountObject(player, 0, new TransformF());
                ((GameConnection)player["client"]).setFirstPerson(false);
                console.commandToClient(client, "PushVehicleMap");
            }
            //if (mount > 0)
            //return;
            // For this specific FPS Example, always mount the player to node 0

            player["mVehicle"] = col;
        }