01.11.2014, 19:18
We just released a small little update:
- Added VehicleLifecycleHolder
It is the same as PlayerLifecycleHolder, just with vehicles.
Make sure that you initialize the object, BEFORE you create any vehicles.
Here is how to make one:
At first, you need a Class which will contain all the vehicle data. For example, I will make a class called "VehicleData":
In this class, you can add this like Fuel, engine state, trunk content etc.
Now, you can create Vehicles like normally:
You can access the vehicle data like this:
When you update your artifacts, make sure that the server uses the newest version of them too!
- Added VehicleLifecycleHolder
It is the same as PlayerLifecycleHolder, just with vehicles.
Make sure that you initialize the object, BEFORE you create any vehicles.
Here is how to make one:
At first, you need a Class which will contain all the vehicle data. For example, I will make a class called "VehicleData":
PHP код:
public class VehicleData extends VehicleLifecycleObject {
public VehicleData(EventManager eventManager, Vehicle vehicle) {
super(eventManager, vehicle);
}
@Override
public void onInit() {
}
@Override
public void onDestroy() {
}
public int getFuel() {
return 50;
}
}
PHP код:
private VehicleLifecycleHolder vehicleLifecycleHolder;
....
vehicleLifecycleHolder = new VehicleLifecycleHolder(eventManager);
vehicleLifecycleHolder.registerClass(VehicleData.class);
PHP код:
Vehicle.create(560, x, y, z, 0, 0, 0, 0, 0, -1);
PHP код:
VehicleData vehicleData = vehicleLifecycleHolder.getObject(vehicle, VehicleData.class);
int fuel = vehicleData.getFuel();