public void AddUpdateVictimAccount(CSteamID id, decimal bounty, string lastDisplayName)
 {
     try
     {
         MySqlConnection connection = CreateConnection();
         MySqlCommand command = connection.CreateCommand();
         if (CheckExists(id))
         {
             command.CommandText = "UPDATE `" + FeexHitman.Instance.Configuration.Instance.FeexHitmanDatabase.DatabaseTableName + "` SET `bounty` = bounty + (" + bounty + "), `lastDisplayName` = @lastDisplayName, `lastUpdated` = NOW() WHERE `steamId` = '" + id.ToString() + "';";
         }
         else
         {
             command.CommandText = "INSERT IGNORE INTO `" + FeexHitman.Instance.Configuration.Instance.FeexHitmanDatabase.DatabaseTableName + "` (steamId,bounty,lastDisplayName,lastUpdated) VALUES('" + id.ToString() + "','" + bounty + "',@lastDisplayName,NOW());";
         }
         command.Parameters.AddWithValue("@lastDisplayName", lastDisplayName);
         connection.Open();
         IAsyncResult result = command.BeginExecuteNonQuery();
         command.EndExecuteNonQuery(result);
         connection.Close();
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
Esempio n. 2
0
        protected override async void execute(CSteamID executor, string parameter)
        {
            Player ply = PlayerTool.getPlayer(executor);

            if (Main.Config.safeZoneOnly && !ply.movement.isSafe)
            {
                UnityThread.executeInUpdate(() =>
                {
                    ChatManager.say(executor, $"Stash can only be accessed inside a safezone", Color.cyan);
                });
                return;
            }

            Items stash = new Items(7);

            stash.resize((byte)Main.Config.width, (byte)Main.Config.height);

            //List<ItemJar> items = AsyncContext.Run(async () => await Task.Run(() => StashDB.GetItemsAsync(executor.ToString())));
            List <ItemJar> items = await Task.Run(() => StashDB.GetItemsAsync(executor.ToString()));

            foreach (ItemJar item in items)
            {
                ItemAsset itemAsset = (ItemAsset)Assets.find(EAssetType.ITEM, item.item.id);

                try
                {
                    stash.addItem(item.x, item.y, item.rot, new Item(item.item.id, item.item.amount, item.item.quality, item.item.metadata));
                }
                catch (Exception ex)
                {
                    UnityThread.executeInUpdate(() =>
                    {
                        ChatManager.say(executor, $"Failed to get {itemAsset.itemName}, not enough free space", Color.cyan);
                    });
                }
            }

            stash.onItemAdded = async(byte page, byte index, ItemJar item) => {
                await Task.Run(() => StashDB.AddItemAsync(executor.ToString(), item));

                //AsyncContext.Run(async () => await Task.Run(() => StashDB.AddItemAsync(executor.ToString(), item)));
            };

            stash.onItemRemoved = async(byte page, byte index, ItemJar item) =>
            {
                await Task.Run(() => StashDB.DeleteItemAsync(executor.ToString(), item));

                //AsyncContext.Run(async () => await Task.Run(() => StashDB.DeleteItemAsync(executor.ToString(), item)));
            };

            stash.onItemUpdated = async(byte page, byte index, ItemJar item) =>
            {
                await Task.Run(() => StashDB.DeleteItemAsync(executor.ToString(), item));

                //AsyncContext.Run(async () => await Task.Run(() => StashDB.UpdateItemAsync(executor.ToString(), item)));
            };

            ply.inventory.updateItems(7, stash);
            ply.inventory.sendStorage();
        }
Esempio n. 3
0
 public static UnturnedPlayer FromCSteamID(CSteamID cSteamID)
 {
     if (string.IsNullOrEmpty(cSteamID.ToString()) || cSteamID.ToString() == "0")
     {
         return(null);
     }
     else
     {
         return(new UnturnedPlayer(cSteamID));
     }
 }
Esempio n. 4
0
 private UnturnedPlayer(CSteamID cSteamID)
 {
     if (string.IsNullOrEmpty(cSteamID.ToString()) || cSteamID.ToString() == "0")
     {
         throw new PlayerIsConsoleException();
     }
     else
     {
         player = PlayerTool.getPlayer(cSteamID);
     }
 }
        public static void TellInfo(IRocketPlayer caller, CSteamID ownerid, CSteamID group)
        {
            string charname = null;

            UnturnedPlayer owner = UnturnedPlayer.FromCSteamID(ownerid);

            bool isOnline = owner.Player != null ? owner.Player.channel != null ? true : false : false;

            if (!isOnline)
            {
                charname = GetCharName(ownerid);
            }

            if (Init.Instance.Configuration.Instance.SayPlayerID)
            {
                UnturnedChat.Say(caller, "Owner ID: " + ownerid.ToString());
            }

            if (Init.Instance.Configuration.Instance.SayPlayerCharacterName)
            {
                if (isOnline)
                {
                    UnturnedChat.Say(caller, "Character Name: " + owner.CharacterName);
                }
                else if (charname != null)
                {
                    UnturnedChat.Say(caller, "Character Name: " + charname);
                }
                else
                {
                    UnturnedChat.Say(caller, "Could not get character name.");
                }
            }
            if (Init.Instance.Configuration.Instance.SayPlayerSteamName)
            {
                UnturnedChat.Say(caller, "Steam Name: " + SteamRequest(ownerid.ToString()));
            }
            if (group != CSteamID.Nil)
            {
                string GroupName = SteamGroupRequest(group.ToString());
                if (Init.Instance.Configuration.Instance.SayGroupID)
                {
                    UnturnedChat.Say(caller, "Group ID: " + group.ToString());
                }
                if (Init.Instance.Configuration.Instance.SayGroupName)
                {
                    UnturnedChat.Say(caller, "Group Name: " + GroupName);
                }
            }
        }
Esempio n. 6
0
        public void TellInfo(IUser caller, CSteamID ownerid, CSteamID group)
        {
            if (!(_playerManager.GetPlayer(ownerid.ToString()) is UnturnedPlayer owner))
            {
                return;
            }

            if (ConfigurationInstance.SayPlayerID)
            {
                caller.SendMessage($"Owner ID: {ownerid}");
            }
            if (ConfigurationInstance.SayPlayerCharacterName)
            {
                caller.SendMessage($"Character Name: {owner.CharacterName}");
            }
            if (ConfigurationInstance.SayPlayerSteamName)
            {
                caller.SendMessage($"Steam Name: {owner.SteamName}");
            }
            if (group != CSteamID.Nil)
            {
                if (ConfigurationInstance.SayGroupID)
                {
                    caller.SendMessage($"Group ID: {owner.SteamGroupID}");
                }
                if (ConfigurationInstance.SayGroupName)
                {
                    caller.SendMessage($"Group Name: {owner.SteamGroupName}");
                }
            }
        }
        private void OnPlayerDisconnected(CSteamID steamid)
        {
            var player = playerManager.GetPlayerByIdAsync(steamid.ToString()).GetAwaiter().GetResult();
            PlayerDisconnectedEvent @event = new PlayerDisconnectedEvent(player, null);

            eventManager.Emit(this, @event);
        }
Esempio n. 8
0
        private void Events_OnJoinRequested(CSteamID player, ref ESteamRejection?rejection)
        {
            Profile SteamProfile = new Profile(ulong.Parse(player.ToString()));
            bool?   vacStatus    = SteamProfile.IsVacBanned;

            string name = SteamProfile.SteamID;

            if (Instance.Configuration.Instance.Errorkick && (!(vacStatus.HasValue)))
            {
                rejection = ESteamRejection.PLUGIN;
                Logger.LogError(Translate("vacStatus_null", name, player));
            }
            else if (!(vacStatus.HasValue))
            {
                Logger.LogError(Translate("vacStatus_null", name, player));
            }
            else
            {
                if ((bool)vacStatus)
                {
                    rejection = ESteamRejection.AUTH_VAC_BAN;
                }
                Logger.Log(Translate((bool)vacStatus ? "vacStatus_true" : "vacStatus_false", name, player));
            }
        }
        public byte GetWarnings(CSteamID id)
        {
            byte num = 0;

            try
            {
                MySqlConnection mySqlConnection = this.createConnection();
                MySqlCommand    mySqlCommand    = mySqlConnection.CreateCommand();
                mySqlCommand.CommandText = string.Concat(new string[] {
                    "select `warninglevel` from `",
                    Zaup_Warning.Instance.Configuration.Instance.TableName,
                    "` where `steamId` = '",
                    id.ToString(),
                    "';"
                });
                mySqlConnection.Open();
                object obj = mySqlCommand.ExecuteScalar();
                if (obj != null)
                {
                    byte.TryParse(obj.ToString(), out num);
                }
                mySqlConnection.Close();
            }
            catch (Exception exception)
            {
                Rocket.Core.Logging.Logger.LogException(exception);
            }
            return(num);
        }
Esempio n. 10
0
 public byte GetWarnings(CSteamID id)
 {
     byte num = 0;
     try
     {
         MySqlConnection mySqlConnection = this.createConnection();
         MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
         mySqlCommand.CommandText = string.Concat(new string[] { 
             "select `warninglevel` from `",
             Zaup_Warning.Instance.Configuration.Instance.TableName,
             "` where `steamId` = '",
             id.ToString(),
             "';" 
         });
         mySqlConnection.Open();
         object obj = mySqlCommand.ExecuteScalar();
         if (obj != null)
         {
             byte.TryParse(obj.ToString(), out num);
         }
         mySqlConnection.Close();
     }
     catch (Exception exception)
     {
         Logger.LogException(exception);
     }
     return num;
 }
Esempio n. 11
0
        public ushort GetWarningsTime(CSteamID id)
        {
            ushort num = 0;

            try
            {
                MySqlConnection mySqlConnection = this.createConnection();
                MySqlCommand    mySqlCommand    = mySqlConnection.CreateCommand();
                mySqlCommand.CommandText = string.Concat(new string[] {
                    "select timestampdiff(day, now(), 'select `lastwarningdate` from `",
                    Zaup_Warning.Instance.Configuration.Instance.TableName,
                    "` where `steamId` = '",
                    id.ToString(),
                    "' ');"
                });
                mySqlConnection.Open();
                object obj = mySqlCommand.ExecuteScalar();
                if (obj != null)
                {
                    ushort.TryParse(obj.ToString(), out num);
                }
                mySqlConnection.Close();
            }
            catch (Exception exception)
            {
                Rocket.Core.Logging.Logger.LogException(exception);
            }
            return(num);
        }
        private void OnPlayerConnected(CSteamID steamid)
        {
            var player = playerManager.GetPlayerById(steamid.ToString());
            PlayerConnectedEvent @event = new PlayerConnectedEvent(player);

            eventManager.Emit(this, @event);
        }
Esempio n. 13
0
 public UnturnedUser(IDependencyContainer container, CSteamID id)
 {
     Id          = id.ToString();
     CSteamID    = id;
     Container   = container;
     UserManager = playerManager = container.Resolve <IPlayerManager>();
 }
Esempio n. 14
0
        public override void OnEnter()
        {
            CSteamID ID = SteamUser.GetSteamID();

            steamID.Value = ID.ToString();
            Finish();
        }
Esempio n. 15
0
    void InitLobby(CSteamID id)
    {
        lobby.LobbyID = id;
        if (Users == null)
        {
            lobby.Users = new List <User>();
        }
        else
        {
            Users.Clear();
        }

        int num = SteamMatchmaking.GetNumLobbyMembers(lobby.LobbyID);

        for (int i = 0; i < num; i++)
        {
            CSteamID userID = SteamMatchmaking.GetLobbyMemberByIndex(lobby.LobbyID, i);
            lobby.Users.Add(new User(userID));
        }
        SendPacketToLobby(new byte[] { }, PacketType.Test, EP2PSend.k_EP2PSendReliable, false);

#if UNITY_EDITOR
        Debug.Log("Num members in the lobby: " + num);
        Debug.Log("My steam ID: " + MyID.ToString());
#endif

        if (OnLobbyInitializationEvent != null)
        {
            OnLobbyInitializationEvent.Invoke();
        }
    }
Esempio n. 16
0
        // Gets player profile picture
        private async Task <string> GetProfilePictureHashAsync(CSteamID user)
        {
            // Gets the Steam API Key from the configuration.
            var apiKey = m_Configuration["steamWebApiKey"];

            // Check if its empty and if so return
            if (string.IsNullOrEmpty(apiKey))
            {
                return("");
            }

            // Creates new web client.
            using var web = new WebClient();

            // Gets the string using the steam API where the id is the users steam api aswell as using the key
            var result =
                await web.DownloadStringTaskAsync(
                    $"http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key={apiKey}&steamids={user.m_SteamID}");

            // Deserializes the json return.
            var deserialized = JsonConvert.DeserializeObject <PlayerSummaries>(result);

            // Return the response making it into a avatar hash, which is a industry standard way of storing photo ids stored remoteley by steam.
            return(deserialized.response.players
                   .FirstOrDefault(k => k.steamid.Equals(user.ToString(), StringComparison.Ordinal))?.avatarhash ??
                   "");
        }
Esempio n. 17
0
        public bool CheckExists(CSteamID id)
        {
            try
            {
                var connection = CreateConnection();
                var command    = connection.CreateCommand();
                var exists     = 0;
                command.CommandText = "SELECT COUNT(1) FROM `" +
                                      FeexHitman.Instance.Configuration.Instance.FeexHitmanDatabase.DatabaseTableName +
                                      "` WHERE `steamId` = '" + id.ToString() + "';";
                connection.Open();
                var result = command.ExecuteScalar();
                if (result != null)
                {
                    int.TryParse(result.ToString(), out exists);
                }
                connection.Close();

                if (exists == 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(false);
            }
        }
Esempio n. 18
0
        private static async Task <KeyValuePair <string, string> > CheckPair(CSteamID steamP, CSteamID steamG)
        {
            var isOnline     = PlayerTool.tryGetSteamPlayer(steamP.ToString(), out var player);
            var nameAndGroup = await RequestUtil.GetNameAndGroup(steamP, steamG);

            return(new KeyValuePair <string, string>(isOnline ? player.playerID.characterName : nameAndGroup.Key, nameAndGroup.Value));
        }
Esempio n. 19
0
 public void AddUpdateVictimAccount(CSteamID id, decimal bounty, string lastDisplayName)
 {
     try
     {
         var connection = CreateConnection();
         var command    = connection.CreateCommand();
         if (CheckExists(id))
         {
             command.CommandText = "UPDATE `" +
                                   FeexHitman.Instance.Configuration.Instance.FeexHitmanDatabase
                                   .DatabaseTableName + "` SET `bounty` = bounty + (" + bounty +
                                   "), `lastDisplayName` = @lastDisplayName, `lastUpdated` = NOW() WHERE `steamId` = '" +
                                   id.ToString() + "';";
         }
         else
         {
             command.CommandText = "INSERT IGNORE INTO `" +
                                   FeexHitman.Instance.Configuration.Instance.FeexHitmanDatabase
                                   .DatabaseTableName +
                                   "` (steamId,bounty,lastDisplayName,lastUpdated) VALUES('" + id.ToString() +
                                   "','" + bounty + "',@lastDisplayName,NOW());";
         }
         command.Parameters.AddWithValue("@lastDisplayName", lastDisplayName);
         connection.Open();
         var result = command.BeginExecuteNonQuery();
         command.EndExecuteNonQuery(result);
         connection.Close();
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
Esempio n. 20
0
        public decimal GetBounty(CSteamID id)
        {
            decimal output = 0;

            try
            {
                var connection = CreateConnection();
                var command    = connection.CreateCommand();
                command.CommandText = "SELECT `bounty` FROM `" +
                                      FeexHitman.Instance.Configuration.Instance.FeexHitmanDatabase.DatabaseTableName +
                                      "` WHERE `steamId` = '" + id.ToString() + "';";
                connection.Open();
                var result = command.ExecuteScalar();
                if (result != null)
                {
                    decimal.TryParse(result.ToString(), out output);
                }
                connection.Close();
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            return(output);
        }
        public override void GetAvatarForPlayerId(GameServiceUserInfo user)
        {
            AccountID_t accountId = new AccountID_t(Convert.ToUInt32(user.PlayerId));
            CSteamID    steamId   = new CSteamID(accountId, EUniverse.k_EUniversePublic, EAccountType.k_EAccountTypeIndividual);

            SteamWebApi.GetSteamUserAvatar(steamId.ToString(), user.SetAvatarFromSprite);
        }
Esempio n. 22
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            RocketPermissionsManager Permissions = R.Instance.GetComponent<RocketPermissionsManager>();
            if (caller != null)
            {
                if (command.Length != 1)
                {
                    UnturnedChat.Say(caller, RocketJobs.Instance.Translate("kick_usage"));
                    return;
                }
                else if (command.Length == 1)
                {
                    UnturnedPlayer Player = (UnturnedPlayer)caller;
                    CSteamID ID = Player.CSteamID;
                    UnturnedPlayer Target = UnturnedPlayer.FromName(command[0].ToLower());
                    CSteamID TargetID = Target.CSteamID;

                    foreach (PrivateJobs Jobs in RocketJobs.Instance.ConfigPrivJobs)
                    {
                        RocketPermissionsGroup g = Permissions.GetGroup(Jobs.LeaderPermissionGroup);
                        if (g.Members.Exists(k => k == ID.ToString()))
                        {
                            RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup);
                            if (Group != null && Group.Members.Exists(k => k == TargetID.ToString()))
                            {
                                Permissions.RemovePlayerFromGroup(Group.Id, Target);
                                UnturnedChat.Say(Target, RocketJobs.Instance.Translate("notification_left_job", Jobs.JobName));
                                UnturnedChat.Say(caller, RocketJobs.Instance.Translate("notification_kicked", Target.DisplayName));
                            }
                        }
                    }
                }
            }
        }
Esempio n. 23
0
        public bool EditWarning(CSteamID id, short amt = 1)
        {
            bool success = false;

            try
            {
                MySqlConnection mySqlConnection = this.createConnection();
                MySqlCommand    mySqlCommand    = mySqlConnection.CreateCommand();
                mySqlCommand.CommandText = string.Concat(new string[] {
                    "insert into `" +
                    Zaup_Warning.Instance.Configuration.Instance.TableName +
                    "` (steamId, warninglevel) VALUES ('" + id.ToString() + "', 1) on duplicate key update `warninglevel`=`warninglevel`+ " +
                    amt.ToString()
                });
                mySqlConnection.Open();
                int affected = mySqlCommand.ExecuteNonQuery();
                mySqlConnection.Close();
                if (affected > 0)
                {
                    success = true;
                }
            }
            catch (Exception exception)
            {
                Rocket.Core.Logging.Logger.LogException(exception);
            }
            return(success);
        }
Esempio n. 24
0
        public static bool AskClaimBed_Prefix(BarricadeManager __instance, CSteamID steamID, byte x, byte y, ushort plant, ushort index)
        {
            BarricadeRegion barricadeRegion;

            if (Provider.isServer && BarricadeManager.tryGetRegion(x, y, plant, out barricadeRegion))
            {
                Player player = PlayerTool.getPlayer(steamID);
                if (player == null)
                {
                    return(false);
                }
                if (player.life.isDead)
                {
                    return(false);
                }
                if (index >= barricadeRegion.drops.Count)
                {
                    return(false);
                }
                if ((barricadeRegion.drops[index].model.transform.position - player.transform.position).sqrMagnitude > 400f)
                {
                    return(false);
                }
                InteractableBed interactableBed = barricadeRegion.drops[index].interactable as InteractableBed;
                if (interactableBed != null && interactableBed.isClaimable && interactableBed.checkClaim(player.channel.owner.playerID.steamID))
                {
                    if (interactableBed.isClaimed)
                    {
                        var home = HomesHelper.GetPlayerHome(steamID, interactableBed);
                        HomesHelper.RemoveHome(steamID, home);
                        home.Unclaim();
                    }
                    else
                    {
                        var playerData = HomesHelper.GetOrCreatePlayer(steamID);
                        int maxHomes   = VipHelper.GetPlayerMaxHomes(steamID.ToString());
                        if (maxHomes == 1 && playerData.Homes.Count == 1)
                        {
                            foreach (var home in playerData.Homes.ToArray())
                            {
                                HomesHelper.RemoveHome(steamID, home);
                                home.Unclaim();
                            }
                        }
                        else if (maxHomes <= playerData.Homes.Count)
                        {
                            UnturnedChat.Say(steamID, MoreHomesPlugin.Instance.Translate("MaxHomesWarn"), MoreHomesPlugin.Instance.MessageColor);
                            return(false);
                        }

                        var playerHome = new PlayerHome(playerData.GetUniqueHomeName(), interactableBed);
                        playerData.Homes.Add(playerHome);
                        playerHome.Claim(steamID);
                        UnturnedChat.Say(steamID, MoreHomesPlugin.Instance.Translate("HomeClaimed", playerHome.Name), MoreHomesPlugin.Instance.MessageColor);
                    }
                }
            }
            return(false);
        }
Esempio n. 25
0
        public void CheckSetupAccount(CSteamID id)
        {
            PlayerBalance bal = GetPlayerBalance(id.ToString());

            if (bal == null)
            {
                bal = new PlayerBalance()
                {
                    SteamID    = id.ToString(),
                    Balance    = pluginInstance.Configuration.Instance.InitialBalance,
                    LastUpdate = DateTime.Now
                };
                data.Add(bal);
            }

            bal.SetExperience(id);
        }
Esempio n. 26
0
        public bool Equals(UnturnedPlayer p)
        {
            if (p == null)
            {
                return(false);
            }

            return(CSteamID.ToString() == p.CSteamID.ToString());
        }
Esempio n. 27
0
 public void SteamRequest()
 {
     new LogEventRequest()
     .SetEventKey("steamInitTxn")
     .SetEventAttribute("steamID", steamID.ToString())
     .Send((response) => {
         GSData scriptData = response.ScriptData;
     });
 }
Esempio n. 28
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>();

            if (caller != null)
            {
                UnturnedPlayer Player = (UnturnedPlayer)caller;
                CSteamID       ID     = Player.CSteamID;
                foreach (PublicJobs Job in RocketJobs.Instance.ConfigPubJobs)
                {
                    RocketPermissionsGroup Group = Permissions.GetGroup(Job.PermissionGroup);
                    if (Group != null)
                    {
                        foreach (string IDS in Group.Members)
                        {
                            if (IDS == ID.ToString())
                            {
                                Permissions.RemovePlayerFromGroup(Job.PermissionGroup, caller);
                                UnturnedChat.Say(caller, RocketJobs.Instance.Translate("notification_left_job", Job.JobName));
                                return;
                            }
                        }
                    }
                }
                foreach (PrivateJobs Job in RocketJobs.Instance.ConfigPrivJobs)
                {
                    RocketPermissionsGroup Group = Permissions.GetGroup(Job.PermissionGroup);
                    if (Group != null)
                    {
                        foreach (string IDS in Group.Members)
                        {
                            if (IDS == ID.ToString())
                            {
                                Permissions.RemovePlayerFromGroup(Job.PermissionGroup, caller);
                                UnturnedChat.Say(caller, RocketJobs.Instance.Translate("notification_left_job", Job.JobName));
                                return;
                            }
                        }
                    }
                }
                UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_not_in_a_job"));
            }
        }
Esempio n. 29
0
        private void OnLobbyEntered(LobbyEnter_t result)
        {
            _steamLobbyID = (CSteamID)result.m_ulSteamIDLobby;
            Debug.LogFormat("[STEAM] Entered lobby with SteamID {0}", _steamLobbyID.ToString());

            if (!BoltNetwork.IsServer && !BoltNetwork.IsClient)
            {
                Debug.Log("[BOLT] Starting client ...");
                BoltLauncher.StartClient();
            }
        }
Esempio n. 30
0
        public async void Events_OnResourceKill(CSteamID player, ResourceAsset asset)
        {
            var instigatorplayer = await m_UnturnedLogRepository.FindPlayerAsync(player.ToString(), UserSearchMode.FindById);

            var server = await m_UnturnedLogRepository.GetCurrentServerAsync() ??
                         await m_UnturnedLogRepository.CheckAndRegisterCurrentServerAsync();

            var EventTreeCut = EventDatabase.BuildEventData(instigatorplayer, "Resource harvested", " ", server);

            await m_UnturnedLogRepository.AddPlayerEventAsync(EventTreeCut);
        }
Esempio n. 31
0
 protected internal UnturnedPlayer(Player player)
 {
     Asset            = UnturnedPlayerAsset.Instance;
     State            = NullEntityState.Instance;
     Inventory        = new UnturnedPlayerInventory(Player);
     Transform        = new UnityTransform(player.transform);
     Player           = player;
     SteamPlayer      = Player.channel.owner;
     SteamId          = SteamPlayer.playerID.steamID;
     EntityInstanceId = SteamId.ToString();
 }
Esempio n. 32
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>();

            if (caller != null)
            {
                UnturnedPlayer Player = (UnturnedPlayer)caller;
                CSteamID       ID     = Player.CSteamID;
                if (command.Length != 1)
                {
                    UnturnedChat.Say(caller, RocketJobs.Instance.Translate("accept_usage"));
                    return;
                }
                else if (command.Length == 1)
                {
                    UnturnedPlayer Target = UnturnedPlayer.FromName(command[0].ToLower());
                    if (RocketJobs.Instance.Applications.ContainsKey(Target.CSteamID))
                    {
                        string JobName = RocketJobs.Instance.Applications[Target.CSteamID];
                        foreach (PrivateJobs Job in RocketJobs.Instance.ConfigPrivJobs)
                        {
                            if (Job.JobName.ToLower() == JobName.ToLower())
                            {
                                RocketPermissionsGroup Group = Permissions.GetGroup(Job.LeaderPermissionGroup);
                                if (Group != null)
                                {
                                    foreach (string IDS in Group.Members)
                                    {
                                        if (IDS == ID.ToString())
                                        {
                                            Permissions.AddPlayerToGroup(Job.PermissionGroup, Target);
                                            UnturnedChat.Say(caller, RocketJobs.Instance.Translate("notification_accepted_application", Target.CharacterName));
                                            UnturnedChat.Say(Target, RocketJobs.Instance.Translate("notification_quiet_joined_job", Job.JobName));
                                            if (RocketJobs.Instance.Configuration.Instance.AnnounceJobJoin)
                                            {
                                                UnturnedChat.Say(RocketJobs.Instance.Translate("notification_global_joined_job", Target.CharacterName, Job.JobName));
                                            }
                                            return;
                                        }
                                    }
                                    UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_not_leader_of_job", Job.JobName));
                                    return;
                                }
                            }
                        }
                        UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_invalid_job_in_storage"));
                        return;
                    }
                    UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_player_not_applying"));
                    return;
                }
            }
        }
Esempio n. 33
0
 public decimal GetBounty(CSteamID id)
 {
     decimal output = 0;
     try
     {
         MySqlConnection connection = CreateConnection();
         MySqlCommand command = connection.CreateCommand();
         command.CommandText = "SELECT `bounty` FROM `" + FeexHitman.Instance.Configuration.Instance.FeexHitmanDatabase.DatabaseTableName + "` WHERE `steamId` = '" + id.ToString() + "';";
         connection.Open();
         object result = command.ExecuteScalar();
         if (result != null) Decimal.TryParse(result.ToString(), out output);
         connection.Close();
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
     return output;
 }
Esempio n. 34
0
        public bool CheckAccount(CSteamID id)
        {
            try
            {
                MySqlConnection connection = CreateConnection();
                MySqlCommand command = connection.CreateCommand();
                int exists = 0;
                connection.Open();
                command.CommandText = "SELECT COUNT(1) FROM `" + FeexRanks.Instance.Configuration.Instance.FeexRanksDatabase.DatabaseTableName + "` WHERE `steamId` = '" + id.ToString() + "'";
                object result = command.ExecuteScalar();
                if (result != null) Int32.TryParse(result.ToString(), out exists);
                connection.Close();

                if (exists == 0) { return false; }
                else { return true; }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return false;
            }
        }
Esempio n. 35
0
 public bool RemoveVictimAccount(CSteamID id)
 {
     try
     {
         MySqlConnection connection = CreateConnection();
         MySqlCommand command = connection.CreateCommand();
         command.CommandText = "DELETE FROM `" + FeexHitman.Instance.Configuration.Instance.FeexHitmanDatabase.DatabaseTableName + "` WHERE `steamId`='" + id.ToString() + "';";
         connection.Open();
         IAsyncResult result = command.BeginExecuteNonQuery();
         command.EndExecuteNonQuery(result);
         connection.Close();
         return true;
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
         return false;
     }
 }
Esempio n. 36
0
 public bool EditWarning(CSteamID id, short amt = 1)
 {
     bool success = false;
     try
     {
         MySqlConnection mySqlConnection = this.createConnection();
         MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
         mySqlCommand.CommandText = string.Concat(new string[] { 
             "insert into `" +
         Zaup_Warning.Instance.Configuration.Instance.TableName +
         "` (steamId, warninglevel) VALUES ('" + id.ToString() + "', 1) on duplicate key update `warninglevel`=`warninglevel`+ " + 
         amt.ToString()
         });
         mySqlConnection.Open();
         int affected = mySqlCommand.ExecuteNonQuery();
         mySqlConnection.Close();
         if (affected > 0) success = true;
     }
     catch (Exception exception)
     {
         Logger.LogException(exception);
     }
     return success;
 }
Esempio n. 37
0
 public ushort GetWarningsTime(CSteamID id)
 {
     ushort num = 0;
     try
     {
         MySqlConnection mySqlConnection = this.createConnection();
         MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
         mySqlCommand.CommandText = string.Concat(new string[] { 
             "select timestampdiff(day, now(), 'select `lastwarningdate` from `",
             Zaup_Warning.Instance.Configuration.Instance.TableName,
             "` where `steamId` = '",
             id.ToString(),
             "' ');" 
         });
         mySqlConnection.Open();
         object obj = mySqlCommand.ExecuteScalar();
         if (obj != null)
         {
             ushort.TryParse(obj.ToString(), out num);
         }
         mySqlConnection.Close();
     }
     catch (Exception exception)
     {
         Logger.LogException(exception);
     }
     return num;
 }
Esempio n. 38
0
 public static void Say(CSteamID CSteamID, string message, Color color)
 {
     if (CSteamID == null || CSteamID.ToString() == "0")
     {
         System.Console.ForegroundColor = ConsoleColor.Gray;
         System.Console.WriteLine(message);
         Logger.Log(message,false);
     }
     else
     {   
         foreach (string m in wrapMessage(message))
         {
             ChatManager.Instance.SteamChannel.send("tellChat", CSteamID, ESteamPacket.UPDATE_UNRELIABLE_BUFFER, new object[] { CSteamID.Nil, (byte)EChatMode.SAY,color, m });
         }
     }
 }
Esempio n. 39
0
 public void UpdateVictimDisplayName(CSteamID id, string lastDisplayName)
 {
     try
     {
         MySqlConnection connection = CreateConnection();
         MySqlCommand command = connection.CreateCommand();
         command.CommandText = "UPDATE `" + FeexHitman.Instance.Configuration.Instance.FeexHitmanDatabase.DatabaseTableName + "` SET `lastDisplayName` = @lastDisplayName WHERE `steamId` = '" + id.ToString() + "';";
         command.Parameters.AddWithValue("@lastDisplayName", lastDisplayName);
         connection.Open();
         IAsyncResult result = command.BeginExecuteNonQuery();
         command.EndExecuteNonQuery(result);
         connection.Close();
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
Esempio n. 40
0
 public void UpdateDisplayName(CSteamID id, string lastDisplayName)
 {
     try
     {
         MySqlConnection connection = CreateConnection();
         MySqlCommand command = connection.CreateCommand();
         command.CommandText = "UPDATE `" + FeexRanks.Instance.Configuration.Instance.FeexRanksDatabase.DatabaseTableName + "` SET `lastDisplayName` = '" + lastDisplayName + "' WHERE `steamId` = '" + id.ToString() + "'";
         connection.Open();
         command.ExecuteNonQuery();
         connection.Close();
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
Esempio n. 41
0
 public void UpdateAccount(CSteamID id, int points)
 {
     try
     {
         MySqlConnection connection = CreateConnection();
         MySqlCommand command = connection.CreateCommand();
         connection.Open();
         command.CommandText = "UPDATE `" + FeexRanks.Instance.Configuration.Instance.FeexRanksDatabase.DatabaseTableName + "` SET `points`=`points`+" + points + " WHERE `steamId`='" + id.ToString() + "'";
         command.ExecuteNonQuery();
         connection.Close();
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
Esempio n. 42
0
 public string[] GetAccountBySteamID(CSteamID id)
 {
     string[] output = new string[3];
     try
     {
         MySqlConnection connection = CreateConnection();
         MySqlCommand command = new MySqlCommand("SELECT * FROM `" + FeexRanks.Instance.Configuration.Instance.FeexRanksDatabase.DatabaseViewName + "` WHERE `steamId` = '" + id.ToString() + "'", connection);
         connection.Open();
         MySqlDataReader dataReader = command.ExecuteReader();
         while (dataReader.Read())
         {
             output[0] = Convert.ToString(dataReader["points"]);
             output[1] = Convert.ToString(dataReader["currentRank"]);
             output[2] = Convert.ToString(dataReader["lastDisplayName"]);
         }
         dataReader.Close();
         connection.Close();
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
     return output;
 }
Esempio n. 43
0
 public static void Say(CSteamID CSteamID, string message, Color color)
 {
     if (CSteamID == null || CSteamID.ToString() == "0")
     {
         Core.Logging.Logger.Log(message, ConsoleColor.Gray);
     }
     else
     {   
         foreach (string m in wrapMessage(message))
         {
             ChatManager.instance.channel.send("tellChat", CSteamID, ESteamPacket.UPDATE_UNRELIABLE_BUFFER, new object[] { CSteamID.Nil, (byte)EChatMode.SAY,color, m });
         }
     }
 }