Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public void ObserverObserverOnTrigger(coCameraData cameradata, coCamera camera, string trigger, bool state)
        {
            // state = 0 means that a trigger key was released
            if (state == false)
            {
                return;
            }

            // Default player triggers: 0=fire 1=altFire 2=jump
            coGameConnection client = camera.getControllingClient();
            string           mode   = camera["mode"];

            switch (mode)
            {
            case "Observer":
                // Do something interesting.
                break;

            case "Corpse":
                //Here is a winner... if you send the prepare too soon, it will crash out the client.  The GameConnectionOnControlObjectChange needs
                //time to run, and since it's still processing the first change (Switch to camera) this second change (Camera->player) will crash
                //out the client.
                //ServerCmdSetEditorCameraStandard(client);
                //ServerCmdDropCameraAtPlayer(client);
                camera.setFlyMode();
                client.setControlObject(camera);
                GameConnectiOnPreparePlayer(client);
                break;
            }
        }
Exemplo n.º 3
0
 public void GameConnectSpamMessageTimeOut(coGameConnection thisobj)
 {
     if (thisobj["spamMessageCount"].AsInt() > 0)
     {
         thisobj["spamMessageCount"] = (thisobj["spamMessageCount"].AsInt() - 1).AsString();
     }
 }
Exemplo n.º 4
0
 public void ServerCmdNetSimulateLag(coGameConnection client, int msDelay, float packetLossPercent)
 {
     if (client["isAdmin"].AsBool())
     {
         client.setSimulatedNetParams((packetLossPercent / 100.0f), msDelay);
     }
 }
Exemplo n.º 5
0
        public void PlayerListGuiUpdate(string thisobj, coGameConnection clientId, string name, string isSuperAdmin, string isAdmin, string isAI, string score, string kills, string deaths)
        {
            // Build the row to display.  The name can have ML control tags, including
            // color and font.  Since we're not using an ML control here, we need to
            // strip them off.

            string tag = isSuperAdmin.AsBool() ? "[Super]" : (isAdmin.AsBool() ? "[Admin]" : (isAI.AsBool() ? "[Bot]" : ""));

            string text = string.Format("{0} {1}\t{2}\t{3}\t{4}", Util.StripMLControlChars(name), tag, score, kills, deaths);
            // Update or add the player to the control

            coGuiTextListCtrl PlayerListGuiList = "PlayerListGuiList";

            if (clientId == -1)
            {
                PlayerListGuiList.addRow(clientId, text, -1);
            }
            else
            {
                PlayerListGuiList.setRowById(clientId, text);
            }

            // Sorts by score

            PlayerListGuiList.sortNumerical(1, false);
            PlayerListGuiList.clearSelection();
        }
Exemplo n.º 6
0
        public void PlayerPlayDeathAnimation(coPlayer player)
        {
            int numDeathAnimations = player.getNumDeathAnimations();

            if (numDeathAnimations <= 0)
            {
                return;
            }

            coGameConnection client = player["client"];

            if (client.isObject())
            {
                int deathidx = client["deathIdx"].AsInt();
                if ((deathidx > numDeathAnimations) || (deathidx == 0))
                {
                    deathidx = 1;
                }
                player.setActionThread("Death" + deathidx, false, true);
                deathidx++;
                client["deathIdx"] = deathidx.AsString();
            }
            else
            {
                int r = new Random().Next(1, numDeathAnimations);
                player.setActionThread("Death" + r, false, true);
            }
        }
Exemplo n.º 7
0
 public void GameConnectionRefreshWeaponHud(coGameConnection client, int amount, string preview, string ret, string zoomRet, int amountInClips)
 {
     if (console.isObject(client))
     {
         console.commandToClient(client, "RefreshWeaponHud", new[] { amount.AsString(), preview, ret, zoomRet, amountInClips.AsString() });
     }
 }
Exemplo n.º 8
0
 public void SendMsgClientKilledSuicide(string msgtype, coGameConnection client, string sourceclient, string damloc)
 {
     if (console.isObject(client))
     {
         MessageAll(msgtype, "%1 takes his own life!", client["playerName"]);
     }
 }
Exemplo n.º 9
0
 public void SendMsgClientKilledImpact(string msgtype, coGameConnection client, string sourceclient, string damloc)
 {
     if (console.isObject(client))
     {
         MessageAll(msgtype, "%1 fell to his death!", client["playerName"]); // console.GetVarString(string.Format("{0}.playerName", client)));
     }
 }
Exemplo n.º 10
0
 public void ServerCmdPlayDeath(coGameConnection client, string anim)
 {
     if (client.isObject())
     {
         PlayerPlayDeathAnimation(client["player"]);
     }
 }
        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)));
        }
Exemplo n.º 12
0
 public void ServerCmdSuicide(coGameConnection client)
 {
     if (client.isObject())
     {
         PlayerKill(client["player"], "Suicide");
     }
 }
