Beispiel #1
0
 private static void CommandCost(ClientInfo _cInfo)
 {
     try
     {
         if (Wallet.IsEnabled && Command_Cost > 0)
         {
             if (Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString) >= Command_Cost)
             {
                 ZCheck(_cInfo);
             }
             else
             {
                 Phrases.Dict.TryGetValue("Gimme3", out string phrase);
                 phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name);
                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
             }
         }
         else
         {
             ZCheck(_cInfo);
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Gimme.CommandCost: {0}", e.Message));
     }
 }
 private static void CommandCost(ClientInfo _cInfo, string _waypoint, Vector3 _position, bool _friends, int _cost)
 {
     try
     {
         if (Wallet.IsEnabled && _cost >= 1)
         {
             if (Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString) >= _cost)
             {
                 Exec(_cInfo, _waypoint, _position, _friends, _cost);
             }
             else
             {
                 Phrases.Dict.TryGetValue("Waypoints14", out string phrase);
                 phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name);
                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
             }
         }
         else
         {
             Exec(_cInfo, _waypoint, _position, _friends, 0);
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Waypoints.CommandCost: {0}", e.Message));
     }
 }
Beispiel #3
0
 public static void Walletcheck(ClientInfo _cInfo, int _item, int _count)
 {
     try
     {
         for (int i = 0; i < Dict.Count; i++)
         {
             string[] _itemData = Dict[i];
             if (int.Parse(_itemData[0]) == _item)
             {
                 int _currentCoins = Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString);
                 int _cost         = int.Parse(_itemData[5]) * _count;
                 if (_currentCoins >= _cost)
                 {
                     _count = int.Parse(_itemData[3]) * _count;
                     ShopPurchase(_cInfo, _itemData[1], _itemData[2], _count, int.Parse(_itemData[4]), _cost);
                 }
                 else
                 {
                     Phrases.Dict.TryGetValue("Shop5", out string _phrase);
                     _phrase = _phrase.Replace("{CoinName}", Wallet.Currency_Name);
                     _phrase = _phrase.Replace("{Value}", _currentCoins.ToString());
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 }
                 return;
             }
         }
         Phrases.Dict.TryGetValue("Shop15", out string _phrase1);
         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase1 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Shop.Walletcheck: {0}", e.Message));
     }
 }
Beispiel #4
0
 public static void WalletCheck(ClientInfo _cInfo, int _purchase)
 {
     if (AuctionItems.ContainsKey(_purchase))
     {
         if (PersistentContainer.Instance.AuctionPrices != null)
         {
             Dictionary <int, int> auctionPrices = PersistentContainer.Instance.AuctionPrices;
             int price = 0;
             if (auctionPrices.ContainsKey(_purchase))
             {
                 auctionPrices.TryGetValue(_purchase, out price);
             }
             int currentCoins = Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString);
             if (currentCoins >= price)
             {
                 BuyAuction(_cInfo, _purchase, price);
             }
             else
             {
                 int missing = price - currentCoins;
                 Phrases.Dict.TryGetValue("Auction7", out string phrase);
                 phrase = phrase.Replace("{Value}", missing.ToString());
                 phrase = phrase.Replace("{Name}", Wallet.Currency_Name);
                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
             }
         }
     }
     else
     {
         Phrases.Dict.TryGetValue("Auction8", out string phrase);
         phrase = phrase.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1);
         phrase = phrase.Replace("{Command_auction}", Command_auction);
         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
     }
 }
