1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Threading . Tasks ;
4+ using CitizenFX . Core ;
5+ using CitizenFX . Core . Native ;
6+ using FivePD . API ;
7+ using FivePD . API . Utils ;
8+
9+
10+ namespace CarCallout
11+ {
12+
13+ [ CalloutProperties ( "Bus Pursuit" , "BGHDDevelopment" , "1.1" ) ]
14+ public class BusPursuit : Callout
15+ {
16+ private Vehicle car ;
17+ Ped driver ;
18+ public BusPursuit ( )
19+ {
20+
21+ Random rnd = new Random ( ) ;
22+ float offsetX = rnd . Next ( 100 , 700 ) ;
23+ float offsetY = rnd . Next ( 100 , 700 ) ;
24+
25+ InitInfo ( World . GetNextPositionOnStreet ( Game . PlayerPed . GetOffsetPosition ( new Vector3 ( offsetX , offsetY , 0 ) ) ) ) ;
26+ ShortName = "Bus Pursuit" ;
27+ CalloutDescription = "A bus has been stolen!" ;
28+ ResponseCode = 3 ;
29+ StartDistance = 250f ;
30+ }
31+
32+ public async override void OnStart ( Ped player )
33+ {
34+ base . OnStart ( player ) ;
35+ Random random = new Random ( ) ;
36+ car = await SpawnVehicle ( VehicleHash . Bus , Location , 12 ) ;
37+ driver = await SpawnPed ( RandomUtils . GetRandomPed ( ) , Location + 2 ) ;
38+ driver . SetIntoVehicle ( car , VehicleSeat . Driver ) ;
39+
40+ driver . AlwaysKeepTask = true ;
41+ driver . BlockPermanentEvents = true ;
42+
43+ PlayerData playerData = Utilities . GetPlayerData ( ) ;
44+ string displayName = playerData . DisplayName ;
45+ VehicleData datacar = await Utilities . GetVehicleData ( car . NetworkId ) ;
46+ string vehicleName = datacar . Name ;
47+ Notify ( "~r~[CarCallouts] ~y~Officer ~b~" + displayName + ",~y~ the suspects are driving a " + vehicleName + "!" ) ;
48+
49+ driver . Task . CruiseWithVehicle ( car , 2f , 387 ) ;
50+ car . AttachBlip ( ) ;
51+ driver . AttachBlip ( ) ;
52+ API . AddBlipForEntity ( car . GetHashCode ( ) ) ;
53+ API . AddBlipForEntity ( driver . GetHashCode ( ) ) ;
54+ }
55+
56+ public async override Task OnAccept ( )
57+ {
58+ InitBlip ( ) ;
59+ UpdateData ( ) ;
60+ }
61+
62+ private void Notify ( string message )
63+ {
64+ API . BeginTextCommandThefeedPost ( "STRING" ) ;
65+ API . AddTextComponentSubstringPlayerName ( message ) ;
66+ API . EndTextCommandThefeedPostTicker ( false , true ) ;
67+ }
68+ private void DrawSubtitle ( string message , int duration )
69+ {
70+ API . BeginTextCommandPrint ( "STRING" ) ;
71+ API . AddTextComponentSubstringPlayerName ( message ) ;
72+ API . EndTextCommandPrint ( duration , false ) ;
73+ }
74+ }
75+ }
0 commit comments