C# Class GTA_RP.Vehicles.VehicleManager

Class responsible for handling vehicles
Inheritance: Singleton
Datei anzeigen Open project: sjlehtonen/GTA-RP Class Usage Examples

Public Methods

Method Description
AddVehicleToDatabase ( int ownerId, FactionEnums faction, string model, float parkX, float parkY, float parkZ, float parkRotX, float parkRotY, float parkRotZ, string plateText, int plateStyle, int color1, int color2 ) : int

Creates a new vehicle into the database Used for debugging purposes only!

DoesVehicleHandleHaveRPVehicle ( NetHandle vehicle ) : bool

Checks whether a vehicle has a RPVehicle object So basically if a vehicle is spawned with a command, this will return false

GenerateUnusedLicensePlate ( ) : string

Generates an unused license plate for civilian vehicle

GetNearestVehicle ( Vector3 position ) : GTA_RP.Vehicles.RPVehicle

Gets nearest vehicle

GetVehicleForCharacter ( Character character ) : GTA_RP.Vehicles.RPVehicle

Return the vehicle that the character is currently using

GetVehicleForHandle ( NetHandle vehicle ) : GTA_RP.Vehicles.RPVehicle
GetVehicleWithId ( int id ) : GTA_RP.Vehicles.RPVehicle

Returns a vehicle with id

GetVehiclesForCharacter ( Character character ) : List

Gets all vehicles that the player owns

InitializeVehicleManager ( ) : void

Loads all vehicles from the database and adds them to the array

LockVehicle ( Client client ) : void

Locks/Unlocks the most nearby vehicle if possible

LockVehicleWithId ( Character character, int id ) : void
ParkVehicle ( Character character, int vehicleId ) : void

Parks a vehicle with selected id

PurchasePark ( Character character, GTA_RP.Vehicles.RPVehicle vehicle ) : void

Purchases a parking spot

SendUpdatedVehicleToClient ( Character character, int vehicleId, string licensePlateText, bool spawned ) : void

Sends a message to client that updates his HUD to include a new vehicle

SpawnVehicleForCharacter ( Character character, int vehicleId ) : void

Spawns a vehicle for player with certain id

SubscribeToVehicleDestroyedEvent ( OnVehicleDestroyedDelegate delegateMethod ) : void

Subscribes a delegate to vehicle destroyed event

SubscribeToVehicleEnterEvent ( OnVehicleEnteredDelegate delegateMethod ) : void

Subscribes a delegate to enter vehicle event

SubscribeToVehicleEnterEvent ( OnVehicleEnteredDelegateCharacter delegateMethod ) : void
SubscribeToVehicleExitEvent ( OnVehicleExitedDelegate delegateMethod ) : void

Subscribes a delegate to exit vehicle event

SubscribeToVehicleExitEvent ( OnVehicleExitedDelegateCharacter delegateMethod ) : void
TryExitVehicleShop ( Character character, int id ) : void

Character attempts to exit a vehicle shop

TryPurchasePark ( Character character, int vehicleId ) : void

Attempts to purchase a parking spot for a vehicle

TryPurchaseVehicle ( Character character, int id, string model, int color1, int color2 ) : void

Tries to purchase a vehicle for client Is called from event handler

UnsubscribeFromVehicleDestroyedEvent ( OnVehicleDestroyedDelegate delegateMethod ) : void

Unsubscribes from vehicle destroyed event

UnsubscribeFromVehicleEnterEvent ( OnVehicleEnteredDelegate delegateMethod ) : void

Unsubscribes from enter vehicle event

UnsubscribeFromVehicleEnterEvent ( OnVehicleEnteredDelegateCharacter delegateMethod ) : void
UnsubscribeFromVehicleExitEvent ( OnVehicleExitedDelegate delegateMethod ) : void

Unsubscribes from exit vehicle event

UnsubscribeFromVehicleExitEvent ( OnVehicleExitedDelegateCharacter delegateMethod ) : void
VehicleDestroyedEvent ( NetHandle vehicle ) : void

Announce destruction of vehicle to subscribers

VehicleEnterEvent ( Client client, NetHandle vehicle, int seat ) : void

Announce player entering vehicle to subscribers

VehicleExitEvent ( Client client, NetHandle vehicle, int seat ) : void

Announce player exiting vehicle to subscribers

VehicleManager ( ) : System.Collections.Generic

Private Methods

Method Description
AddVehicleToManager ( int id, int ownerId, FactionEnums faction, string model, float parkX, float parkY, float parkZ, float parkRotX, float parkRotY, float parkRotZ, string plateText, int color1, int color2 ) : void

Adds a vehicle into the vehicle manager

CreateVehicleShop ( int id, Vector3 entrance, Vector3 exit, Vector3 exitRot, Vector3 cameraPos, Vector3 cameraRot, Vector3 charPos, Vector3 vehiclePos, Vector3 vehicleRot ) : void