Beispiel #5
0
 public static void BuyLife(ClientInfo _cInfo)
 {
     try
     {
         EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId);
         if (player != null)
         {
             if (Max_Extra_Lives > 0)
             {
                 if (PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].HardcoreEnabled)
                 {
                     string[] stats = PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].HardcoreStats;
                     int.TryParse(stats[2], out int extraLives);
                     if (extraLives < Max_Extra_Lives)
                     {
                         if (Life_Price < 0)
                         {
                             Life_Price = 0;
                         }
                         int cost = Life_Price * extraLives++;
                         if (Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString) >= cost)
                         {
                             Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, cost);
                             stats[2] = (extraLives + 1).ToString();
                             PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].HardcoreStats = stats;
                             PersistentContainer.DataChange = true;
                             Phrases.Dict.TryGetValue("Hardcore7", out string phrase);
                             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                         }
                         else
                         {
                             Phrases.Dict.TryGetValue("Hardcore8", out string phrase);
                             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                         }
                     }
                     else
                     {
                         Phrases.Dict.TryGetValue("Hardcore9", out string phrase);
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
                 else
                 {
                     Phrases.Dict.TryGetValue("Hardcore10", out string _phrase);
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
             else
             {
                 Phrases.Dict.TryGetValue("Hardcore9", out string _phrase);
                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Hardcore.BuyLife: {0}", e.Message));
     }
 }
Beispiel #6
0
 public static void NewLotto(ClientInfo _cInfo, string _message)
 {
     if (!ShuttingDown)
     {
         if (OpenLotto)
         {
             int winnings = LottoValue * LottoEntries.Count;
             Phrases.Dict.TryGetValue("Lottery2", out string phrase);
             phrase = phrase.Replace("{Value1}", winnings.ToString());
             phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name);
             phrase = phrase.Replace("{Value2}", LottoValue.ToString());
             phrase = phrase.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1);
             phrase = phrase.Replace("{Command_lottery_enter}", Command_lottery_enter);
             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
         }
         else
         {
             if (int.TryParse(_message, out int _lottoValue))
             {
                 if (_lottoValue > 0)
                 {
                     if (Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString) >= _lottoValue)
                     {
                         OpenLotto  = true;
                         LottoValue = _lottoValue;
                         LottoEntries.Add(_cInfo);
                         Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, LottoValue);
                         Phrases.Dict.TryGetValue("Lottery4", out string phrase);
                         phrase = phrase.Replace("{Value}", _lottoValue.ToString());
                         phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name);
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                         Phrases.Dict.TryGetValue("Lottery5", out phrase);
                         phrase = phrase.Replace("{Value}", LottoValue.ToString());
                         phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name);
                         phrase = phrase.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1);
                         phrase = phrase.Replace("{Command_lottery_enter}", Command_lottery_enter);
                         ChatHook.ChatMessage(null, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null);
                     }
                     else
                     {
                         Phrases.Dict.TryGetValue("Lottery6", out string phrase);
                         phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name);
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
                 else
                 {
                     Phrases.Dict.TryGetValue("Lottery3", out string phrase);
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
             else
             {
                 Phrases.Dict.TryGetValue("Lottery3", out string phrase);
                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
             }
         }
     }
 }
Beispiel #7
0
 public static void CommandCost(ClientInfo _cInfo)
 {
     if (Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString) >= Command_Cost)
     {
         TeleportPlayer(_cInfo);
     }
     else
     {
         Phrases.Dict.TryGetValue("Died3", out string phrase);
         phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name);
         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
     }
 }
 private static void CommandCost(ClientInfo _cInfo)
 {
     if (Wallet.IsEnabled && Command_Cost > 0)
     {
         if (Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString) >= Command_Cost)
         {
             StartScouting(_cInfo);
         }
         else
         {
             Phrases.Dict.TryGetValue("ScoutPlayer2", out string phrase);
             phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name);
             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
         }
     }
     else
     {
         StartScouting(_cInfo);
     }
 }
Beispiel #9
0
 public static void CommandCost(ClientInfo _cInfo)
 {
     try
     {
         int currentCoins = Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString);
         if (currentCoins >= Command_Cost)
         {
             GiveAnimals(_cInfo);
         }
         else
         {
             Phrases.Dict.TryGetValue("AnimalTracking2", out string phrase);
             phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name);
             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Animals.CommandCost: {0}", e.Message));
     }
 }
Beispiel #10
0
 public static void EnterLotto(ClientInfo _cInfo)
 {
     if (OpenLotto)
     {
         if (Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString) >= LottoValue)
         {
             if (!LottoEntries.Contains(_cInfo))
             {
                 LottoEntries.Add(_cInfo);
                 Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, LottoValue);
                 Phrases.Dict.TryGetValue("Lottery7", out string phrase);
                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 if (LottoEntries.Count == 8)
                 {
                     StartLotto();
                 }
             }
             else
             {
                 Phrases.Dict.TryGetValue("Lottery8", out string phrase);
                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
             }
         }
         else
         {
             Phrases.Dict.TryGetValue("Lottery6", out string phrase);
             phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name);
             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
         }
     }
     else
     {
         Phrases.Dict.TryGetValue("Lottery1", out string phrase);
         phrase = phrase.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1);
         phrase = phrase.Replace("{Command_lottery}", Command_lottery);
         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
     }
 }
        public static void TeleFriend(ClientInfo _cInfo, int _invitingFriend)
        {
            ClientInfo cInfo2 = PersistentOperations.GetClientInfoFromEntityId(_invitingFriend);

            if (cInfo2 != null)
            {
                EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId);
                if (player != null)
                {
                    if (Wallet.IsEnabled && Command_Cost >= 1)
                    {
                        if (Wallet.GetCurrency(cInfo2.CrossplatformId.CombinedString) >= Command_Cost)
                        {
                            Wallet.RemoveCurrency(cInfo2.CrossplatformId.CombinedString, Command_Cost);
                        }
                        else
                        {
                            Phrases.Dict.TryGetValue("FriendTeleport10", out string phrase);
                            phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name);
                            ChatHook.ChatMessage(cInfo2, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                            return;
                        }
                    }
                    Phrases.Dict.TryGetValue("FriendTeleport7", out string phrase1);
                    ChatHook.ChatMessage(cInfo2, Config.Chat_Response_Color + phrase1 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                    cInfo2.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3((int)player.position.x, (int)player.position.y, (int)player.position.z), null, false));
                    PersistentContainer.Instance.Players[cInfo2.CrossplatformId.CombinedString].LastFriendTele = DateTime.Now;
                    PersistentContainer.DataChange = true;
                }
            }
            else
            {
                Phrases.Dict.TryGetValue("FriendTeleport11", out string _phrase);
                ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
            }
        }
