Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- //
- // SAFEPOINTS - LOSE YOUR WANTED STARS v1.3 [C#]
- // MADE BY CodeMunk
- //
- // THIS IS MY VERY FIRST MOD SO THE SOURCE CODE IS ACCORDINGLY NOT HIGH QUALITY.
- // I HAVE LEFT COMMENTS EVERYWHERE IN THE CODE SO THAT BEGINNERS CAN FIND THEIR WAY AROUND BETTER.
- // HAVE FUN EXPERIMENTING AROUND
- //
- // PERMISSION:
- // ANYONE CAN USE THIS SOURCE CODE TO WRITE THEIR OWN MOD. IF YOU DECIDE TO UPLOAD THIS, PLEASE GIVE ME CREDITS.
- //
- //
- using System;
- using GTA; //Install "ScriptHookV2" via NuGet
- using GTA.Math; //Otherwise you dont need any further references
- using GTA.Native;
- namespace SafePoints
- {
- public class SafePoints : Script
- {
- // The coordinates of the individual points are each stored in a variable
- // Simply copy paste a cwXCoord and fill it with the coordinates of a point you have chosen.
- Vector3 cw1Coord = new Vector3(135f, -1050f, 28f), //Pillbox Hill
- cw2Coord = new Vector3(964f, -1856f, 30f), //San Andreas
- cw3Coord = new Vector3(-676f, 902f, 230f), //Vinewood Mid
- cw4Coord = new Vector3(147f, 320f, 111f), //Vinewoods Hills
- cw5Coord = new Vector3(259f, 2587f, 44f), //Harmony
- cw6Coord = new Vector3(-1359f, -757f, 21f), //Del Perro
- cw7Coord = new Vector3(-459f, -2283f, 6.600f), //Elysian Island
- cw8Coord = new Vector3(1341.673f, 4319.541f, 37f), //Galilee
- cw9Coord = new Vector3(3804f, 4440f, 3f), //San-Chianski / Catfish View
- cw10Coord = new Vector3(280f, 6801f, 14.715f), //Paleto Bay
- cw11Coord = new Vector3(-1133f, 4964f, 220f), //Chiliad-Mountain
- cw12Coord = new Vector3(-2353f, 263f, 164f); //Pacific Bluffs
- // These are the integer where we will store the amount of money you specify in the .ini file
- readonly int moneyToTake, moneyToTake2, moneyToTake3, moneyToTake4, moneyToTake5;
- // Here we declare the config file (.ini)
- ScriptSettings config;
- // Here we declare the blips (the round things on the map)
- Blip loc1Blip, loc2Blip, loc3Blip, loc4Blip, loc5Blip, loc6Blip, loc7Blip, loc8Blip, loc9Blip, loc10Blip, loc11Blip, loc12Blip;
- readonly int checkpoint1, checkpoint2, checkpoint3, checkpoint4, checkpoint5, checkpoint6, checkpoint7, checkpoint8,
- checkpoint9, checkpoint10, checkpoint11, checkpoint12;
- public SafePoints()
- {
- // Here we call the config file and save the data in our money integer
- config = ScriptSettings.Load("scripts\\SafePoints.ini");
- moneyToTake = Settings.GetValue<int>("SETTINGS", "MONEY_WANTED_1", 2000);
- moneyToTake2 = Settings.GetValue<int>("SETTINGS", "MONEY_WANTED_2", 3000);
- moneyToTake3 = Settings.GetValue<int>("SETTINGS", "MONEY_WANTED_3", 5000);
- moneyToTake4 = Settings.GetValue<int>("SETTINGS", "MONEY_WANTED_4", 7500);
- moneyToTake5 = Settings.GetValue<int>("SETTINGS", "MONEY_WANTED_5", 10000);
- // Here you create and configure the blips to be displayed on the map
- loc1Blip = World.CreateBlip(cw1Coord);
- loc2Blip = World.CreateBlip(cw2Coord);
- loc3Blip = World.CreateBlip(cw3Coord);
- loc4Blip = World.CreateBlip(cw4Coord);
- loc5Blip = World.CreateBlip(cw5Coord);
- loc6Blip = World.CreateBlip(cw6Coord);
- loc7Blip = World.CreateBlip(cw7Coord);
- loc8Blip = World.CreateBlip(cw8Coord);
- loc9Blip = World.CreateBlip(cw9Coord);
- loc10Blip = World.CreateBlip(cw10Coord);
- loc11Blip = World.CreateBlip(cw11Coord);
- loc12Blip = World.CreateBlip(cw12Coord);
- loc1Blip.Scale = 1f;
- loc2Blip.Scale = 1f;
- loc3Blip.Scale = 1f;
- loc4Blip.Scale = 1f;
- loc5Blip.Scale = 1f;
- loc6Blip.Scale = 1f;
- loc7Blip.Scale = 1f;
- loc8Blip.Scale = 1f;
- loc9Blip.Scale = 1f;
- loc10Blip.Scale = 1f;
- loc11Blip.Scale = 1f;
- loc12Blip.Scale = 1f;
- loc1Blip.Sprite = BlipSprite.PolicePlayer;
- loc2Blip.Sprite = BlipSprite.PolicePlayer;
- loc3Blip.Sprite = BlipSprite.PolicePlayer;
- loc4Blip.Sprite = BlipSprite.PolicePlayer;
- loc5Blip.Sprite = BlipSprite.PolicePlayer;
- loc6Blip.Sprite = BlipSprite.PolicePlayer;
- loc7Blip.Sprite = BlipSprite.PolicePlayer;
- loc8Blip.Sprite = BlipSprite.PolicePlayer;
- loc9Blip.Sprite = BlipSprite.PolicePlayer;
- loc10Blip.Sprite = BlipSprite.PolicePlayer;
- loc11Blip.Sprite = BlipSprite.PolicePlayer;
- loc12Blip.Sprite = BlipSprite.PolicePlayer;
- loc1Blip.IsShortRange = true;
- loc2Blip.IsShortRange = true;
- loc3Blip.IsShortRange = true;
- loc4Blip.IsShortRange = true;
- loc5Blip.IsShortRange = true;
- loc6Blip.IsShortRange = true;
- loc7Blip.IsShortRange = true;
- loc8Blip.IsShortRange = true;
- loc9Blip.IsShortRange = true;
- loc10Blip.IsShortRange = true;
- loc11Blip.IsShortRange = true;
- loc12Blip.IsShortRange = true;
- loc1Blip.Name = "SafePoint";
- loc2Blip.Name = "SafePoint";
- loc3Blip.Name = "SafePoint";
- loc4Blip.Name = "SafePoint";
- loc5Blip.Name = "SafePoint";
- loc6Blip.Name = "SafePoint";
- loc7Blip.Name = "SafePoint";
- loc8Blip.Name = "SafePoint";
- loc9Blip.Name = "SafePoint";
- loc10Blip.Name = "SafePoint";
- loc11Blip.Name = "SafePoint";
- loc12Blip.Name = "SafePoint";
- // Here we create the cylinders into which you must enter/drive to lose your wanted level (each with the individual coordinates)
- checkpoint1 = Function.Call<int>(Hash.CREATE_CHECKPOINT, 45, cw1Coord.X, cw1Coord.Y, cw1Coord.Z, cw1Coord.X, cw1Coord.Y,
- cw1Coord.Z, 1.0, 255, 255, 0, 150, 0);
- checkpoint2 = Function.Call<int>(Hash.CREATE_CHECKPOINT, 45, cw2Coord.X, cw2Coord.Y, cw2Coord.Z, cw2Coord.X, cw2Coord.Y,
- cw2Coord.Z, 1.0, 255, 255, 0, 150, 0);
- checkpoint3 = Function.Call<int>(Hash.CREATE_CHECKPOINT, 45, cw3Coord.X, cw3Coord.Y, cw3Coord.Z, cw3Coord.X, cw3Coord.Y,
- cw3Coord.Z, 1.0, 255, 255, 0, 150, 0);
- checkpoint4 = Function.Call<int>(Hash.CREATE_CHECKPOINT, 45, cw4Coord.X, cw4Coord.Y, cw4Coord.Z, cw4Coord.X, cw4Coord.Y,
- cw4Coord.Z, 1.0, 255, 255, 0, 150, 0);
- checkpoint5 = Function.Call<int>(Hash.CREATE_CHECKPOINT, 45, cw5Coord.X, cw5Coord.Y, cw5Coord.Z, cw5Coord.X, cw5Coord.Y,
- cw5Coord.Z, 1.0, 255, 255, 0, 150, 0);
- checkpoint6 = Function.Call<int>(Hash.CREATE_CHECKPOINT, 45, cw6Coord.X, cw6Coord.Y, cw6Coord.Z, cw6Coord.X, cw6Coord.Y,
- cw6Coord.Z, 1.0, 255, 255, 0, 150, 0);
- checkpoint7 = Function.Call<int>(Hash.CREATE_CHECKPOINT, 45, cw7Coord.X, cw7Coord.Y, cw7Coord.Z, cw7Coord.X, cw7Coord.Y,
- cw7Coord.Z, 1.0, 255, 255, 0, 150, 0);
- checkpoint8 = Function.Call<int>(Hash.CREATE_CHECKPOINT, 45, cw8Coord.X, cw8Coord.Y, cw8Coord.Z, cw8Coord.X, cw8Coord.Y,
- cw8Coord.Z, 1.0, 255, 255, 0, 150, 0);
- checkpoint9 = Function.Call<int>(Hash.CREATE_CHECKPOINT, 45, cw9Coord.X, cw9Coord.Y, cw9Coord.Z, cw9Coord.X, cw9Coord.Y,
- cw9Coord.Z, 1.0, 255, 255, 0, 150, 0);
- checkpoint10 = Function.Call<int>(Hash.CREATE_CHECKPOINT, 45, cw10Coord.X, cw10Coord.Y, cw10Coord.Z, cw10Coord.X,
- cw10Coord.Y, cw10Coord.Z, 1.0, 255, 255, 0, 150, 0);
- checkpoint11 = Function.Call<int>(Hash.CREATE_CHECKPOINT, 45, cw11Coord.X, cw11Coord.Y, cw11Coord.Z, cw11Coord.X,
- cw11Coord.Y, cw11Coord.Z, 1.0, 255, 255, 0, 150, 0);
- checkpoint12 = Function.Call<int>(Hash.CREATE_CHECKPOINT, 45, cw12Coord.X, cw12Coord.Y, cw12Coord.Z, cw12Coord.X,
- cw12Coord.Y, cw12Coord.Z, 1.0, 255, 255, 0, 150, 0);
- // Here we set the height and width of the cylinder
- Function.Call(Hash.SET_CHECKPOINT_CYLINDER_HEIGHT, checkpoint1, 1f, 1f, 1f);
- Function.Call(Hash.SET_CHECKPOINT_CYLINDER_HEIGHT, checkpoint2, 1f, 1f, 1f);
- Function.Call(Hash.SET_CHECKPOINT_CYLINDER_HEIGHT, checkpoint3, 1f, 1f, 1f);
- Function.Call(Hash.SET_CHECKPOINT_CYLINDER_HEIGHT, checkpoint4, 1f, 1f, 1f);
- Function.Call(Hash.SET_CHECKPOINT_CYLINDER_HEIGHT, checkpoint5, 1f, 1f, 1f);
- Function.Call(Hash.SET_CHECKPOINT_CYLINDER_HEIGHT, checkpoint6, 1f, 1f, 1f);
- Function.Call(Hash.SET_CHECKPOINT_CYLINDER_HEIGHT, checkpoint7, 1f, 1f, 1f);
- Function.Call(Hash.SET_CHECKPOINT_CYLINDER_HEIGHT, checkpoint8, 1f, 1f, 1f);
- Function.Call(Hash.SET_CHECKPOINT_CYLINDER_HEIGHT, checkpoint9, 1f, 1f, 1f);
- Function.Call(Hash.SET_CHECKPOINT_CYLINDER_HEIGHT, checkpoint10, 1f, 1f, 1f);
- Function.Call(Hash.SET_CHECKPOINT_CYLINDER_HEIGHT, checkpoint11, 1f, 1f, 1f);
- Function.Call(Hash.SET_CHECKPOINT_CYLINDER_HEIGHT, checkpoint12, 1f, 1f, 1f);
- Interval = 0;
- Tick += SafePoint_Tick;
- }
- // Here we check if the player is 2f away from one of the cylinders. (Can be set to any distance)
- private bool IsCoordNearStation(Vector3 coords)
- {
- return coords.DistanceTo(cw1Coord) < 2f || coords.DistanceTo(cw2Coord) < 2f || coords.DistanceTo(cw3Coord) < 2f ||
- coords.DistanceTo(cw4Coord) < 2f || coords.DistanceTo(cw5Coord) < 2f || coords.DistanceTo(cw6Coord) < 2f ||
- coords.DistanceTo(cw7Coord) < 2f || coords.DistanceTo(cw8Coord) < 2f || coords.DistanceTo(cw9Coord) < 2f ||
- coords.DistanceTo(cw10Coord) < 2f || coords.DistanceTo(cw11Coord) < 2f || coords.DistanceTo(cw12Coord) < 2f;
- }
- private void SafePoint_Tick(object sender, EventArgs e)
- {
- // Here we declare the game character and its position
- Player plr = Game.Player;
- Ped plrPed = plr.Character;
- Vector3 plrPedCoords = plrPed.Position;
- // Here it is checked whether the game character is near a cylinder. If yes then:
- if (IsCoordNearStation(plrPedCoords))
- {
- // The script checks which wanted level it has and executes the appropriate if loop
- if (plr.WantedLevel == 0)
- {
- }
- else
- {
- if (plr.Money >= moneyToTake) // Here is checked if the game character has enough money
- {
- if (plr.WantedLevel == 0)
- {
- }
- else
- {
- if (plr.WantedLevel == 1)
- {
- Game.FadeScreenOut(1500); // Here the screen goes black in 1500 milliseconds
- Wait(2500); // The script waits 2500 milliseconds
- Function.Call(Hash.ADD_TO_CLOCK_TIME, 0, 20, 0); // 20 minutes are added to the in game time
- plr.WantedLevel = 0; //Wanted level is set to 0
- plr.Money -= moneyToTake; // The game character will have the money taken from the account
- Game.FadeScreenIn(2500); // The screen will return to normal in 2500 milliseconds
- Function.Call(Hash.PLAY_MISSION_COMPLETE_AUDIO, "FRANKLIN_BIG_01"); // An in-game audio file is played
- UI.Notify("Wanted level cleared!"); // A pop up message is displayed to the player
- Wait(10); // The script waits 10 milliseconds
- }
- else
- {
- if (plr.WantedLevel == 2)
- {
- Game.FadeScreenOut(1500);
- Wait(2500);
- Function.Call(Hash.ADD_TO_CLOCK_TIME, 0, 20, 0);
- plr.WantedLevel = 0;
- plr.Money -= moneyToTake2;
- Game.FadeScreenIn(2500);
- Function.Call(Hash.PLAY_MISSION_COMPLETE_AUDIO, "FRANKLIN_BIG_01");
- UI.Notify("Wanted level cleared!");
- Wait(10);
- }
- else
- {
- if (plr.WantedLevel == 3)
- {
- Game.FadeScreenOut(1500);
- Wait(2500);
- Function.Call(Hash.ADD_TO_CLOCK_TIME, 0, 20, 0);
- plr.WantedLevel = 0;
- plr.Money -= moneyToTake3;
- Game.FadeScreenIn(2500);
- Function.Call(Hash.PLAY_MISSION_COMPLETE_AUDIO, "FRANKLIN_BIG_01");
- UI.Notify("Wanted level cleared!");
- Wait(10);
- }
- else
- {
- if (plr.WantedLevel == 4)
- {
- Game.FadeScreenOut(1500);
- Wait(2500);
- Function.Call(Hash.ADD_TO_CLOCK_TIME, 0, 20, 0);
- plr.WantedLevel = 0;
- plr.Money -= moneyToTake4;
- Game.FadeScreenIn(2500);
- Function.Call(Hash.PLAY_MISSION_COMPLETE_AUDIO, "FRANKLIN_BIG_01");
- UI.Notify("Wanted level cleared!");
- Wait(10);
- }
- else
- {
- if (plr.WantedLevel == 5)
- {
- Game.FadeScreenOut(1500);
- Wait(2500);
- Function.Call(Hash.ADD_TO_CLOCK_TIME, 0, 20, 0);
- plr.WantedLevel = 0;
- plr.Money -= moneyToTake5;
- Game.FadeScreenIn(2500);
- Function.Call(Hash.PLAY_MISSION_COMPLETE_AUDIO, "FRANKLIN_BIG_01");
- UI.Notify("Wanted level cleared!");
- Wait(10);
- }
- }
- }
- }
- }
- }
- }
- else
- {
- // This pop up message is displayed to the player when the game character does not have enough money
- UI.Notify("You dont have enough cash. Have fun with the police!");
- }
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment