Example #1
0
        public static UserEconomy Add(ulong steam_id, int players_killed = 0, int mutants_killed = 0, int animals_killed = 0, int deaths = 0)
        {
            UserEconomy result;

            if (Economy.Database.ContainsKey(steam_id))
            {
                result = null;
            }
            else
            {
                UserEconomy userEconomy = new UserEconomy(steam_id, Economy.StartBalance);
                userEconomy.PlayersKilled = players_killed;
                userEconomy.MutantsKilled = mutants_killed;
                userEconomy.AnimalsKilled = animals_killed;
                userEconomy.Deaths        = deaths;
                Economy.Database.Add(steam_id, userEconomy);
                if (Core.DatabaseType.Equals("MYSQL"))
                {
                    MySQL.Update(string.Format(Economy.SQL_INSERT_ECONOMY, new object[]
                    {
                        steam_id,
                        userEconomy.Balance,
                        userEconomy.PlayersKilled,
                        userEconomy.MutantsKilled,
                        userEconomy.AnimalsKilled,
                        userEconomy.Deaths
                    }));
                }
                result = userEconomy;
            }
            return(result);
        }
Example #2
0
 public static void Teleport_PlayerTo(object obj, NetUser Sender, NetUser Target, string command, Vector3 pos)
 {
     if (obj != null && obj is EventTimer)
     {
         (obj as EventTimer).Dispose();
     }
     if (Economy.Enabled && Core.CommandTeleportPayment > 0uL)
     {
         UserEconomy userEconomy = Economy.Get(Sender.userID);
         string      newValue    = Core.CommandTeleportPayment.ToString("N0") + Economy.CurrencySign;
         if (userEconomy.Balance < Core.CommandTeleportPayment)
         {
             Broadcast.Notice(Sender, "☢", Config.GetMessage("Command.Teleport.NoEnoughCurrency", Sender, null).Replace("%PRICE%", newValue), 5f);
             return;
         }
         userEconomy.Balance -= Core.CommandTeleportPayment;
         string newValue2 = userEconomy.Balance.ToString("N0") + Economy.CurrencySign;
         Broadcast.Message(Sender, Config.GetMessage("Economy.Balance", Sender, null).Replace("%BALANCE%", newValue2), null, 0f);
     }
     Broadcast.Notice(Sender, "☢", Config.GetMessage("Command.Teleport.TeleportOnPlayer", Sender, null).Replace("%USERNAME%", Target.displayName), 5f);
     Broadcast.Notice(Target, "☢", Config.GetMessage("Command.Teleport.TeleportedPlayer", Target, null).Replace("%USERNAME%", Sender.displayName), 5f);
     if (Core.CommandTeleportCountdown > 0)
     {
         Users.CountdownAdd(Sender.userID, new Countdown(command, (double)Core.CommandTeleportCountdown));
     }
     Helper.TeleportTo(Sender, pos);
 }
 public static void Teleport_HomeWarp(object obj, NetUser Sender, string command, Vector3 pos)
 {
     if ((obj != null) && (obj is EventTimer))
     {
         (obj as EventTimer).Dispose();
     }
     if (Economy.Enabled && (Core.CommandHomePayment > 0L))
     {
         UserEconomy economy  = Economy.Get(Sender.userID);
         string      newValue = Core.CommandHomePayment.ToString("N0") + Economy.CurrencySign;
         if (economy.Balance < Core.CommandHomePayment)
         {
             Broadcast.Notice(Sender, "☢", Config.GetMessage("Command.Home.NoEnoughCurrency", Sender, null).Replace("%PRICE%", newValue), 5f);
             return;
         }
         economy.Balance -= Core.CommandHomePayment;
         string str2 = economy.Balance.ToString("N0") + Economy.CurrencySign;
         Broadcast.Message(Sender, Config.GetMessage("Economy.Balance", Sender, null).Replace("%BALANCE%", str2), null, 0f);
     }
     if (Core.CommandHomeCountdown > 0)
     {
         Users.CountdownAdd(Sender.userID, new Countdown(command, (double)Core.CommandHomeCountdown));
     }
     Broadcast.Notice(Sender, "☢", Config.GetMessage("Command.Home.Return", Sender, null), 5f);
     Helper.TeleportTo(Sender, pos);
 }
Example #4
0
        public static UserEconomy Add(ulong steam_id, [Optional, DefaultParameterValue(0)] int players_killed, [Optional, DefaultParameterValue(0)] int mutants_killed, [Optional, DefaultParameterValue(0)] int animals_killed, [Optional, DefaultParameterValue(0)] int deaths)
        {
            if (Database.ContainsKey(steam_id))
            {
                return(null);
            }
            UserEconomy economy = new UserEconomy(steam_id, StartBalance)
            {
                PlayersKilled = players_killed,
                MutantsKilled = mutants_killed,
                AnimalsKilled = animals_killed,
                Deaths        = deaths
            };

            Database.Add(steam_id, economy);
            if (Core.DatabaseType.Equals("MYSQL"))
            {
                MySQL.Update(string.Format(SQL_INSERT_ECONOMY, new object[] { steam_id, economy.Balance, economy.PlayersKilled, economy.MutantsKilled, economy.AnimalsKilled, economy.Deaths }));
            }
            return(economy);
        }