Beispiel #12
0
 public static void BagToBank(ClientInfo _cInfo, string _amount)
 {
     try
     {
         EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId);
         if (player != null)
         {
             if (int.TryParse(_amount, out int value))
             {
                 if (Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString) >= value)
                 {
                     Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, value);
                     if (Deposit_Fee_Percent > 0)
                     {
                         float fee             = value * ((float)Deposit_Fee_Percent / 100);
                         int   adjustedDeposit = value - (int)fee;
                         AddCoinsToBank(_cInfo.CrossplatformId.CombinedString, adjustedDeposit);
                         using (StreamWriter sw = new StreamWriter(Filepath, true, Encoding.UTF8))
                         {
                             sw.WriteLine(string.Format("{0}: '{1}' '{2}' added '{3}' to their bank", DateTime.Now, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName, adjustedDeposit));
                             sw.WriteLine();
                             sw.Flush();
                             sw.Close();
                         }
                         Phrases.Dict.TryGetValue("Bank3", out string phrase);
                         phrase = phrase.Replace("{Value}", adjustedDeposit.ToString());
                         phrase = phrase.Replace("{Name}", Wallet.Currency_Name);
                         phrase = phrase.Replace("{Percent}", Deposit_Fee_Percent.ToString());
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     }
                     else
                     {
                         AddCoinsToBank(_cInfo.CrossplatformId.CombinedString, value);
                         using (StreamWriter sw = new StreamWriter(Filepath, true, Encoding.UTF8))
                         {
                             sw.WriteLine(string.Format("{0}: '{1}' '{2}' added '{3}' to their bank", DateTime.Now, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName, value));
                             sw.WriteLine();
                             sw.Flush();
                             sw.Close();
                         }
                         Phrases.Dict.TryGetValue("Bank4", out string phrase);
                         phrase = phrase.Replace("{Value}", value.ToString());
                         phrase = phrase.Replace("{Name}", Wallet.Currency_Name);
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
                 else
                 {
                     Phrases.Dict.TryGetValue("Bank5", out string phrase);
                     phrase = phrase.Replace("{Name}", Wallet.Currency_Name);
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
             else
             {
                 Phrases.Dict.TryGetValue("Bank6", out string _phrase);
                 _phrase = _phrase.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1);
                 _phrase = _phrase.Replace("{Command_deposit}", Command_deposit);
                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Bank.ChestToBankDeposit: {0}", e.Message));
     }
 }
        public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
        {
            try
            {
                if (_params.Count < 1 || _params.Count > 2)
                {
                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 1 or 2, found '{0}'", _params.Count));

                    return;
                }
                if (_params[0].ToLower().Equals("off"))
                {
                    if (Wallet.IsEnabled)
                    {
                        Wallet.IsEnabled = false;
                        Config.WriteXml();
                        Config.LoadXml();
                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wallet has been set to off"));

                        return;
                    }
                    else
                    {
                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wallet is already off"));

                        return;
                    }
                }
                else if (_params[0].ToLower().Equals("on"))
                {
                    if (!Wallet.IsEnabled)
                    {
                        Wallet.IsEnabled = true;
                        Config.WriteXml();
                        Config.LoadXml();
                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wallet has been set to on"));

                        return;
                    }
                    else
                    {
                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wallet is already on"));

                        return;
                    }
                }
                else if (_params[0].ToLower().Equals("all"))
                {
                    bool negative = false;
                    if (_params[1].Contains("-"))
                    {
                        _params[1].Replace("-", "");
                        negative = true;
                    }
                    if (!int.TryParse(_params[1], out int adjustCoins))
                    {
                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Can not adjust wallet. Value '{0}' is invalid", _params[1]));
                    }
                    else
                    {
                        List <ClientInfo> clientList = PersistentOperations.ClientList();
                        if (clientList != null)
                        {
                            for (int i = 0; i < clientList.Count; i++)
                            {
                                ClientInfo cInfo = clientList[i];
                                if (cInfo != null)
                                {
                                    if (negative)
                                    {
                                        if (Wallet.GetCurrency(cInfo.CrossplatformId.CombinedString) >= adjustCoins)
                                        {
                                            Wallet.RemoveCurrency(cInfo.CrossplatformId.CombinedString, adjustCoins);
                                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Removed '{0}' '{1}' from Id '{2}' named '{3}'", _params[1], Wallet.Currency_Name, cInfo.CrossplatformId.CombinedString, cInfo.playerName));
                                        }
                                        else
                                        {
                                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Unable to remove '{0}' '{1}'. Target '{2}' named '{3}' does not have enough", _params[1], Wallet.Currency_Name, cInfo.CrossplatformId.CombinedString, cInfo.playerName));
                                        }
                                        return;
                                    }
                                    else
                                    {
                                        Wallet.AddCurrency(cInfo.CrossplatformId.CombinedString, adjustCoins);
                                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Added '{0}' '{1}' to id '{2}' named '{3}'", _params[1], Wallet.Currency_Name, cInfo.CrossplatformId.CombinedString, cInfo.playerName));

                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
                else if (_params.Count == 2)
                {
                    if (_params[1].Length < 1 || _params[1].Length > 6)
                    {
                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Can not adjust wallet. Value '{0}' is invalid", _params[1]));

                        return;
                    }
                    bool negative = false;
                    if (_params[1].Contains("-"))
                    {
                        _params[1].Replace("-", "");
                        negative = true;
                    }
                    if (!int.TryParse(_params[1], out int adjustCoins))
                    {
                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Can not adjust wallet. Value '{0}' is invalid", _params[1]));

                        return;
                    }
                    if (_params[0].Contains("_"))
                    {
                        PersistentPlayer p = PersistentContainer.Instance.Players[_params[0]];
                        if (p != null)
                        {
                            if (negative)
                            {
                                Wallet.RemoveCurrency(_params[0], adjustCoins);
                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Removed '{0}' '{1}' from Id '{2}'", _params[1], Wallet.Currency_Name, _params[0]));
                            }
                            else
                            {
                                Wallet.AddCurrency(_params[0], adjustCoins);
                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Added '{0}' '{1}' to wallet '{2}'", _params[1], Wallet.Currency_Name, _params[0]));
                            }
                        }
                        else
                        {
                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Id not found '{0}'", _params[0]));
                        }
                    }
                    else
                    {
                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Invalid Id '{0}'", _params[0]));
                    }
                }
                else if (_params.Count == 1)
                {
                    if (_params[0].Contains("_"))
                    {
                        ClientInfo cInfo = PersistentOperations.GetClientInfoFromNameOrId(_params[0]);
                        if (cInfo != null)
                        {
                            int currentWallet = Wallet.GetCurrency(cInfo.CrossplatformId.CombinedString);
                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Id '{0}' named '{1}' has '{2}' '{3}'", _params[0], cInfo.playerName, currentWallet, Wallet.Currency_Name));
                        }
                    }
                }
                else
                {
                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Invalid argument '{0}'", _params[0]));
                }
            }
            catch (Exception e)
            {
                Log.Out(string.Format("[SERVERTOOLS] Error in WalletConsole.Execute: {0}", e.Message));
            }
        }
Beispiel #14
0
 public static void Bet(ClientInfo _cInfo)
 {
     try
     {
         if (Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString) < Command_Cost)
         {
             Phrases.Dict.TryGetValue("Gamble3", out string phrase);
             phrase = phrase.Replace("{Value}", Command_Cost.ToString());
             phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name);
             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
             return;
         }
         else
         {
             DateTime lastgamble = new DateTime();
             if (PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastGamble != null)
             {
                 lastgamble = PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastGamble;
             }
             TimeSpan varTime           = DateTime.Now - lastgamble;
             double   fractionalMinutes = varTime.TotalMinutes;
             int      timepassed        = (int)fractionalMinutes;
             int      delay             = Delay_Between_Uses;
             if (ReservedSlots.IsEnabled && ReservedSlots.Reduced_Delay && ReservedSlots.Dict.ContainsKey(_cInfo.PlatformId.CombinedString) || ReservedSlots.Dict.ContainsKey(_cInfo.CrossplatformId.CombinedString))
             {
                 if (ReservedSlots.Dict.TryGetValue(_cInfo.PlatformId.ReadablePlatformUserIdentifier, out DateTime dt))
                 {
                     if (DateTime.Now < dt)
                     {
                         delay = Delay_Between_Uses / 2;
                     }
                 }
                 else if (ReservedSlots.Dict.TryGetValue(_cInfo.CrossplatformId.ReadablePlatformUserIdentifier, out dt))
                 {
                     if (DateTime.Now < dt)
                     {
                         delay = Delay_Between_Uses / 2;
                     }
                 }
             }
             if (timepassed >= delay)
             {
                 int[] pot;
                 if (Dict.ContainsKey(_cInfo.CrossplatformId.CombinedString))
                 {
                     Dict.TryGetValue(_cInfo.CrossplatformId.CombinedString, out pot);
                 }
                 else
                 {
                     pot = new int[] { 1, 0 };
                 }
                 Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, Command_Cost);
                 int gamble = Random.Next(pot[0] + 1);
                 if (gamble == 1)
                 {
                     int winnings = Command_Cost * 2;
                     if (pot[1] > 0)
                     {
                         winnings = pot[1] * 2;
                     }
                     if (!Dict.ContainsKey(_cInfo.CrossplatformId.CombinedString))
                     {
                         Dict.Add(_cInfo.CrossplatformId.CombinedString, new int[] { pot[0] + 1, winnings });
                     }
                     else
                     {
                         Dict[_cInfo.CrossplatformId.CombinedString] = new int[] { pot[0] + 1, winnings };
                     }
                     Phrases.Dict.TryGetValue("Gamble5", out string phrase);
                     phrase = phrase.Replace("{Number}", pot[0].ToString());
                     phrase = phrase.Replace("{Value}", winnings.ToString());
                     phrase = phrase.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1);
                     phrase = phrase.Replace("{Command_gamble_payout}", Command_gamble_payout);
                     phrase = phrase.Replace("{Command_gamble_bet}", Command_gamble_bet);
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 }
                 else
                 {
                     if (Dict.ContainsKey(_cInfo.CrossplatformId.CombinedString))
                     {
                         Dict.Remove(_cInfo.CrossplatformId.CombinedString);
                     }
                     PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastGamble = DateTime.Now;
                     PersistentContainer.DataChange = true;
                     Phrases.Dict.TryGetValue("Gamble6", out string phrase);
                     phrase = phrase.Replace("{Number}", pot[0].ToString());
                     phrase = phrase.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1);
                     phrase = phrase.Replace("{Command_gamble_bet}", Command_gamble_bet);
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
             else
             {
                 int remaining = delay - timepassed;
                 Phrases.Dict.TryGetValue("Gamble7", out string phrase);
                 phrase = phrase.Replace("{DelayBetweenUses}", delay.ToString());
                 phrase = phrase.Replace("{TimeRemaining}", remaining.ToString());
                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Gamble.Bet: {0}", e.Message));
     }
 }
Beispiel #15
0
 public static void NewBounty(ClientInfo _cInfo, string _message)
 {
     try
     {
         if (_message.Contains(" "))
         {
             string[] idAndBounty = _message.Split(' ').ToArray();
             if (int.TryParse(idAndBounty[0], out int id))
             {
                 if (int.TryParse(idAndBounty[1], out int bounty))
                 {
                     ClientInfo cInfo2 = ConnectionManager.Instance.Clients.ForEntityId(id);
                     if (cInfo2 != null)
                     {
                         if (bounty < Minimum_Bounty)
                         {
                             bounty = Minimum_Bounty;
                         }
                         int currentCoins = Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString);
                         if (currentCoins >= bounty)
                         {
                             Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, bounty);
                             int _currentbounty = PersistentContainer.Instance.Players[cInfo2.CrossplatformId.CombinedString].Bounty;
                             PersistentContainer.Instance.Players[cInfo2.CrossplatformId.CombinedString].Bounty = _currentbounty + bounty;
                             PersistentContainer.DataChange = true;
                             using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8))
                             {
                                 sw.WriteLine(string.Format("{0}: '{1}' named '{2}' added '{3}' bounty to '{4}' '{5}' named '{6}'", DateTime.Now, _cInfo.PlatformId.CombinedString, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName, bounty, cInfo2.PlatformId.CombinedString, cInfo2.CrossplatformId.CombinedString, cInfo2.playerName));
                                 sw.WriteLine();
                                 sw.Flush();
                                 sw.Close();
                             }
                             Phrases.Dict.TryGetValue("Bounties5", out string phrase);
                             phrase = phrase.Replace("{Value}", bounty.ToString());
                             phrase = phrase.Replace("{PlayerName}", cInfo2.playerName);
                             ChatHook.ChatMessage(null, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null);
                         }
                         else
                         {
                             Phrases.Dict.TryGetValue("Bounties4", out string phrase);
                             phrase = phrase.Replace("{Value}", bounty.ToString());
                             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                         }
                     }
                 }
                 else
                 {
                     Phrases.Dict.TryGetValue("Bounties6", out string phrase);
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
         }
         else
         {
             if (int.TryParse(_message, out int _id))
             {
                 ClientInfo cInfo2 = ConnectionManager.Instance.Clients.ForEntityId(_id);
                 if (cInfo2 != null)
                 {
                     int currentCoins = Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString);
                     if (currentCoins >= Minimum_Bounty)
                     {
                         Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, Minimum_Bounty);
                         int _currentbounty = PersistentContainer.Instance.Players[cInfo2.CrossplatformId.CombinedString].Bounty;
                         PersistentContainer.Instance.Players[cInfo2.CrossplatformId.CombinedString].Bounty = _currentbounty + Minimum_Bounty;
                         PersistentContainer.DataChange = true;
                         using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8))
                         {
                             sw.WriteLine(string.Format("{0}: '{1}' '{2}' named '{3}' added '{4}' bounty to '{5}' '{6}' named '{7}'", DateTime.Now, _cInfo.PlatformId.CombinedString, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName, Minimum_Bounty, cInfo2.PlatformId.CombinedString, cInfo2.CrossplatformId.CombinedString, cInfo2.playerName));
                             sw.WriteLine();
                             sw.Flush();
                             sw.Close();
                         }
                         Phrases.Dict.TryGetValue("Bounties5", out string phrase);
                         phrase = phrase.Replace("{Value}", Minimum_Bounty.ToString());
                         phrase = phrase.Replace("{PlayerName}", cInfo2.playerName);
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     }
                     else
                     {
                         Phrases.Dict.TryGetValue("Bounties4", out string phrase);
                         phrase = phrase.Replace("{Value}", Minimum_Bounty.ToString());
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Bounties.NewBounty: {0}", e.Message));
     }
 }