public static GameData GetData() { GameData dat = new GameData(); // Game and world dat.GameTime = World.CurrentDayTime; dat.FPS = Game.FPS; dat.RadioStation = WorldHelper.GetRadioFriendlyName(Function.Call<string>(Hash.GET_PLAYER_RADIO_STATION_NAME)); dat.Weather = World.Weather.ToString(); // Player dat.PlayerHandle = Game.Player.Character.Handle; dat.WantedLevel = Game.Player.WantedLevel; dat.PlayerHealth = Function.Call<int>(Hash.GET_ENTITY_HEALTH, Game.Player.Character.Handle) - 100; dat.PlayerArmor = Game.Player.Character.Armor; dat.PlayerMoney = Game.Player.Money; dat.PlayerPos = Game.Player.Character.Position; dat.PlayerHeading = Game.Player.Character.Heading; dat.PlayerName = ((PedHash)Game.Player.Character.Model.Hash).ToString(); dat.ZoneName = World.GetZoneName(Game.Player.Character.Position); dat.StreetName = World.GetStreetName(Game.Player.Character.Position); // Weapons dat.WeaponName = Enum.GetName(typeof(WeaponHash), Game.Player.Character.Weapons.Current.Hash); dat.WeaponAmmo = Game.Player.Character.Weapons.Current.Ammo; dat.WeaponAmmoInClip = Game.Player.Character.Weapons.Current.AmmoInClip; dat.WeaponMaxInClip = Game.Player.Character.Weapons.Current.MaxAmmoInClip; // Vehicle if (Game.Player.Character.IsInVehicle()) { var veh = Game.Player.Character.CurrentVehicle; dat.VehicleHandle = veh.Handle; dat.VehicleName = veh.FriendlyName; dat.VehicleSpeed = veh.Speed; dat.VehicleRPM = veh.CurrentRPM; dat.VehicleLicense = veh.NumberPlate; dat.VehicleType = veh.ClassType.ToString(); dat.VehicleEngineHealth = veh.EngineHealth; dat.VehiclePetrolHealth = veh.PetrolTankHealth; } return dat; }
private void OnTick(object sender, EventArgs e) { cacheData = GameData.GetData(); // Tick extension manager ExtensionManager.Instance.Update(); // Check for inputs WebInput input; while (inputQueue.TryDequeue(out input)) { try { Logger.Log("Executing " + input.Cmd + " " + input.Arg); object retVal = input.Execute(); retQueue.Enqueue(new KeyValuePair<string, object>(input.UID, retVal)); } catch (Exception ex) { Logger.Log(ex.ToString()); } } }