Fix veh data class to have defaults
This commit is contained in:
@@ -110,16 +110,51 @@ function initClassTable() {
|
||||
|
||||
},
|
||||
vehicleData: class {
|
||||
constructor(vehicleAssoc) {
|
||||
if(!vehicleAssoc) {
|
||||
return;
|
||||
}
|
||||
constructor(vehicleAssoc, vehicle = null) {
|
||||
// General Info
|
||||
this.databaseId = 0;
|
||||
this.server = serverId;
|
||||
this.model = vehicle.modelIndex;
|
||||
this.vehicle = vehicle;
|
||||
|
||||
// Ownership
|
||||
this.ownerType = AG_VEHOWNER_NONE;
|
||||
this.ownerId = 0;
|
||||
this.buyPrice = 0;
|
||||
this.rentPrice = 0;
|
||||
|
||||
// Position and Rotation
|
||||
this.spawnPosition = vehicle.position;
|
||||
this.spawnRotation = vehicle.heading;
|
||||
|
||||
// Colour Info
|
||||
this.colour1IsRGBA = 0;
|
||||
this.colour2IsRGBA = 0;
|
||||
this.colour3IsRGBA = 0;
|
||||
this.colour4IsRGBA = 0;
|
||||
this.colour1RGBA = toColour(255, 255, 255, 255);
|
||||
this.colour2RGBA = toColour(255, 255, 255, 255);
|
||||
this.colour3RGBA = toColour(255, 255, 255, 255);
|
||||
this.colour4RGBA = toColour(255, 255, 255, 255);
|
||||
this.colour1 = vehicle.colour1 || 1;
|
||||
this.colour2 = vehicle.colour2 || 1;
|
||||
this.colour3 = vehicle.colour3 || 1;
|
||||
this.colour4 = vehicle.colour4 || 1;
|
||||
|
||||
// Vehicle Attributes
|
||||
this.locked = false;
|
||||
this.engine = false;
|
||||
this.lights = false;
|
||||
this.health = 1000;
|
||||
this.engineDamage = 0;
|
||||
this.visualDamage = 0;
|
||||
this.dirtLevel = 0;
|
||||
|
||||
if(vehicleAssoc) {
|
||||
// General Info
|
||||
this.databaseId = vehicleAssoc["veh_id"];
|
||||
this.server = vehicleAssoc["veh_server"];
|
||||
this.model = vehicleAssoc["veh_model"];
|
||||
this.vehicle = null;
|
||||
|
||||
// Ownership
|
||||
this.ownerType = vehicleAssoc["veh_owner_type"];
|
||||
@@ -153,8 +188,7 @@ function initClassTable() {
|
||||
this.engineDamage = vehicleAssoc["veh_damage_engine"];
|
||||
this.visualDamage = vehicleAssoc["veh_damage_visual"];
|
||||
this.dirtLevel = vehicleAssoc["veh_dirt_level"];
|
||||
|
||||
this.vehicle = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
commandData: class {
|
||||
|
||||
Reference in New Issue
Block a user