Exemplo n.º 13
0
 public void ServerCmdTestAnimation(coGameConnection client, string anim)
 {
     if (client.isObject())
     {
         ((coPlayer)client["player"]).call("playTestAnimation", anim);
     }
 }
Exemplo n.º 14
0
 public void ServerCmdSADSetPassword(coGameConnection client, string password)
 {
     if (client["isSuperAdmin"].AsBool())
     {
         sGlobal["$Pref::Server::AdminPassword"] = password;
     }
 }
Exemplo n.º 15
0
        public void SendMsgClientKilledDefault(string msgtype, coGameConnection client, coGameConnection sourceclient, string damloc)
        {
            if (console.isObject(client))
            {
                if (sourceclient == client)
                {
                    SendMsgClientKilledSuicide(msgtype, client, sourceclient, damloc);
                }

                else if (console.GetVarString(sourceclient["team"]) != "" && sourceclient["team"] != client["team"])
                {
                    MessageAll(msgtype, "%1 killed by %2 - friendly fire!", client["playerName"], sourceclient["playerName"]);
                }
                else
                {
                    if (console.isObject(sourceclient))
                    {
                        MessageAll(msgtype, "%1 gets nailed by %2!", client["playerName"], sourceclient["playerName"]);
                    }
                    else
                    {
                        MessageAll(msgtype, "%1 gets nailed by %2!", client["playerName"], "a Bot!");
                    }
                }
            }
        }
Exemplo n.º 16
0
 public void ServerCmdUse(coGameConnection client, coItem data)
 {
     if (((coPlayer)client.getControlObject()).isObject())
     {
         ((coPlayer)client.getControlObject()).call("use", data);
     }
 }
Exemplo n.º 17
0
 public void ClientWantsGhostAlwaysRetry(coGameConnection client)
 {
     if (missionRunning)
     {
         client.activateGhosting();
     }
 }
Exemplo n.º 18
0
        public void ServerCmdCycleCameraFlyType(coGameConnection client)
        {
            coCamera camera = client["camera"];

            if (camera.getMode() != Camera__CameraMotionMode.FlyMode)
            {
                return;
            }
            if (camera["newtonMode"].AsBool() == false)
            {
                camera["newtonMode"]     = true.AsString();
                camera["newtonRotation"] = false.AsString();
                camera.setVelocity(new Point3F("0 0 0"));
            }
            else if (camera["newtonRotation"].AsBool() == false)
            {
                camera["newtonMode"]     = true.AsString();
                camera["newtonRotation"] = true.AsString();
                camera.setAngularVelocity(new Point3F("0 0 0"));
            }
            else
            {
                camera["newtonMode"]     = false.AsString();
                camera["newtonRotation"] = false.AsString();
            }
            client.setControlObject(camera);
            console.Call("clientCmdSyncEditorGui");
        }
Exemplo n.º 19
0
 public void GameConnectionSetAmmoAmountHud(coGameConnection client, int amount, int amountinClips)
 {
     if (console.isObject(client))
     {
         console.commandToClient(client, "SetAmmoAmountHud", new[] { amount.AsString(), amountinClips.AsString() });
     }
 }
Exemplo n.º 20
0
        public void ArmorOnDisabled(coPlayerData datablock, coPlayer player, string state)
        {
            player.setImageTrigger(0, false);
            coItem item = (((coItemData)(player.getMountedImage(WeaponSlot)))["item"]);

            if (item.isObject())
            {
                int amount = ShapeBaseShapeBaseGetInventory(player, (item["image.ammo"]));

                if (amount.AsBool())
                {
                    ShapeBaseShapeBaseThrow(player, (item["image.clip"]), 1);
                }
            }
            ShapeBaseTossPatch(player);
            PlayerPlayDeathCry(player);
            PlayerPlayDeathAnimation(player);


            //If it's a player check.....
            coGameConnection client = player["client"];

            if (client.isObject())
            {
                console.commandToClient(client, console.addTaggedString("toggleVehicleMap"), new[] { "false" });
            }

            int ctov = iGlobal["$CorpseTimeoutValue"];

            player.schedule((ctov - 1000).AsString(), "startFade", "1000", "0", "true");
            player.schedule(ctov.AsString(), "delete");
        }
