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

48 lines
1.9 KiB
JavaScript

"use strict";
/// <reference path="../types-gtanetwork/index.d.ts" />
var farbmenu = API.createMenu("Farben", "Optionen", 0, 0, 6);
farbmenu.ResetKey(menuControl.Back);
farbmenu.AddItem(API.createMenuItem("~r~Schliessen", "Schliesst das Menu!"));
farbmenu.AddItem(API.createMenuItem("~g~Kaufen", "Fuehrt dich zum Kaufmenu weiter!"));
for (var i = 0; i < 159; i++) {
farbmenu.AddItem(API.createMenuItem("Farbe:" + i, "Keine Beschreibung verfuegbar!"));
}
var kaufmenu = API.createMenu("Kaufen", "Optionen", 0, 0, 6);
kaufmenu.AddItem(API.createMenuItem("~r~Zurueck", "Doch nicht die Farbe?!"));
kaufmenu.AddItem(API.createMenuItem("~g~Kaufen", "Kauft die ausgewaehlte Farbe!"));
var vehicle1 = null;
var lastcolor = null;
API.onServerEventTrigger.connect(function (eventName, args) {
if (eventName == "createColorMenu") {
var vehicle = args[0];
vehicle1 = vehicle;
API.setEntitySyncedData(vehicle, "data:primary_color", API.getVehiclePrimaryColor(vehicle));
API.setEntitySyncedData(vehicle, "data:secondary_color", API.getVehicleSecondaryColor(vehicle));
farbmenu.Visible = true;
}
});
farbmenu.OnItemSelect.connect(function (sendermenu, selectedItem, index) {
if (index == 0) {
farbmenu.Visible = false;
API.triggerServerEvent("unfreeze");
API.triggerServerEvent("ApplyColor", API.getEntitySyncedData(vehicle1, "data:primary_color"));
}
else if (index == 1) {
farbmenu.Visible = false;
kaufmenu.Visible = true;
}
else {
API.triggerServerEvent("ApplyColor", index - 2);
//API.setVehiclePrimaryColor(vehicle1, index - 2);
lastcolor = index - 2;
}
});
kaufmenu.OnItemSelect.connect(function (sendermenu, selectedItem, index) {
if (index == 0) {
farbmenu.Visible = true;
kaufmenu.Visible = false;
}
else if (index == 1) {
API.triggerServerEvent("buyVehicleColor", lastcolor);
}
});