Ragemp-roleplay-skript/vehicle.js
2019-04-16 13:59:07 +02:00

50 lines
No EOL
1.9 KiB
JavaScript

API.onPlayerEnterVehicle.connect(function (veh) {
var player = API.getLocalPlayer();
if (API.getPlayerVehicleSeat(API.getLocalPlayer()) == -1) {
if (API.getEntitySyncedData(veh, "motor") == false) {
API.triggerServerEvent("triggerVehicleEngine", 0);
API.sendNotification("~w~Drücke ~r~M~w~ um den Motor zu starten!");
} else {
if (API.hasEntitySyncedData(veh, "tank") == true) {
if (API.getEntitySyncedData(veh, "tank") > 0) {
API.triggerServerEvent("triggerVehicleEngine", 1);
}
}
}
}
});
API.onKeyDown.connect(function (sender, e) {
if (e.KeyCode == Keys.M) {
var player = API.getLocalPlayer();
if (API.getPlayerVehicleSeat(player) == -1) {
var veh = API.getPlayerVehicle(player);
if (API.hasEntitySyncedData(veh, "tank") == true) {
if (API.getEntitySyncedData(veh, "tank") > 0) {
if (API.getEntitySyncedData(veh, "motor") == false) {
API.triggerServerEvent("triggerVehicleEngine", 1);
API.setEntitySyncedData(veh, "motor", true);
} else {
API.triggerServerEvent("triggerVehicleEngine", 0)
API.setEntitySyncedData(veh, "motor", false);
}
} else {
API.sendNotification("Der Tank ist leer!");
}
} else {
if (API.getEntitySyncedData(veh, "motor") == false) {
API.triggerServerEvent("triggerVehicleEngine", 1);
API.setEntitySyncedData(veh, "motor", true);
} else {
API.triggerServerEvent("triggerVehicleEngine", 0)
API.setEntitySyncedData(veh, "motor", false);
}
}
}
}
})