Exemplo n.º 21
0
        public void WeaponImageOnMount(coScriptObject thisobj, coPlayer player, int slot)
        {
            coGameConnection client = player["client"];

            string ammoName = "";

            ammoName = ((coItemData)thisobj["ammo"]).getName();


            int currentammo    = 0;
            int ammountinClips = 0;

            if (thisobj.isField("clip"))
            {
                if (ShapeBaseShapeBaseGetInventory(player, thisobj["ammo"]).AsBool())
                {
                    player.setImageAmmo(slot, true);
                    currentammo = ShapeBaseShapeBaseGetInventory(player, thisobj["ammo"]);
                }
                else if (ShapeBaseShapeBaseGetInventory(player, thisobj["clip"]) > 0)
                {
                    ShapeBaseShapeBaseSetInventory(player, thisobj["ammo"], thisobj["ammo.maxInventory"].AsInt());
                    player.setImageAmmo(slot, true);

                    currentammo     = thisobj["ammo.maxInventory"].AsInt();
                    ammountinClips += player["remaining" + ammoName].AsInt();
                }
                else
                {
                    ammountinClips += player["remaining" + ammoName].AsInt();
                }

                ammountinClips  = ShapeBaseShapeBaseGetInventory(player, thisobj["clip"]);
                ammountinClips *= thisobj["ammo.maxInventory"].AsInt();

                if ((player["client"] != "") && !player["isAiControlled"].AsBool())
                {
                    GameConnectionRefreshWeaponHud(client, currentammo, thisobj["item.previewImage"], thisobj["item.reticle"], thisobj["item.zoomReticle"], ammountinClips);
                }
            }
            else if (thisobj["ammo"] != "")
            {
                if (ShapeBaseShapeBaseGetInventory(player, thisobj["ammo"]).AsBool())
                {
                    player.setImageAmmo(slot, true);
                    currentammo = ShapeBaseShapeBaseGetInventory(player, thisobj["ammo"]);
                }
                else
                {
                    currentammo = 0;
                }


                if (player["client"] != "" && !player["isAiControlled"].AsBool())
                {
                    GameConnectionRefreshWeaponHud(client, 1, thisobj["item.previewImage"], thisobj["item.reticle"], thisobj["item.zoomReticle"], currentammo);
                }
            }
        }
Exemplo n.º 22
0
        public void ServerCmdSetEditorFlyCamera(coGameConnection client)
        {
            coCamera camera = client["camera"];

            camera.setFlyMode();
            client.setControlObject(camera);
            console.Call("clientCmdSyncEditorGui");
        }
Exemplo n.º 23
0
 public void ServerCmdMessageSent(coGameConnection client, string text)
 {
     if (text.Trim().Length >= iGlobal["$Pref::Server::MaxChatLen"])
     {
         text = text.Substring(0, iGlobal["$Pref::Server::MaxChatLen"]);
     }
     ChatMessageAll(client, console.ColorEncode(@"\c4%1: %2"), client["playerName"], text);
 }
Exemplo n.º 24
0
        public void ServerCmdEditorCameraAutoFit(coGameConnection client, float radius)
        {
            coCamera camera = client["camera"];

            camera.autoFitRadius(radius);
            client.setControlObject(camera);
            console.Call("clientCmdSyncEditorGui");
        }
Exemplo n.º 25
0
        public void ServerCmdTogglePathCamera(coGameConnection client, bool val)
        {
            string control = val ? client["PathCamera"] : client["camera"];

            client.setControlObject(control);

            console.Call("clientCmdSyncEditorGui");
        }
Exemplo n.º 26
0
 public void ServerCmdSetEditorCameraPlayerThird(coGameConnection client)
 {
     ((coPlayer)client["player"]).setVelocity(new Point3F("0 0 0"));
     client.setControlObject(client["player"]);
     client.setFirstPerson(false);
     bGlobal["$isFirstPersonVar"] = false;
     console.Call("clientCmdSyncEditorGui");
 }
Exemplo n.º 27
0
 public void IncDeaths(coGameConnection 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")
     //    MessageAll("MsgClientScoreChanged", "", console.GetVarString(client + ".score"),
     //               console.GetVarString(client + ".kills"), console.GetVarString(client + ".deaths"), client);
 }
Exemplo n.º 28
0
 public void IncScore(coGameConnection client, string score, string dontmessageall)
 {
     //if (!console.isObject(client)) return;
     //console.SetVar(client + ".score", console.GetVarInt(client + ".score") + int.Parse(score));
     //if (dontmessageall == "0")
     //    MessageAll("MsgClientScoreChanged", "", console.GetVarString(client + ".score"),
     //               console.GetVarString(client + "kills"), console.GetVarString(client + ".deaths"), client);
 }
Exemplo n.º 29
0
 public void toggleFirstPerson(bool val)
 {
     if (val)
     {
         coGameConnection ServerConnection = "ServerConnection";
         ServerConnection.setFirstPerson(ServerConnection.isFirstPerson());
         //((coGameConnection) "ServerConnection").setFirstPerson(!((coGameConnection) "ServerConnection").isFirstPerson());
     }
 }
Exemplo n.º 30
0
        public void GameConnectiOnPreparePlayer(coGameConnection client)
        {
            string playerSpawnPoint = PickPlayerSpawnPoint(Game__DefaultPlayerSpawnGroups);

            if (SpawnPlayer(client, playerSpawnPoint, false))
            {
                GameConnectionLoadOut(client, client["player"]);
            }
        }