Ejemplo n.º 1
0
        private async Task saveLastCoordsTick()
        {
            await Delay(300000);

            foreach (var source in LastCoordsInCache)
            {
                string sid = ("steam:" + source.Key.Identifiers["steam"]);
                try
                {
                    Vector3 lastCoords  = source.Value.Item1;
                    float   lastHeading = source.Value.Item2;

                    UPlayerCoords UPC = new UPlayerCoords()
                    {
                        x       = lastCoords.X,
                        y       = lastCoords.Y,
                        z       = lastCoords.Z,
                        heading = lastHeading
                    };

                    string pos = JsonConvert.SerializeObject(UPC);

                    Exports["ghmattimysql"].execute("UPDATE characters SET coords=? WHERE identifier=?", new[] { pos, sid });
                }
                catch { continue; }
            }
        }
Ejemplo n.º 2
0
        private void OnPlayerDropped([FromSource] Player player, string reason)
        {
            string sid = ("steam:" + player.Identifiers["steam"]);

            LoadCharacter.characters.Remove(sid);

            try
            {
                Vector3 lastCoords  = LastCoordsInCache[player].Item1;
                float   lastHeading = LastCoordsInCache[player].Item2;

                UPlayerCoords UPC = new UPlayerCoords()
                {
                    x       = lastCoords.X,
                    y       = lastCoords.Y,
                    z       = lastCoords.Z,
                    heading = lastHeading
                };

                string pos = JsonConvert.SerializeObject(UPC);

                Exports["ghmattimysql"].execute("UPDATE characters SET coords=? WHERE identifier=?", new[] { pos, sid });

                LastCoordsInCache.Remove(player);
            }
            catch
            {
            }
        }