Creates a new vehicle shop

DoesVehicleExistWithLicensePlate ( String licensePlate ) : Boolean

Checks if vehicle exists with the given license plate

GenerateRandomString ( int length ) : String

Generates a random string with given length

GetVehicleShopWithId ( int id ) : GTA_RP.Vehicles.VehicleShop

Gets vehicle shop with certain id

HasVehicles ( ) : Boolean

Checks whether any vehicles exist

InitializeVehicleInsertId ( ) : void

Initializes the vehicle insert ID

InitializeVehicleShops ( ) : void

Initializes vehicle shops

IsCharacterInVehicle ( Character character, GTA_RP.Vehicles.RPVehicle vehicle ) : bool

Checks if character is in given vehicle

RunVehicleDestroyedEvents ( NetHandle vehicle ) : void

Runs all subscriber methods for vehicle destroyed event

RunVehicleEnterEvents ( Client client, NetHandle vehicle, int seat ) : void

Runs all subscriber methods for enter vehicle event

RunVehicleExitEvents ( Client client, NetHandle vehicle, int seat ) : void

Runs all subscriber methods for exit vehicle event

SendVehicleLockedMessage ( Client client, Boolean locked ) : void

Informs player whether vehicles was locked or unlocked

SetParkingSpotForVehicle ( GTA_RP.Vehicles.RPVehicle vehicle, Vector3 spot, Vector3 spotRot ) : void

Set's new parking spot for vehicle

Method Details

AddVehicleToDatabase() public method

Creates a new vehicle into the database Used for debugging purposes only!
public AddVehicleToDatabase ( int ownerId, FactionEnums faction, string model, float parkX, float parkY, float parkZ, float parkRotX, float parkRotY, float parkRotZ, string plateText, int plateStyle, int color1, int color2 ) : int
ownerId int Id of the owning character
faction FactionEnums Id of the faction if exists, 0 if civilian
model string Vehicle model
parkX float Vehicle park X position
parkY float Vehicle park Y position
parkZ float Vehicle park Z position
parkRotX float Vehicle park X rotation
parkRotY float Vehicle park Y rotation
parkRotZ float Vehicle park Z rotation
plateText string Text of the license plate
plateStyle int Style of the license plate
color1 int Primary color of the vehicle
color2 int Secondary color of the vehicle
return int

DoesVehicleHandleHaveRPVehicle() public method

Checks whether a vehicle has a RPVehicle object So basically if a vehicle is spawned with a command, this will return false
public DoesVehicleHandleHaveRPVehicle ( NetHandle vehicle ) : bool
vehicle NetHandle Vehicle handle
return bool

GenerateUnusedLicensePlate() public method

Generates an unused license plate for civilian vehicle
public GenerateUnusedLicensePlate ( ) : string
return string

GetNearestVehicle() public method

Gets nearest vehicle
public GetNearestVehicle ( Vector3 position ) : GTA_RP.Vehicles.RPVehicle
position Vector3 Position for which to get the nearest vehicle
return GTA_RP.Vehicles.RPVehicle

GetVehicleForCharacter() public method

Return the vehicle that the character is currently using
public GetVehicleForCharacter ( Character character ) : GTA_RP.Vehicles.RPVehicle
character Character Character
return GTA_RP.Vehicles.RPVehicle

GetVehicleForHandle() public method

public GetVehicleForHandle ( NetHandle vehicle ) : GTA_RP.Vehicles.RPVehicle
vehicle NetHandle
return GTA_RP.Vehicles.RPVehicle

GetVehicleWithId() public method

Returns a vehicle with id
public GetVehicleWithId ( int id ) : GTA_RP.Vehicles.RPVehicle
id int Vehicle id
return GTA_RP.Vehicles.RPVehicle

GetVehiclesForCharacter() public method

Gets all vehicles that the player owns
public GetVehiclesForCharacter ( Character character ) : List
character Character Character
return List

InitializeVehicleManager() public method

Loads all vehicles from the database and adds them to the array
public InitializeVehicleManager ( ) : void
return void

LockVehicle() public method

Locks/Unlocks the most nearby vehicle if possible
public LockVehicle ( Client client ) : void
client Client
return void

LockVehicleWithId() public method

public LockVehicleWithId ( Character character, int id ) : void
character Character
id int
return void

ParkVehicle() public method

Parks a vehicle with selected id
public ParkVehicle ( Character character, int vehicleId ) : void
character Character
vehicleId int Vehicle id
return void

PurchasePark() public method

Purchases a parking spot
public PurchasePark ( Character character, GTA_RP.Vehicles.RPVehicle vehicle ) : void
character Character Character who is buying
vehicle GTA_RP.Vehicles.RPVehicle Vehicle for which the parking spot is being bought for
return void