Example #5
0
        public static void HurtKilled(DamageEvent damage)
        {
            ulong        amount      = 0L;
            string       key         = "";
            ulong        costChicken = 0L;
            string       displayName = "";
            PlayerClient client      = damage.victim.client;
            PlayerClient client2     = damage.attacker.client;
            bool         flag        = !(damage.victim.idMain is Character);
            bool         flag2       = !(damage.attacker.idMain is Character);
            UserData     data        = (client != null) ? Users.GetBySteamID(client.userID) : null;
            UserData     data2       = (client2 != null) ? Users.GetBySteamID(client2.userID) : null;

            if (data == null)
            {
            }
            ClanData data3 = (data2 != null) ? data2.Clan : null;

            if (!flag2 || (client2 != null))
            {
                if (client2 != null)
                {
                    displayName = damage.attacker.client.netUser.displayName;
                }
                else
                {
                    displayName = Helper.NiceName(damage.attacker.character.name);
                    Config.Get("NAMES." + ((data == null) ? Core.Languages[0] : data.Language), displayName, ref displayName, true);
                }
                if (flag)
                {
                    if (!(damage.victim.idMain is SleepingAvatar) || !FeeSleeper)
                    {
                        return;
                    }
                    SleepingAvatar idMain = damage.victim.idMain as SleepingAvatar;
                    if (idMain == null)
                    {
                        return;
                    }
                    UserData bySteamID = Users.GetBySteamID(idMain.ownerID);
                    if (bySteamID == null)
                    {
                        return;
                    }
                    ulong balance = GetBalance(bySteamID.SteamID);
                    key = bySteamID.Username;
                    if (FeeMurder)
                    {
                        amount = (ulong)Math.Abs((float)((balance * FeeMurderPercent) / 100f));
                    }
                    if (PayMurder)
                    {
                        costChicken = (ulong)Math.Abs((float)((balance * PayMurderPercent) / 100f));
                    }
                    if (((costChicken > 0L) && Clans.Enabled) && (data3 != null))
                    {
                        if (data3.Level.BonusMembersPayMurder > 0)
                        {
                            costChicken += (costChicken * data3.Level.BonusMembersPayMurder) / ((ulong)100L);
                        }
                        if (data3.Tax > 0)
                        {
                            ulong num4 = (costChicken * data3.Tax) / ((ulong)100L);
                            data3.Balance += num4;
                            costChicken   -= num4;
                        }
                    }
                    if (costChicken > 0L)
                    {
                        BalanceAdd(client2.userID, costChicken);
                    }
                    if (amount > 0L)
                    {
                        BalanceSub(bySteamID.SteamID, amount);
                    }
                }
                else if (client != null)
                {
                    key = damage.victim.client.netUser.displayName;
                    ulong num5 = GetBalance(client.userID);
                    if (client2 == null)
                    {
                        if (FeeDeath)
                        {
                            amount = (ulong)Math.Abs((float)((num5 * FeeDeathPercent) / 100f));
                        }
                    }
                    else if ((client2 != client) && !flag2)
                    {
                        if ((client2 != client) && !flag2)
                        {
                            UserEconomy economy1 = Get(client2.userID);
                            economy1.PlayersKilled++;
                            if (FeeMurder)
                            {
                                amount = (ulong)Math.Abs((float)((num5 * FeeMurderPercent) / 100f));
                            }
                            if (PayMurder)
                            {
                                costChicken = (ulong)Math.Abs((float)((num5 * PayMurderPercent) / 100f));
                            }
                        }
                    }
                    else if (FeeSuicide)
                    {
                        amount = (ulong)Math.Abs((float)((num5 * FeeSuicidePercent) / 100f));
                    }
                    if (((costChicken > 0L) && Clans.Enabled) && (data3 != null))
                    {
                        if (data3.Level.BonusMembersPayMurder > 0)
                        {
                            costChicken += (costChicken * data3.Level.BonusMembersPayMurder) / ((ulong)100L);
                        }
                        if (data3.Tax > 0)
                        {
                            ulong num6 = (costChicken * data3.Tax) / ((ulong)100L);
                            data3.Balance += num6;
                            costChicken   -= num6;
                        }
                    }
                    if (costChicken > 0L)
                    {
                        BalanceAdd(client2.userID, costChicken);
                    }
                    if (amount > 0L)
                    {
                        BalanceSub(client.userID, amount);
                    }
                    UserEconomy economy2 = Get(client.userID);
                    economy2.Deaths++;
                }
                else if (client2 != null)
                {
                    key = Helper.NiceName(damage.victim.character.name);
                    if (key.Equals("Chicken", StringComparison.OrdinalIgnoreCase))
                    {
                        if (CostChicken != 0L)
                        {
                            costChicken = CostChicken;
                        }
                        UserEconomy economy3 = Get(client2.userID);
                        economy3.AnimalsKilled++;
                    }
                    else if (key.Equals("Rabbit", StringComparison.OrdinalIgnoreCase))
                    {
                        if (CostRabbit != 0L)
                        {
                            costChicken = CostRabbit;
                        }
                        UserEconomy economy4 = Get(client2.userID);
                        economy4.AnimalsKilled++;
                    }
                    else if (key.Equals("Boar", StringComparison.OrdinalIgnoreCase))
                    {
                        if (CostBoar != 0L)
                        {
                            costChicken = CostBoar;
                        }
                        UserEconomy economy5 = Get(client2.userID);
                        economy5.AnimalsKilled++;
                    }
                    else if (key.Equals("Stag", StringComparison.OrdinalIgnoreCase))
                    {
                        if (CostStag != 0L)
                        {
                            costChicken = CostStag;
                        }
                        UserEconomy economy6 = Get(client2.userID);
                        economy6.AnimalsKilled++;
                    }
                    else if (key.Equals("Wolf", StringComparison.OrdinalIgnoreCase))
                    {
                        if (CostWolf != 0L)
                        {
                            costChicken = CostWolf;
                        }
                        UserEconomy economy7 = Get(client2.userID);
                        economy7.AnimalsKilled++;
                    }
                    else if (key.Equals("Bear", StringComparison.OrdinalIgnoreCase))
                    {
                        if (CostBear != 0L)
                        {
                            costChicken = CostBear;
                        }
                        UserEconomy economy8 = Get(client2.userID);
                        economy8.AnimalsKilled++;
                    }
                    else if (key.Equals("Mutant Wolf", StringComparison.OrdinalIgnoreCase))
                    {
                        if (CostMutantWolf != 0L)
                        {
                            costChicken = CostMutantWolf;
                        }
                        UserEconomy economy9 = Get(client2.userID);
                        economy9.MutantsKilled++;
                    }
                    else if (key.Equals("Mutant Bear", StringComparison.OrdinalIgnoreCase))
                    {
                        if (CostMutantBear != 0L)
                        {
                            costChicken = CostMutantBear;
                        }
                        UserEconomy economy10 = Get(client2.userID);
                        economy10.MutantsKilled++;
                    }
                    else
                    {
                        ConsoleSystem.LogWarning("[WARNING] Economy: Creature '" + key + "' not have cost of death.");
                    }
                    Config.Get("NAMES." + ((data2 == null) ? Core.Languages[0] : data2.Language), key, ref key, true);
                    if (((costChicken > 0L) && Clans.Enabled) && (data3 != null))
                    {
                        if (data3.Level.BonusMembersPayMurder > 0)
                        {
                            costChicken += (costChicken * data3.Level.BonusMembersPayMurder) / ((ulong)100L);
                        }
                        if (data3.Tax > 0)
                        {
                            ulong num7 = (costChicken * data3.Tax) / ((ulong)100L);
                            data3.Balance += num7;
                            costChicken   -= num7;
                        }
                    }
                    if (costChicken > 0L)
                    {
                        BalanceAdd(client2.userID, costChicken);
                    }
                }
                if ((client2 != null) && (costChicken > 0L))
                {
                    string text = Config.GetMessage("Economy.PlayerDeath.Pay", client2.netUser, null);
                    if (flag)
                    {
                        text = Config.GetMessage("Economy.SleeperDeath.Pay", client2.netUser, null);
                    }
                    text = text.Replace("%DEATHPAY%", costChicken.ToString("N0") + CurrencySign).Replace("%VICTIM%", key);
                    Broadcast.Message(client2.netPlayer, text, null, 0f);
                }
                if ((client != null) && (amount > 0L))
                {
                    string str4;
                    str4 = str4 = Config.GetMessage("Economy.PlayerDeath.Fee", client.netUser, null);
                    if ((client2 == client) || flag2)
                    {
                        str4 = Config.GetMessage("Economy.PlayerSuicide.Fee", client.netUser, null);
                    }
                    str4 = str4.Replace("%DEATHFEE%", amount.ToString("N0") + CurrencySign).Replace("%KILLER%", displayName).Replace("%VICTIM%", key);
                    Broadcast.Message(client.netPlayer, str4, null, 0f);
                }
            }
        }