Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using GTA;
- namespace ScriptEvents
- {
- public enum Race
- {
- SouthBroker,
- AirportRun,
- DukesBoulevard,
- SouthAlgonquin,
- StarJunction,
- RoadToBohan,
- NorthAlderney,
- Elevated,
- SouthAlderney
- }
- public enum VehicleType
- {
- Bike,
- Boat,
- Car,
- Helicopter,
- Plane
- }
- //GET_TIME_SINCE
- public static class Events
- {
- #region Private fields
- private static Player localPlayer = Game.LocalPlayer;
- private static Ped localCharacter = Game.LocalPlayer.Character;
- // Variables for tracking Player/Character property values.
- private static int playerMoney, timesArrested, timesDied, wantedLevel, missionsCompleted, missionsFailed, weaponAmmo, daysPassed, vehiclesExported, pigeonsExterminated, timesDrunk, stuntJumpsCompleted, stuntJumpsFound, photosTaken, savesMade, textsReceived, weaponsPickedUp, sentEmails, receivedEmails, firstAidCollected, pedsKilled, vehicleFlips, headshotKills, tiresPopped, bridgesFlownUnder;
- private static float playerHealth, playerVehicleHealth, gameProgress, payAndSprayPaid, clothesBought, foodBought, taxisPaidFor;
- private static bool playerInVehicle, playerClimbing, playerSwimming, playerPressingHorn, playerIsRagdoll, playerShooting, sirenActive;
- private static Vehicle playerLastVehicle;
- private static Weapon playerCurrentWeapon;
- private static Ped playerPedTarget;
- private static GTA.Timer eventsTimer;
- private static FloatStatistic[] missionStatistic = { FloatStatistic.ROMAN_MISSION_PROGRESS, FloatStatistic.VLAD_MISSION_PROGRESS, FloatStatistic.JACOB_MISSION_PROGRESS, FloatStatistic.FAUSTIN_MISSION_PROGRESS, FloatStatistic.MANNY_MISSION_PROGRESS, FloatStatistic.ELIZABETA_MISSION_PROGRESS, FloatStatistic.DWAYNE_MISSION_PROGRESS, FloatStatistic.BRUCIE_MISSION_PROGRESS, FloatStatistic.PLAYBOY_MISSION_PROGRESS, FloatStatistic.FRANCIS_MISSION_PROGRESS, FloatStatistic.ULPC_MISSION_PROGRESS, FloatStatistic.PACKIE_MISSION_PROGRESS, FloatStatistic.RAY_MISSION_PROGRESS, FloatStatistic.GERRY_MISSION_PROGRESS, FloatStatistic.DERRICK_MISSION_PROGRESS, FloatStatistic.BERNIE_MISSION_PROGRESS, FloatStatistic.BELL_MISSION_PROGRESS, FloatStatistic.GAMBETTI_MISSION_PROGRESS, FloatStatistic.JIMMY_MISSION_PROGRESS };
- private static float[] missionProgress = new float[missionStatistic.Length];
- private static FloatStatistic[] respectStatistic = { FloatStatistic.ROMAN_RESPECT, FloatStatistic.JACOB_RESPECT, FloatStatistic.DWAYNE_RESPECT, FloatStatistic.BRUCIE_RESPECT, FloatStatistic.PACKIE_RESPECT, FloatStatistic.RESPECT_TOTAL /*Where is this displayed or used?*/ };
- private static float[] respectProgress = new float[respectStatistic.Length];
- private static FloatStatistic[] likeStatistic = { FloatStatistic.ROMAN_LIKE, FloatStatistic.JACOB_LIKE, FloatStatistic.DWAYNE_LIKE, FloatStatistic.BRUCIE_LIKE, FloatStatistic.PACKIE_LIKE };
- private static float[] likeProgress = new float[likeStatistic.Length];
- private static FloatStatistic[] fondnessStatistic = { FloatStatistic.CARMEN_ORTIZ_FONDNESS, FloatStatistic.ALEX_CHILTON_FONDNESS, FloatStatistic.KIKI_JENKINS_FONDNESS, FloatStatistic.MICHELLE_FONDNESS, FloatStatistic.KATE_FONDNESS };
- private static float[] fondnessProgress = new float[fondnessStatistic.Length];
- private static FloatStatistic[] trustStatistic = { FloatStatistic.CARMEN_TRUST, FloatStatistic.ALEX_TRUST, FloatStatistic.KIKI_TRUST, FloatStatistic.MICHELLE_TRUST, FloatStatistic.KATE_TRUST };
- private static float[] trustProgress = new float[trustStatistic.Length];
- private static FloatStatistic[] recordStatistic = { FloatStatistic.SOUTH_BROKER_RECORD, FloatStatistic.AIRPORT_RUN_RECORD, FloatStatistic.DUKES_BOULEVARD_RECORD, FloatStatistic.SOUTH_ALGONQUIN_RECORD, FloatStatistic.STAR_JUNCTION_RECORD, FloatStatistic.ROAD_TO_BOHAN_RECORD, FloatStatistic.NORTH_ALDERNEY_RECORD, FloatStatistic.ELEVATED_RECORD, FloatStatistic.SOUTH_ALDERNEY_RECORD };
- private static float[] recordProgress = new float[recordStatistic.Length]; // Don't know the format, maybe bugged, need to get to the races to check it I guess.
- private static IntegerStatistic[] vehicleStolenStatistic = { IntegerStatistic.CARS_STOLEN, IntegerStatistic.BIKES_STOLEN, IntegerStatistic.BOATS_STOLEN, IntegerStatistic.HELICOPTERS_STOLEN };
- private static int[] vehiclesStolen = new int[vehicleStolenStatistic.Length];
- private static IntegerStatistic[] racesWonStatistic = { IntegerStatistic.SOUTH_BROKER_WINS, IntegerStatistic.AIRPORT_RUN_WINS, IntegerStatistic.DUKES_BOULEVARD_WINS, IntegerStatistic.SOUTH_ALGONQUIN_WINS, IntegerStatistic.STAR_JUNCTION_WINS, IntegerStatistic.ROAD_TO_BOHAN_WINS, IntegerStatistic.NORTH_ALDERNEY_WINS, IntegerStatistic.ELEVATED_WINS, IntegerStatistic.SOUTH_ALDERNEY_WINS };
- private static int[] racesWon = new int[racesWonStatistic.Length];
- private static IntegerStatistic[] racesFinishedStatistic = { IntegerStatistic.SOUTH_BROKER_RACES, IntegerStatistic.AIRPORT_RUN_RACES, IntegerStatistic.DUKES_BOULEVARD_RACES, IntegerStatistic.SOUTH_ALGONQUIN_RACES, IntegerStatistic.STAR_JUNCTION_RACES, IntegerStatistic.ROAD_TO_BOHAN_RACES, IntegerStatistic.NORTH_ALDERNEY_RACES, IntegerStatistic.ELEVATED_RACES, IntegerStatistic.SOUTH_ALDERNEY_RACES };
- private static int[] racesFinished = new int[racesFinishedStatistic.Length];
- private static IntegerStatistic[] explodedStatistic = { IntegerStatistic.BIKES_EXPLODED, IntegerStatistic.BOATS_EXPLODED, IntegerStatistic.CARS_EXPLODED, IntegerStatistic.HELICOPTERS_EXPLODED, IntegerStatistic.PLANES_EXPLODED };
- private static int[] explodedProgress = new int[explodedStatistic.Length];
- #endregion
- #region Constructor
- static Events()
- {
- eventsTimer = new GTA.Timer(30);
- eventsTimer.Tick += new EventHandler(EventsTimer_Tick);
- eventsTimer.Start();
- //localPlayer = Game.LocalPlayer;
- //localCharacter = Game.LocalPlayer.Character;
- #region Statistics
- for (int i = 0; i < missionStatistic.Length; i++)
- {
- missionProgress[i] = Game.GetFloatStatistic(missionStatistic[i]);
- }
- for (int i = 0; i < respectStatistic.Length; i++)
- {
- respectProgress[i] = Game.GetFloatStatistic(respectStatistic[i]);
- }
- for (int i = 0; i < likeStatistic.Length; i++)
- {
- likeProgress[i] = Game.GetFloatStatistic(likeStatistic[i]);
- }
- for (int i = 0; i < fondnessStatistic.Length; i++)
- {
- fondnessProgress[i] = Game.GetFloatStatistic(fondnessStatistic[i]);
- }
- for (int i = 0; i < trustStatistic.Length; i++)
- {
- trustProgress[i] = Game.GetFloatStatistic(trustStatistic[i]);
- }
- for (int i = 0; i < recordStatistic.Length; i++)
- {
- recordProgress[i] = Game.GetFloatStatistic(recordStatistic[i]);
- }
- for (int i = 0; i < vehicleStolenStatistic.Length; i++)
- {
- vehiclesStolen[i] = Game.GetIntegerStatistic(vehicleStolenStatistic[i]);
- }
- for (int i = 0; i < racesWonStatistic.Length; i++)
- {
- racesWon[i] = Game.GetIntegerStatistic(racesWonStatistic[i]);
- }
- for (int i = 0; i < racesFinishedStatistic.Length; i++)
- {
- racesFinished[i] = Game.GetIntegerStatistic(racesFinishedStatistic[i]);
- }
- for (int i = 0; i < explodedStatistic.Length; i++)
- {
- explodedProgress[i] = Game.GetIntegerStatistic(explodedStatistic[i]);
- }
- payAndSprayPaid = Game.GetFloatStatistic(FloatStatistic.SPENT_ON_PAY_N_SPRAY);
- clothesBought = Game.GetFloatStatistic(FloatStatistic.SPENT_BUYING_CLOTHES);
- foodBought = Game.GetFloatStatistic(FloatStatistic.SPENT_ON_FOOD);
- taxisPaidFor = Game.GetFloatStatistic(FloatStatistic.SPENT_ON_TAXIS);
- daysPassed = Game.GetIntegerStatistic(IntegerStatistic.DAYS_PASSED);
- vehiclesExported = Game.GetIntegerStatistic(IntegerStatistic.VEHICLES_EXPORTED);
- pigeonsExterminated = Game.GetIntegerStatistic(IntegerStatistic.PIGEONS_EXTERMINATED);
- timesDrunk = Game.GetIntegerStatistic(IntegerStatistic.TIMES_GOT_DRUNK);
- stuntJumpsCompleted = Game.GetIntegerStatistic(IntegerStatistic.STUNT_JUMPS_COMPLETED);
- stuntJumpsFound = Game.GetIntegerStatistic(IntegerStatistic.STUNT_JUMPS_FOUND);
- //racesWon = Game.GetIntegerStatistic(IntegerStatistic.NUMBER_OF_RACES_WON);
- //racesLost = Game.GetIntegerStatistic(IntegerStatistic.NUMBER_OF_RACES_LOST);
- //PIGEONS_EXTERMINATED = 361,
- #endregion
- if (localPlayer.isActive)
- {
- timesArrested = Game.GetIntegerStatistic(IntegerStatistic.TIMES_BUSTED); //STARS_ATTAINED = 278, //STARS_EVADED = 279,
- timesDied = Game.GetIntegerStatistic(IntegerStatistic.TIMES_DIED);
- weaponsPickedUp = Game.GetIntegerStatistic(IntegerStatistic.WEAPONS_PICKED_UP);
- missionsCompleted = Game.GetIntegerStatistic(IntegerStatistic.MISSIONS_PASSED);
- missionsFailed = Game.GetIntegerStatistic(IntegerStatistic.MISSIONS_FAILED);
- gameProgress = Game.GetFloatStatistic(FloatStatistic.GAME_PROGRESS);
- sentEmails = Game.GetIntegerStatistic(IntegerStatistic.EMAILS_SENT);
- receivedEmails = Game.GetIntegerStatistic(IntegerStatistic.EMAILS_RECEIVED);
- firstAidCollected = Game.GetIntegerStatistic(IntegerStatistic.FIRST_AID_COLLECTED);
- pedsKilled = Game.GetIntegerStatistic(IntegerStatistic.PEOPLE_KILLED);
- vehicleFlips = Game.GetIntegerStatistic(IntegerStatistic.FLIPS_DONE_IN_A_VEHICLE);
- headshotKills = Game.GetIntegerStatistic(IntegerStatistic.KILLS_BY_HEADSHOTS);
- tiresPopped = Game.GetIntegerStatistic(IntegerStatistic.TIRES_POPPED_BY_GUNSHOT);
- bridgesFlownUnder = Game.GetIntegerStatistic(IntegerStatistic.NUMBER_OF_BRIDGES_FLOWN_UNDER);
- wantedLevel = localPlayer.WantedLevel;
- weaponAmmo = localCharacter.Weapons.Current.Ammo;
- playerHealth = localCharacter.Health;
- playerMoney = localPlayer.Money;
- playerClimbing = GTA.Native.Function.Call<bool>("IS_PED_CLIMBING", localCharacter);
- playerSwimming = localCharacter.isSwimming;
- playerCurrentWeapon = localCharacter.Weapons.Current;
- playerPedTarget = localPlayer.GetTargetedPed();
- playerPressingHorn = localPlayer.isPressingHorn;
- playerIsRagdoll = localCharacter.isRagdoll;
- playerShooting = localCharacter.isShooting;
- playerInVehicle = localCharacter.isInVehicle();
- if (playerInVehicle)
- {
- playerVehicleHealth = localCharacter.CurrentVehicle.Health;
- playerLastVehicle = localCharacter.CurrentVehicle;
- sirenActive = localCharacter.CurrentVehicle.SirenActive;
- }
- else
- {
- playerVehicleHealth = 0f;
- playerLastVehicle = null;
- sirenActive = false;
- }
- }
- else
- {
- // TODO: Reset events etc.
- }
- }
- #endregion
- #region Delegates
- public delegate void HealthChangedEvent(float newHealth, float oldHealth);
- public delegate void MoneyChangedEvent(int newAmount, int oldAmount);
- public delegate void WeaponChangedEvent(Weapon newWeapon, Weapon oldWeapon);
- public delegate void VehicleChangedEvent(Vehicle vehicle);
- public delegate void WantedLevelChangedEvent(int wantedLevel);
- public delegate void JackedEvent(Vehicle vehicle);
- public delegate void ArrestedEvent(int wantedLevel);
- public delegate void ClimbingEvent(Vector3 position);
- public delegate void WaterEvent(Vector3 position);
- public delegate void MissionEvent();
- public delegate void PedGunTargetEvent(Ped ped, Weapon weapon);
- public delegate void PlayerMeleeEvent();
- public delegate void HornPressEvent(); // Maybe add duration ?
- public delegate void PlayerRagdolEvent(); // Anim changed event ?
- public delegate void PlayerShootEvent(Weapon weapon, int newAmmo, int oldAmmo); // Maybe switch this up to not use ammo or missed hit...? (integer) //BULLETS_FIRED = 287, //BULLETS_HIT = 288
- public delegate void DeathEvent(Vector3 position);
- public delegate void GameProgessEvent(float newProgress, float oldProgress); // What is: //TOTAL_PROGRESS = 110, ??
- public delegate void MissionProgressEvent(FloatStatistic mission, float newProgress, float oldProgress);
- public delegate void RespectChangedEvent(FloatStatistic respect, float newRespect, float oldRespect);
- public delegate void LikeChangedEvent(FloatStatistic like, float newRespect, float oldRespect);
- public delegate void FondnessChangedEvent(FloatStatistic fondness, float newFondness, float oldFondness);
- public delegate void TrustChangedEvent(FloatStatistic trust, float newTrust, float oldTrust);
- public delegate void RecordChangedEvent(FloatStatistic record, float newRecord, float oldRecord);
- public delegate void PayAndSprayEvent(int spent); // Only fixing vehicle damage (paying money) will fire this event! (//PAY_N_SPRAY_VISITS = 282, what is this?)
- public delegate void BuyClothesEvent(int spent, int total); // ^^
- public delegate void BuyFoodEvent(int spent, int total);
- public delegate void PaidForTaxiEvent(int spent); // Maybe add total?
- public delegate void DayPassedEvent(int days);
- public delegate void VehicleExportedEvent(Model model, int total);
- public delegate void VehicleStolenEvent(Vehicle vehicle, int type);
- public delegate void RaceFinishedEvent(Race race, bool won, int total); //public delegate void RaceFinishedEvent(int race, bool won, int total);
- public delegate void PigeonEvent(int total);
- public delegate void DrunkEvent(Vector3 position);
- public delegate void SirenEvent();
- public delegate void StuntJumpEvent(Vector3 position);
- public delegate void PhotoTakenEvent();
- public delegate void SaveEvent();
- public delegate void TextReceivedEvent();
- public delegate void WeaponPickUpEvent();
- public delegate void EmailEvent();
- public delegate void FirstAidCollectedEvent();
- public delegate void VehicleExplodedEvent(VehicleType vehicleType);
- public delegate void PedKilledEvent();
- public delegate void VehicleFlipEvent(Vehicle currentVehicle);
- public delegate void HeadshotKillEvent();
- public delegate void TirePoppedEvent();
- public delegate void FlyUnderBridgeEvent();
- public delegate void SpawnEvent(Vector3 position);
- //BOWLING_DEFEATS
- //BOWLING_DRAWS
- //BOWLING_HIGH_SCORE
- //BOWLING_PERFECTS
- //BOWLING_SPARES
- //BOWLING_STRIKES
- //BOWLING_WINS
- //BURGERS_EATEN
- //CARS_SOLD_TO_STEVIE
- //DARTS_BULLSEYE
- //DARTS_DEFEATS
- //DARTS_WINS
- //ENEMY_GANG_MEMBERS_KILLED
- //GIRLS_DUMPED
- //HOTDOGS_EATEN
- //PROSTITUTE_VISITS
- #endregion
- #region Events
- public static event DrunkEvent OnPlayerGetDrunk = null;
- public static event PigeonEvent OnPlayerExterminatedPigeon = null;
- public static event RaceFinishedEvent OnPlayerCompleteRace = null;
- public static event VehicleStolenEvent OnPlayerStealVehicle = null;
- public static event DayPassedEvent OnDayPassed = null;
- public static event GameProgessEvent OnGameProgressChanged = null;
- public static event MissionProgressEvent OnMissionProgressChanged = null;
- public static event RespectChangedEvent OnPlayerRespectChanged = null;
- public static event LikeChangedEvent OnPlayerLikeChanged = null;
- public static event FondnessChangedEvent OnPlayerFondnessChanged = null;
- public static event TrustChangedEvent OnPlayerTrustChanged = null;
- public static event RecordChangedEvent OnPlayerRaceRecordChanged = null;
- public static event PayAndSprayEvent OnPlayerVehicleRepaired = null;
- public static event BuyClothesEvent OnPlayerBoughtClothes = null;
- public static event BuyFoodEvent OnPlayerBoughtFood = null;
- public static event PaidForTaxiEvent OnPlayerPayTaxiFare = null;
- public static event VehicleExportedEvent OnPlayerExportVehicle = null;
- public static event HealthChangedEvent OnPlayerHealthChanged = null, OnVehicleHealthChanged = null;
- public static event VehicleChangedEvent OnPlayerEnterVehicle = null, OnPlayerExitVehicle = null;
- public static event MoneyChangedEvent OnPlayerMoneyChanged = null;
- public static event WeaponChangedEvent OnPlayerWeaponChanged = null;
- public static event JackedEvent OnPlayerJacked = null;
- public static event ArrestedEvent OnPlayerArrested = null;
- public static event DeathEvent OnPlayerDied = null;
- public static event WantedLevelChangedEvent OnPlayerWantedLevelChanged = null;
- public static event ClimbingEvent OnPlayerStartClimbing = null, OnPlayerStopClimbing = null;
- public static event MissionEvent OnPlayerMissionCompleted = null, OnPlayerMissionFailed = null;
- public static event WaterEvent OnPlayerStartSwimming = null, OnPlayerStopSwimming = null;
- public static event PedGunTargetEvent OnPlayerTargetPedWithGun = null;
- public static event PlayerMeleeEvent OnPlayerMelee = null;
- public static event HornPressEvent OnPlayerPressHorn = null;
- public static event PlayerRagdolEvent OnPlayerStartRagdoll = null, OnPlayerStopRagdoll = null;
- public static event PlayerShootEvent OnPlayerShootWeapon = null;
- public static event SirenEvent OnSirenActivate = null, OnSirenDeactivate = null;
- public static event StuntJumpEvent OnStuntJumpCompleted = null, OnStuntJumpFound = null;
- public static event PhotoTakenEvent OnPhotoTaken = null;
- public static event SaveEvent OnSave = null;
- public static event TextReceivedEvent OnTextReceived = null;
- public static event WeaponPickUpEvent OnWeaponPickup = null;
- public static event EmailEvent OnEmailSent = null, OnEmailReceived = null;
- public static event FirstAidCollectedEvent OnFirstAidCollected = null;
- public static event VehicleExplodedEvent OnVehicleExploded = null;
- public static event PedKilledEvent OnPedKilled = null;
- public static event VehicleFlipEvent OnVehicleFlip = null;
- public static event HeadshotKillEvent OnHeadshotKill = null;
- public static event TirePoppedEvent OnTirePopped = null;
- public static event FlyUnderBridgeEvent OnFlyUnderBridge = null;
- public static event SpawnEvent OnSpawn = null;
- #endregion
- #region Private Methods
- private static void EventsTimer_Tick(object sender, EventArgs e)
- {
- if (localPlayer.isActive)
- {
- if (OnPlayerHealthChanged != null)
- {
- if (localCharacter.Health != playerHealth)
- {
- OnPlayerHealthChanged(localCharacter.Health, playerHealth);
- playerHealth = localCharacter.Health;
- }
- }
- if (OnPlayerJacked != null)
- {
- if (GTA.Native.Function.Call<bool>("IS_PED_BEING_JACKED", localCharacter))
- OnPlayerJacked(playerLastVehicle);
- }
- if (OnPlayerArrested != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.TIMES_BUSTED) > timesArrested)
- {
- timesArrested = Game.GetIntegerStatistic(IntegerStatistic.TIMES_BUSTED);
- OnPlayerArrested(localPlayer.WantedLevel);
- }
- }
- if (OnPlayerMissionCompleted != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.MISSIONS_PASSED) > missionsCompleted)
- {
- missionsCompleted = Game.GetIntegerStatistic(IntegerStatistic.MISSIONS_PASSED);
- OnPlayerMissionCompleted();
- }
- }
- if (OnPlayerMissionFailed != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.MISSIONS_FAILED) > missionsFailed)
- {
- missionsFailed = Game.GetIntegerStatistic(IntegerStatistic.MISSIONS_FAILED);
- OnPlayerMissionFailed();
- }
- }
- if (OnPlayerMoneyChanged != null)
- {
- if (localPlayer.Money != playerMoney)
- {
- OnPlayerMoneyChanged(localPlayer.Money, playerMoney);
- playerMoney = localPlayer.Money;
- }
- }
- if (OnPlayerWeaponChanged != null)
- {
- if (localCharacter.Weapons.Current != playerCurrentWeapon)
- {
- //if (localCharacter.Weapons.Current == Weapon.Misc_Object)
- // OnPlayerWeaponChanged(Weapon.Unarmed, playerCurrentWeapon);
- //else
- // OnPlayerWeaponChanged(localCharacter.Weapons.Current, playerCurrentWeapon);
- Weapon currentWeapon = localCharacter.Weapons.Current;
- OnPlayerWeaponChanged(((currentWeapon == Weapon.Misc_Object) ? Weapon.Unarmed : currentWeapon), playerCurrentWeapon);
- playerCurrentWeapon = localCharacter.Weapons.Current;
- }
- }
- if (OnPlayerEnterVehicle != null)
- {
- if (localCharacter.isInVehicle())
- {
- if (!playerInVehicle)
- {
- OnPlayerEnterVehicle(localCharacter.CurrentVehicle);
- playerInVehicle = true;
- playerVehicleHealth = localCharacter.CurrentVehicle.Health;
- playerLastVehicle = localCharacter.CurrentVehicle;
- }
- }
- }
- if (OnPlayerExitVehicle != null)
- {
- if (!localCharacter.isInVehicle())
- {
- if (playerInVehicle)
- {
- OnPlayerExitVehicle(playerLastVehicle);
- playerInVehicle = false;
- }
- }
- }
- if (OnVehicleHealthChanged != null)
- {
- if (localCharacter.isInVehicle())
- {
- if (playerVehicleHealth != localCharacter.CurrentVehicle.Health)
- {
- OnVehicleHealthChanged(localCharacter.CurrentVehicle.Health, playerVehicleHealth);
- playerVehicleHealth = localCharacter.CurrentVehicle.Health;
- }
- }
- else
- playerVehicleHealth = 0f;
- }
- // Maybe use health event for ..? (newHealth < 0)
- // Spawned event?
- if (OnPlayerDied != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.TIMES_DIED) != timesDied)
- {
- OnPlayerDied(localCharacter.Position);
- timesDied = Game.GetIntegerStatistic(IntegerStatistic.TIMES_DIED);
- }
- }
- if (OnPlayerStartClimbing != null)
- {
- if (GTA.Native.Function.Call<bool>("IS_PED_CLIMBING", localCharacter))
- {
- if (!playerClimbing)
- {
- OnPlayerStartClimbing(localCharacter.Position);
- playerClimbing = true;
- }
- }
- }
- if (OnPlayerStopClimbing != null)
- {
- if (!GTA.Native.Function.Call<bool>("IS_PED_CLIMBING", localCharacter))
- {
- if (playerClimbing)
- {
- playerClimbing = false;
- OnPlayerStopClimbing(localCharacter.Position);
- }
- }
- }
- if (OnPlayerStartSwimming != null)
- {
- if (localCharacter.isSwimming)
- {
- if (!playerSwimming)
- {
- OnPlayerStartSwimming(localCharacter.Position);
- playerSwimming = true;
- }
- }
- }
- if (OnPlayerStopSwimming != null)
- {
- if (!localCharacter.isSwimming)
- {
- if (playerSwimming)
- {
- playerSwimming = false;
- OnPlayerStopSwimming(localCharacter.Position);
- }
- }
- }
- if (OnPlayerWantedLevelChanged != null)
- {
- if (localPlayer.WantedLevel != wantedLevel)
- {
- wantedLevel = localPlayer.WantedLevel;
- OnPlayerWantedLevelChanged(wantedLevel);
- }
- }
- if (OnPlayerTargetPedWithGun != null)
- {
- Ped victim = localPlayer.GetTargetedPed();
- if (Game.Exists(victim))
- {
- if (victim != playerPedTarget)
- {
- playerPedTarget = victim;
- OnPlayerTargetPedWithGun(victim, localCharacter.Weapons.Current);
- }
- }
- else
- playerPedTarget = null;
- }
- if (OnPlayerMelee != null)
- {
- if (localCharacter.isInMeleeCombat)
- OnPlayerMelee();
- }
- if (OnPlayerPressHorn != null) // Add start stop or duration ...?
- {
- if (localPlayer.isPressingHorn)
- {
- if (!playerPressingHorn)
- OnPlayerPressHorn();
- playerPressingHorn = true;
- }
- else
- playerPressingHorn = false;
- }
- if (OnPlayerStartRagdoll != null) // Seemes to work, needs more testing for situations like falling etc.
- {
- if (localCharacter.isRagdoll)
- {
- if (!playerIsRagdoll)
- OnPlayerStartRagdoll();
- playerIsRagdoll = true;
- }
- }
- if (OnPlayerStopRagdoll != null)
- {
- if (!localCharacter.isRagdoll)
- {
- if (playerIsRagdoll)
- {
- OnPlayerStopRagdoll();
- playerIsRagdoll = false;
- }
- }
- }
- if (OnPlayerShootWeapon != null) // Misses shots because of timer "interval", shots are damn quick, need to rethink this!
- {
- if (localCharacter.isShooting)
- {
- if (!playerShooting)
- {
- OnPlayerShootWeapon(localCharacter.Weapons.Current, localCharacter.Weapons.Current.Ammo, (weaponAmmo = localCharacter.Weapons.Current.Ammo));
- playerShooting = true;
- }
- }
- else
- playerShooting = false;
- }
- if (OnGameProgressChanged != null) // Need to think about saves here...?
- {
- if (Game.GetFloatStatistic(FloatStatistic.GAME_PROGRESS) > gameProgress)
- {
- OnGameProgressChanged(Game.GetFloatStatistic(FloatStatistic.GAME_PROGRESS), gameProgress);
- gameProgress = Game.GetFloatStatistic(FloatStatistic.GAME_PROGRESS);
- }
- }
- if (OnMissionProgressChanged != null)
- {
- for (int i = 0; i < missionStatistic.Length; i++) //for (int i = 0; i < 19; i++)
- {
- if (Game.GetFloatStatistic(missionStatistic[i]) > missionProgress[i])
- {
- OnMissionProgressChanged(missionStatistic[i], Game.GetFloatStatistic(missionStatistic[i]), missionProgress[i]);
- missionProgress[i] = Game.GetFloatStatistic(missionStatistic[i]);
- }
- }
- }
- if (OnPlayerRespectChanged != null)
- {
- for (int i = 0; i < respectStatistic.Length; i++) //for (int i = 0; i < 6; i++) // No break here, we want all that have changed to be fired not just the one we find first.
- {
- if (Game.GetFloatStatistic(respectStatistic[i]) > respectProgress[i])
- {
- OnPlayerRespectChanged(respectStatistic[i], Game.GetFloatStatistic(respectStatistic[i]), respectProgress[i]);
- respectProgress[i] = Game.GetFloatStatistic(respectStatistic[i]);
- }
- }
- }
- if (OnPlayerLikeChanged != null)
- {
- for (int i = 0; i < likeStatistic.Length; i++) //for (int i = 0; i < 5; i++)
- {
- if (Game.GetFloatStatistic(likeStatistic[i]) > likeProgress[i])
- {
- OnPlayerLikeChanged(likeStatistic[i], Game.GetFloatStatistic(likeStatistic[i]), likeProgress[i]);
- likeProgress[i] = Game.GetFloatStatistic(likeStatistic[i]);
- }
- }
- }
- if (OnPlayerFondnessChanged != null)
- {
- for (int i = 0; i < fondnessStatistic.Length; i++) //for (int i = 0; i < 5; i++)
- {
- if (Game.GetFloatStatistic(fondnessStatistic[i]) > fondnessProgress[i])
- {
- OnPlayerFondnessChanged(fondnessStatistic[i], Game.GetFloatStatistic(fondnessStatistic[i]), fondnessProgress[i]);
- fondnessProgress[i] = Game.GetFloatStatistic(fondnessStatistic[i]);
- }
- }
- }
- if (OnPlayerTrustChanged != null)
- {
- for (int i = 0; i < trustStatistic.Length; i++) //for (int i = 0; i < 5; i++)
- {
- if (Game.GetFloatStatistic(trustStatistic[i]) > trustProgress[i])
- {
- OnPlayerTrustChanged(trustStatistic[i], Game.GetFloatStatistic(trustStatistic[i]), trustProgress[i]);
- trustProgress[i] = Game.GetFloatStatistic(trustStatistic[i]);
- }
- }
- }
- if (OnPlayerRaceRecordChanged != null)
- {
- for (int i = 0; i < recordStatistic.Length; i++) //for (int i = 0; i < 9; i++)
- {
- if (Game.GetFloatStatistic(recordStatistic[i]) > recordProgress[i])
- {
- OnPlayerRaceRecordChanged(recordStatistic[i], Game.GetFloatStatistic(recordStatistic[i]), recordProgress[i]);
- recordProgress[i] = Game.GetFloatStatistic(recordStatistic[i]);
- }
- }
- }
- if (OnPlayerVehicleRepaired != null)
- {
- if (Game.GetFloatStatistic(FloatStatistic.SPENT_ON_PAY_N_SPRAY) > payAndSprayPaid)
- {
- OnPlayerVehicleRepaired((int)Game.GetFloatStatistic(FloatStatistic.SPENT_ON_PAY_N_SPRAY));
- payAndSprayPaid = Game.GetFloatStatistic(FloatStatistic.SPENT_ON_PAY_N_SPRAY);
- }
- }
- if (OnPlayerBoughtClothes != null)
- {
- if (Game.GetFloatStatistic(FloatStatistic.SPENT_BUYING_CLOTHES) > clothesBought)
- {
- OnPlayerBoughtClothes((int)(Game.GetFloatStatistic(FloatStatistic.SPENT_BUYING_CLOTHES) - clothesBought), (int)Game.GetFloatStatistic(FloatStatistic.SPENT_BUYING_CLOTHES));
- clothesBought = Game.GetFloatStatistic(FloatStatistic.SPENT_BUYING_CLOTHES);
- }
- }
- if (OnPlayerBoughtFood != null)
- {
- if (Game.GetFloatStatistic(FloatStatistic.SPENT_ON_FOOD) > foodBought)
- {
- OnPlayerBoughtFood((int)(Game.GetFloatStatistic(FloatStatistic.SPENT_ON_FOOD) - foodBought), (int)Game.GetFloatStatistic(FloatStatistic.SPENT_ON_FOOD));
- foodBought = Game.GetFloatStatistic(FloatStatistic.SPENT_ON_FOOD);
- }
- }
- if (OnPlayerPayTaxiFare != null)
- {
- if (Game.GetFloatStatistic(FloatStatistic.SPENT_ON_TAXIS) > taxisPaidFor)
- {
- OnPlayerPayTaxiFare((int)(Game.GetFloatStatistic(FloatStatistic.SPENT_ON_TAXIS) - taxisPaidFor));
- taxisPaidFor = Game.GetFloatStatistic(FloatStatistic.SPENT_ON_TAXIS);
- }
- }
- if (OnDayPassed != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.DAYS_PASSED) > daysPassed)
- {
- OnDayPassed(Game.GetIntegerStatistic(IntegerStatistic.DAYS_PASSED));
- daysPassed = Game.GetIntegerStatistic(IntegerStatistic.DAYS_PASSED);
- }
- }
- if (OnPlayerExportVehicle != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.VEHICLES_EXPORTED) > vehiclesExported)
- {
- if (Game.Exists(playerLastVehicle))
- OnPlayerExportVehicle(playerLastVehicle.Model.ToString(), Game.GetIntegerStatistic(IntegerStatistic.VEHICLES_EXPORTED));
- else
- OnPlayerExportVehicle(" Unavailable ", Game.GetIntegerStatistic(IntegerStatistic.VEHICLES_EXPORTED));
- vehiclesExported = Game.GetIntegerStatistic(IntegerStatistic.VEHICLES_EXPORTED);
- }
- }
- if (OnPlayerStealVehicle != null)
- {
- for (int i = 0; i < vehicleStolenStatistic.Length; i++)
- {
- if (Game.GetIntegerStatistic(vehicleStolenStatistic[i]) > vehiclesStolen[i])
- {
- // Game.Exists() maybe needed and a != null check in the script ...?
- OnPlayerStealVehicle(localCharacter.CurrentVehicle, i);
- vehiclesStolen[i] = Game.GetIntegerStatistic(vehicleStolenStatistic[i]);
- }
- }
- }
- if (OnPlayerCompleteRace != null)
- {
- for (int i = 0; i < racesFinishedStatistic.Length; i++)
- {
- if (Game.GetIntegerStatistic(racesFinishedStatistic[i]) != racesFinished[i])
- {
- //if (Game.GetIntegerStatistic(racesWonStatistic[i]) != racesWon[i])
- // OnPlayerCompleteRace((Race)i, true, Game.GetIntegerStatistic(racesFinishedStatistic[i]));
- //else
- // OnPlayerCompleteRace((Race)i, false, Game.GetIntegerStatistic(racesFinishedStatistic[i]));
- OnPlayerCompleteRace((Race)i, (Game.GetIntegerStatistic(racesWonStatistic[i]) > racesWon[i]), Game.GetIntegerStatistic(racesFinishedStatistic[i]));
- racesFinished[i] = Game.GetIntegerStatistic(racesFinishedStatistic[i]);
- racesWon[i] = Game.GetIntegerStatistic(racesWonStatistic[i]);
- }
- }
- }
- if (OnPlayerExterminatedPigeon != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.PIGEONS_EXTERMINATED) != pigeonsExterminated)
- {
- OnPlayerExterminatedPigeon(Game.GetIntegerStatistic(IntegerStatistic.PIGEONS_EXTERMINATED));
- pigeonsExterminated = Game.GetIntegerStatistic(IntegerStatistic.PIGEONS_EXTERMINATED);
- }
- }
- if (OnPlayerGetDrunk != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.TIMES_GOT_DRUNK) != timesDrunk)
- {
- OnPlayerGetDrunk(localCharacter.Position); // params...?
- timesDrunk = Game.GetIntegerStatistic(IntegerStatistic.TIMES_GOT_DRUNK);
- }
- }
- if (OnSirenActivate != null)
- {
- if (localCharacter.isInVehicle())
- {
- if (localCharacter.CurrentVehicle.SirenActive)
- {
- if (!sirenActive)
- OnSirenActivate();
- sirenActive = true;
- }
- }
- }
- if (OnSirenDeactivate != null)
- {
- if (localCharacter.isInVehicle())
- {
- if (!localCharacter.CurrentVehicle.SirenActive)
- {
- if (sirenActive)
- {
- OnSirenDeactivate();
- sirenActive = false;
- }
- }
- }
- }
- if (OnStuntJumpCompleted != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.STUNT_JUMPS_COMPLETED) > stuntJumpsCompleted)
- {
- OnStuntJumpCompleted(localCharacter.Position);
- stuntJumpsCompleted = Game.GetIntegerStatistic(IntegerStatistic.STUNT_JUMPS_COMPLETED);
- }
- }
- if (OnStuntJumpFound != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.STUNT_JUMPS_FOUND) > stuntJumpsFound)
- {
- OnStuntJumpFound(localCharacter.Position);
- stuntJumpsFound = Game.GetIntegerStatistic(IntegerStatistic.STUNT_JUMPS_FOUND);
- }
- }
- if (OnPhotoTaken != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.PHOTOS_TAKEN) > photosTaken)
- {
- OnPhotoTaken();
- photosTaken = Game.GetIntegerStatistic(IntegerStatistic.PHOTOS_TAKEN);
- }
- }
- if (OnSave != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.SAVES_MADE) > savesMade)
- {
- OnSave();
- savesMade = Game.GetIntegerStatistic(IntegerStatistic.SAVES_MADE);
- }
- }
- if (OnTextReceived != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.TEXTS_RECEIVED) > textsReceived)
- {
- OnTextReceived();
- textsReceived = Game.GetIntegerStatistic(IntegerStatistic.TEXTS_RECEIVED);
- }
- }
- if (OnWeaponPickup != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.WEAPONS_PICKED_UP) > weaponsPickedUp)
- {
- OnWeaponPickup();
- weaponsPickedUp = Game.GetIntegerStatistic(IntegerStatistic.WEAPONS_PICKED_UP);
- }
- }
- if (OnEmailSent != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.EMAILS_SENT) > sentEmails)
- {
- OnEmailSent();
- sentEmails = Game.GetIntegerStatistic(IntegerStatistic.EMAILS_SENT);
- }
- }
- if (OnEmailReceived != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.EMAILS_RECEIVED) > receivedEmails)
- {
- OnEmailReceived();
- receivedEmails = Game.GetIntegerStatistic(IntegerStatistic.EMAILS_RECEIVED);
- }
- }
- if (OnFirstAidCollected != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.FIRST_AID_COLLECTED) > firstAidCollected)
- {
- OnFirstAidCollected();
- firstAidCollected = Game.GetIntegerStatistic(IntegerStatistic.FIRST_AID_COLLECTED);
- }
- }
- if (OnVehicleExploded != null)
- {
- for (int i = 0; i < explodedStatistic.Length; i++)
- {
- if (Game.GetIntegerStatistic(explodedStatistic[i]) > explodedProgress[i])
- {
- OnVehicleExploded((VehicleType)explodedStatistic[i]);
- explodedProgress[i] = Game.GetIntegerStatistic(explodedStatistic[i]);
- }
- }
- }
- if (OnPedKilled != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.PEOPLE_KILLED) > pedsKilled)
- {
- OnPedKilled();
- pedsKilled = Game.GetIntegerStatistic(IntegerStatistic.PEOPLE_KILLED);
- }
- }
- if (OnVehicleFlip != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.FLIPS_DONE_IN_A_VEHICLE) > vehicleFlips)
- {
- OnVehicleFlip(localCharacter.CurrentVehicle);
- vehicleFlips = Game.GetIntegerStatistic(IntegerStatistic.FLIPS_DONE_IN_A_VEHICLE);
- }
- }
- if (OnHeadshotKill != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.KILLS_BY_HEADSHOTS) > headshotKills)
- {
- OnHeadshotKill();
- headshotKills = Game.GetIntegerStatistic(IntegerStatistic.KILLS_BY_HEADSHOTS);
- }
- }
- if (OnTirePopped != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.TIRES_POPPED_BY_GUNSHOT) > tiresPopped)
- {
- OnTirePopped();
- tiresPopped = Game.GetIntegerStatistic(IntegerStatistic.TIRES_POPPED_BY_GUNSHOT);
- }
- }
- if (OnFlyUnderBridge != null)
- {
- if (Game.GetIntegerStatistic(IntegerStatistic.NUMBER_OF_BRIDGES_FLOWN_UNDER) > bridgesFlownUnder)
- {
- OnFlyUnderBridge();
- bridgesFlownUnder = Game.GetIntegerStatistic(IntegerStatistic.NUMBER_OF_BRIDGES_FLOWN_UNDER);
- }
- }
- }
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement