Fix veh data class to have defaults

This commit is contained in:
VortrexFTW
2020-09-07 11:33:13 -05:00
parent 5ef636ac93
commit cfdb0533f5

View File

@@ -110,16 +110,51 @@ function initClassTable() {
}, },
vehicleData: class { vehicleData: class {
constructor(vehicleAssoc) { constructor(vehicleAssoc, vehicle = null) {
if(!vehicleAssoc) { // General Info
return; 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 // General Info
this.databaseId = vehicleAssoc["veh_id"]; this.databaseId = vehicleAssoc["veh_id"];
this.server = vehicleAssoc["veh_server"]; this.server = vehicleAssoc["veh_server"];
this.model = vehicleAssoc["veh_model"]; this.model = vehicleAssoc["veh_model"];
this.vehicle = null;
// Ownership // Ownership
this.ownerType = vehicleAssoc["veh_owner_type"]; this.ownerType = vehicleAssoc["veh_owner_type"];
@@ -153,8 +188,7 @@ function initClassTable() {
this.engineDamage = vehicleAssoc["veh_damage_engine"]; this.engineDamage = vehicleAssoc["veh_damage_engine"];
this.visualDamage = vehicleAssoc["veh_damage_visual"]; this.visualDamage = vehicleAssoc["veh_damage_visual"];
this.dirtLevel = vehicleAssoc["veh_dirt_level"]; this.dirtLevel = vehicleAssoc["veh_dirt_level"];
}
this.vehicle = null;
} }
}, },
commandData: class { commandData: class {