SendUpdatedVehicleToClient() public method

Sends a message to client that updates his HUD to include a new vehicle
public SendUpdatedVehicleToClient ( Character character, int vehicleId, string licensePlateText, bool spawned ) : void
character Character Character to whose client to send
vehicleId int Id of the new vehicle
licensePlateText string Text of the vehicle's license plate
spawned bool Is vehicle spawned
return void

SpawnVehicleForCharacter() public method

Spawns a vehicle for player with certain id
public SpawnVehicleForCharacter ( Character character, int vehicleId ) : void
character Character
vehicleId int Vehicle id
return void

SubscribeToVehicleDestroyedEvent() public method

Subscribes a delegate to vehicle destroyed event
public SubscribeToVehicleDestroyedEvent ( OnVehicleDestroyedDelegate delegateMethod ) : void
delegateMethod OnVehicleDestroyedDelegate Delegate
return void

SubscribeToVehicleEnterEvent() public method

Subscribes a delegate to enter vehicle event
public SubscribeToVehicleEnterEvent ( OnVehicleEnteredDelegate delegateMethod ) : void
delegateMethod OnVehicleEnteredDelegate Delegate
return void

SubscribeToVehicleEnterEvent() public method

public SubscribeToVehicleEnterEvent ( OnVehicleEnteredDelegateCharacter delegateMethod ) : void
delegateMethod OnVehicleEnteredDelegateCharacter
return void

SubscribeToVehicleExitEvent() public method

Subscribes a delegate to exit vehicle event
public SubscribeToVehicleExitEvent ( OnVehicleExitedDelegate delegateMethod ) : void
delegateMethod OnVehicleExitedDelegate Delegate
return void

SubscribeToVehicleExitEvent() public method

public SubscribeToVehicleExitEvent ( OnVehicleExitedDelegateCharacter delegateMethod ) : void
delegateMethod OnVehicleExitedDelegateCharacter
return void

TryExitVehicleShop() public method

Character attempts to exit a vehicle shop
public TryExitVehicleShop ( Character character, int id ) : void
character Character
id int Shop id
return void

TryPurchasePark() public method

Attempts to purchase a parking spot for a vehicle
public TryPurchasePark ( Character character, int vehicleId ) : void
character Character
vehicleId int
return void

TryPurchaseVehicle() public method

Tries to purchase a vehicle for client Is called from event handler
public TryPurchaseVehicle ( Character character, int id, string model, int color1, int color2 ) : void
character Character
id int
model string Vehicle model
color1 int Vehicle color 1
color2 int Vehicle color 2
return void

UnsubscribeFromVehicleDestroyedEvent() public method

Unsubscribes from vehicle destroyed event
public UnsubscribeFromVehicleDestroyedEvent ( OnVehicleDestroyedDelegate delegateMethod ) : void
delegateMethod OnVehicleDestroyedDelegate Delegate
return void

UnsubscribeFromVehicleEnterEvent() public method

Unsubscribes from enter vehicle event
public UnsubscribeFromVehicleEnterEvent ( OnVehicleEnteredDelegate delegateMethod ) : void
delegateMethod OnVehicleEnteredDelegate Delegate
return void

UnsubscribeFromVehicleEnterEvent() public method

public UnsubscribeFromVehicleEnterEvent ( OnVehicleEnteredDelegateCharacter delegateMethod ) : void
delegateMethod OnVehicleEnteredDelegateCharacter
return void

UnsubscribeFromVehicleExitEvent() public method

Unsubscribes from exit vehicle event
public UnsubscribeFromVehicleExitEvent ( OnVehicleExitedDelegate delegateMethod ) : void
delegateMethod OnVehicleExitedDelegate Delegate
return void

UnsubscribeFromVehicleExitEvent() public method

public UnsubscribeFromVehicleExitEvent ( OnVehicleExitedDelegateCharacter delegateMethod ) : void
delegateMethod OnVehicleExitedDelegateCharacter
return void

VehicleDestroyedEvent() public method

Announce destruction of vehicle to subscribers
public VehicleDestroyedEvent ( NetHandle vehicle ) : void
vehicle NetHandle Vehicle handle
return void

VehicleEnterEvent() public method

Announce player entering vehicle to subscribers
public VehicleEnterEvent ( Client client, NetHandle vehicle, int seat ) : void
client Client Client who entered vehicle
vehicle NetHandle Vehicle that client entered into
seat int
return void

VehicleExitEvent() public method

Announce player exiting vehicle to subscribers
public VehicleExitEvent ( Client client, NetHandle vehicle, int seat ) : void
client Client Client who exited vehicle
vehicle NetHandle Vehicle from which client exited
seat int
return void

VehicleManager() public method

public VehicleManager ( ) : System.Collections.Generic
return System.Collections.Generic