C# Класс GTA_RP.Vehicles.VehicleManager

Class responsible for handling vehicles
Наследование: Singleton
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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

Приватные методы

Метод Описание
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

Описание методов

AddVehicleToDatabase() публичный Метод

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
Результат int

DoesVehicleHandleHaveRPVehicle() публичный Метод

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
Результат bool

GenerateUnusedLicensePlate() публичный Метод

Generates an unused license plate for civilian vehicle
public GenerateUnusedLicensePlate ( ) : string
Результат string

GetNearestVehicle() публичный Метод

Gets nearest vehicle
public GetNearestVehicle ( Vector3 position ) : GTA_RP.Vehicles.RPVehicle
position Vector3 Position for which to get the nearest vehicle
Результат GTA_RP.Vehicles.RPVehicle

GetVehicleForCharacter() публичный Метод

Return the vehicle that the character is currently using
public GetVehicleForCharacter ( Character character ) : GTA_RP.Vehicles.RPVehicle
character Character Character
Результат GTA_RP.Vehicles.RPVehicle

GetVehicleForHandle() публичный Метод

public GetVehicleForHandle ( NetHandle vehicle ) : GTA_RP.Vehicles.RPVehicle
vehicle NetHandle
Результат GTA_RP.Vehicles.RPVehicle

GetVehicleWithId() публичный Метод

Returns a vehicle with id
public GetVehicleWithId ( int id ) : GTA_RP.Vehicles.RPVehicle
id int Vehicle id
Результат GTA_RP.Vehicles.RPVehicle

GetVehiclesForCharacter() публичный Метод

Gets all vehicles that the player owns
public GetVehiclesForCharacter ( Character character ) : List
character Character Character
Результат List

InitializeVehicleManager() публичный Метод

Loads all vehicles from the database and adds them to the array
public InitializeVehicleManager ( ) : void
Результат void

LockVehicle() публичный Метод

Locks/Unlocks the most nearby vehicle if possible
public LockVehicle ( Client client ) : void
client Client
Результат void

LockVehicleWithId() публичный Метод

public LockVehicleWithId ( Character character, int id ) : void
character Character
id int
Результат void

ParkVehicle() публичный Метод

Parks a vehicle with selected id
public ParkVehicle ( Character character, int vehicleId ) : void
character Character
vehicleId int Vehicle id
Результат void

PurchasePark() публичный Метод

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
Результат void

SendUpdatedVehicleToClient() публичный Метод

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
Результат void

SpawnVehicleForCharacter() публичный Метод

Spawns a vehicle for player with certain id
public SpawnVehicleForCharacter ( Character character, int vehicleId ) : void
character Character
vehicleId int Vehicle id
Результат void

SubscribeToVehicleDestroyedEvent() публичный Метод

Subscribes a delegate to vehicle destroyed event
public SubscribeToVehicleDestroyedEvent ( OnVehicleDestroyedDelegate delegateMethod ) : void
delegateMethod OnVehicleDestroyedDelegate Delegate
Результат void

SubscribeToVehicleEnterEvent() публичный Метод

Subscribes a delegate to enter vehicle event
public SubscribeToVehicleEnterEvent ( OnVehicleEnteredDelegate delegateMethod ) : void
delegateMethod OnVehicleEnteredDelegate Delegate
Результат void

SubscribeToVehicleEnterEvent() публичный Метод

public SubscribeToVehicleEnterEvent ( OnVehicleEnteredDelegateCharacter delegateMethod ) : void
delegateMethod OnVehicleEnteredDelegateCharacter
Результат void

SubscribeToVehicleExitEvent() публичный Метод

Subscribes a delegate to exit vehicle event
public SubscribeToVehicleExitEvent ( OnVehicleExitedDelegate delegateMethod ) : void
delegateMethod OnVehicleExitedDelegate Delegate
Результат void

SubscribeToVehicleExitEvent() публичный Метод

public SubscribeToVehicleExitEvent ( OnVehicleExitedDelegateCharacter delegateMethod ) : void
delegateMethod OnVehicleExitedDelegateCharacter
Результат void

TryExitVehicleShop() публичный Метод

Character attempts to exit a vehicle shop
public TryExitVehicleShop ( Character character, int id ) : void
character Character
id int Shop id
Результат void

TryPurchasePark() публичный Метод

Attempts to purchase a parking spot for a vehicle
public TryPurchasePark ( Character character, int vehicleId ) : void
character Character
vehicleId int
Результат void

TryPurchaseVehicle() публичный Метод

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
Результат void

UnsubscribeFromVehicleDestroyedEvent() публичный Метод

Unsubscribes from vehicle destroyed event
public UnsubscribeFromVehicleDestroyedEvent ( OnVehicleDestroyedDelegate delegateMethod ) : void
delegateMethod OnVehicleDestroyedDelegate Delegate
Результат void

UnsubscribeFromVehicleEnterEvent() публичный Метод

Unsubscribes from enter vehicle event
public UnsubscribeFromVehicleEnterEvent ( OnVehicleEnteredDelegate delegateMethod ) : void
delegateMethod OnVehicleEnteredDelegate Delegate
Результат void

UnsubscribeFromVehicleEnterEvent() публичный Метод

public UnsubscribeFromVehicleEnterEvent ( OnVehicleEnteredDelegateCharacter delegateMethod ) : void
delegateMethod OnVehicleEnteredDelegateCharacter
Результат void

UnsubscribeFromVehicleExitEvent() публичный Метод

Unsubscribes from exit vehicle event
public UnsubscribeFromVehicleExitEvent ( OnVehicleExitedDelegate delegateMethod ) : void
delegateMethod OnVehicleExitedDelegate Delegate
Результат void

UnsubscribeFromVehicleExitEvent() публичный Метод

public UnsubscribeFromVehicleExitEvent ( OnVehicleExitedDelegateCharacter delegateMethod ) : void
delegateMethod OnVehicleExitedDelegateCharacter
Результат void

VehicleDestroyedEvent() публичный Метод

Announce destruction of vehicle to subscribers
public VehicleDestroyedEvent ( NetHandle vehicle ) : void
vehicle NetHandle Vehicle handle
Результат void

VehicleEnterEvent() публичный Метод

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
Результат void

VehicleExitEvent() публичный Метод

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
Результат void

VehicleManager() публичный Метод

public VehicleManager ( ) : System.Collections.Generic
Результат System.Collections.Generic