1279 lines
57 KiB
C#
1279 lines
57 KiB
C#
using GrandTheftMultiplayer.Server;
|
|
using GrandTheftMultiplayer.Shared;
|
|
using GrandTheftMultiplayer.Server.API;
|
|
using GrandTheftMultiplayer.Shared.Math;
|
|
using GrandTheftMultiplayer.Server.Elements;
|
|
using GrandTheftMultiplayer.Server.Constant;
|
|
using MySql.Data.MySqlClient;
|
|
using System;
|
|
using System.Data;
|
|
using System.Threading.Tasks;
|
|
using GrandTheftMultiplayer.Server.Managers;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Roleplay.Vehiclesystem
|
|
{
|
|
class VehicleMain : Script
|
|
{
|
|
|
|
|
|
public static string myConnectionString = "SERVER=185.223.28.49;" + "DATABASE=gtanetwork;" + "UID=fivem;" + "PASSWORD=" + Main.databasepass + ";";
|
|
public static MySqlConnection connection;
|
|
public static MySqlCommand command;
|
|
public static MySqlDataReader reader;
|
|
|
|
|
|
public static int Spoilers = 0;
|
|
public static int intFront_Bumper = 1;
|
|
public static int intRear_Bumper = 2;
|
|
public static int Side_Skirt = 3;
|
|
public static int Exhaust = 4;
|
|
public static int Frame = 5;
|
|
public static int Grille = 6;
|
|
public static int Hood = 7;
|
|
public static int Fender = 8;
|
|
public static int Right_Fender = 9;
|
|
public static int Roof = 10;
|
|
public static int Engine = 11;
|
|
public static int Brakes = 12;
|
|
public static int Transmission = 13;
|
|
public static int Horns = 14;
|
|
public static int Suspension = 15;
|
|
public static int Armor = 16;
|
|
public static int Turbo = 18;
|
|
public static int Xenon = 22;
|
|
public static int Front_Wheels = 23;
|
|
public static int Back_Wheels = 24;
|
|
public static int Plate_holders = 25;
|
|
public static int Trim_Design = 27;
|
|
public static int Ornaments = 28;
|
|
public static int Dial_Design = 30;
|
|
public static int Steering_Wheel = 33;
|
|
public static int Shift_Lever = 34;
|
|
public static int Plaques = 35;
|
|
public static int Hydraulics = 38;
|
|
public static int Livery = 48;
|
|
public static int Plate = 62;
|
|
public static int Colour_1 = 66;
|
|
public static int Colour_2 = 67;
|
|
public static int Window_Tint = 69;
|
|
|
|
|
|
public VehicleMain()
|
|
{
|
|
//EVENTS
|
|
API.onClientEventTrigger += onVehicleFunctions;
|
|
API.onVehicleDeath += onVehicleDead;
|
|
API.onClientEventTrigger += onGasStationUse;
|
|
|
|
//createDBVehicles(); causing desynces
|
|
tanktimer();
|
|
createGasStations();
|
|
API.onEntityEnterColShape += onGasStationEnter;
|
|
API.onClientEventTrigger += onMotor;
|
|
API.onUpdate += onUpdate;
|
|
}
|
|
|
|
|
|
|
|
|
|
public void tanktimer()
|
|
{
|
|
API.delay(1000*28, false, () => {
|
|
foreach (NetHandle veh in API.getAllVehicles())
|
|
{
|
|
if(API.hasEntitySyncedData(veh,"tank") == true)
|
|
{
|
|
if (API.hasEntitySyncedData(veh, "motor") && API.getEntitySyncedData(veh, "motor") == true)
|
|
{
|
|
if(API.getEntitySyncedData(veh, "tank") > 0 && API.getEntitySyncedData(veh,"tank") != null)
|
|
{
|
|
int tank = API.getEntitySyncedData(veh, "tank");
|
|
API.setEntitySyncedData(veh, "tank", tank - 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
public void addTank(Vehicle veh, int amount)
|
|
{
|
|
API.setEntitySyncedData(veh, "tank", Convert.ToInt32(API.getEntitySyncedData(veh, "tank") + amount));
|
|
}
|
|
|
|
public void setTank(Vehicle veh, int amount)
|
|
{
|
|
API.setEntitySyncedData(veh, "tank", Convert.ToInt32(amount));
|
|
}
|
|
|
|
public int getTank(Vehicle veh)
|
|
{
|
|
int tank = 0;
|
|
if(API.hasEntitySyncedData(veh,"tank") == true)
|
|
{
|
|
tank = API.getEntitySyncedData(veh, "tank");
|
|
}
|
|
return tank;
|
|
}
|
|
|
|
|
|
public static int Tankpreis = 2; // 2$
|
|
public const int GasMenu_CALLBACK = 46153;
|
|
public void openGasMenu(Client player)
|
|
{
|
|
if (Tankpreis != 0 && GasMenu_CALLBACK != 0)
|
|
{
|
|
if (player.vehicleSeat == -1)
|
|
{
|
|
object[] argumentList = new object[11];
|
|
argumentList[0] = GasMenu_CALLBACK;
|
|
argumentList[1] = "Tankstelle";
|
|
argumentList[2] = "Optionen:";
|
|
argumentList[3] = true;
|
|
argumentList[4] = 3;
|
|
argumentList[5] = "~b~1% Tanken";
|
|
argumentList[6] = "~g~Voll Tanken";
|
|
argumentList[7] = "~r~Schliessen";
|
|
argumentList[8] = "~y~" + Tankpreis + "$";
|
|
API.triggerClientEvent(player, "menu_handler_create_menu", argumentList);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void onGasStationUse(Client sender, string eventName, object[] arguments)
|
|
{
|
|
if(eventName == "menu_handler_select_item")
|
|
{
|
|
int callback = (int)arguments[0];
|
|
int index = (int)arguments[1];
|
|
if (callback == GasMenu_CALLBACK)
|
|
{
|
|
if (index == 0)
|
|
{
|
|
if (sender.isInVehicle == true)
|
|
{
|
|
if (Environment.MONEY.Money.getBarMoney(sender) >= Tankpreis)
|
|
{
|
|
if (getTank(sender.vehicle) < 100)
|
|
{
|
|
sender.vehicle.freezePosition = true;
|
|
API.delay(1000 * 5, true, () =>
|
|
{
|
|
sender.vehicle.freezePosition = false;
|
|
Environment.MONEY.Money.giveBarMoney(sender, -Tankpreis, API);
|
|
addTank(sender.vehicle, 1);
|
|
});
|
|
}
|
|
}
|
|
else
|
|
{
|
|
API.sendNotificationToPlayer(sender, "Du hast nicht genug Geld dabei!");
|
|
}
|
|
}
|
|
}
|
|
else if (index == 1)
|
|
{
|
|
if (sender.isInVehicle == true)
|
|
{
|
|
int tankfuellung = 100 - getTank(sender.vehicle);
|
|
int preis = tankfuellung * Tankpreis;
|
|
if (Environment.MONEY.Money.getBarMoney(sender) >= preis)
|
|
{
|
|
sender.vehicle.freezePosition = true;
|
|
API.delay(1000 * 5, true, () =>
|
|
{
|
|
Environment.MONEY.Money.giveBarMoney(sender, -preis, API);
|
|
setTank(sender.vehicle, 100);
|
|
sender.vehicle.freezePosition = false;
|
|
});
|
|
}
|
|
else
|
|
{
|
|
API.sendNotificationToPlayer(sender, "Du hast nicht genug Geld dabei!");
|
|
}
|
|
}
|
|
}
|
|
else if (index == 2)
|
|
{
|
|
API.triggerClientEvent(sender, "menu_handler_close_menu");
|
|
sender.vehicle.freezePosition = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void createGasStations()
|
|
{
|
|
new Gas_station(new Vector3(180.4381,-1560.155,29.25));
|
|
new Gas_station(new Vector3(614.2005, 263.85, 103.0894));
|
|
new Gas_station(new Vector3(268.3035, -1268.73, 29.145));
|
|
new Gas_station(new Vector3(-77.21, -1763.109, 29.540));
|
|
new Gas_station(new Vector3(-315, -1474, 30));
|
|
new Gas_station(new Vector3(-521, -1215, 18));
|
|
new Gas_station(new Vector3(820, -1031, 26));
|
|
new Gas_station(new Vector3(-717, -932, 19));
|
|
new Gas_station(new Vector3(-2089, -313, 13));
|
|
new Gas_station(new Vector3(-2552, 2336, 33));
|
|
new Gas_station(new Vector3(176, 6604, 31));
|
|
new Gas_station(new Vector3(1698, 6420, 32));
|
|
new Gas_station(new Vector3(2000, 3774, 32));
|
|
new Gas_station(new Vector3(1788, 3330, 41));
|
|
new Gas_station(new Vector3(-1439, -269, 46));
|
|
new Gas_station(new Vector3(-1653, -3144, 13));
|
|
new Gas_station(new Vector3(263, 2609, 44));
|
|
}
|
|
|
|
public class Gas_station
|
|
{
|
|
public Vector3 Position { get; set; }
|
|
|
|
public Gas_station(Vector3 position)
|
|
{
|
|
Position = position;
|
|
ColShape col = API.shared.createSphereColShape(Position, 3);
|
|
col.setData("Gas_Station", true);
|
|
API.shared.createMarker(0, Position, new Vector3(0, 0, 0), new Vector3(0, 0, 0), new Vector3(1, 1, 1), 185, 255, 0, 0, 0);
|
|
var b = API.shared.createBlip(Position);
|
|
API.shared.setBlipSprite(b, 361);
|
|
API.shared.setBlipColor(b, 1);
|
|
b.scale = 0.5f;
|
|
b.shortRange = true;
|
|
}
|
|
}
|
|
|
|
public DateTime LastAnnounce;
|
|
|
|
private void onUpdate()
|
|
{
|
|
if (DateTime.Now.Subtract(LastAnnounce).TotalSeconds >= 30) //Checks if the time between now and the 'last announce' is more or equal than 15 minutes
|
|
{
|
|
foreach (NetHandle nh in API.getAllVehicles())
|
|
{
|
|
if (API.getEntitySyncedData(nh, "tank") == 0)
|
|
{
|
|
Vehicle veh = API.getEntityFromHandle<Vehicle>(nh);
|
|
if (API.getVehicleEngineStatus(veh) == true)
|
|
{
|
|
API.setVehicleEngineStatus(veh, false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static bool hasPrivateVehicle(Client player)
|
|
{
|
|
bool state = false;
|
|
foreach(NetHandle nh in API.shared.getAllVehicles())
|
|
{
|
|
if(nh != null)
|
|
{
|
|
Vehicle veh = API.shared.getEntityFromHandle<Vehicle>(nh);
|
|
if (veh != null)
|
|
{
|
|
if (API.shared.getEntityData(veh, "besitzer") == player.name)
|
|
{
|
|
state = true;
|
|
}
|
|
else
|
|
{
|
|
state = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return state;
|
|
}
|
|
|
|
public static List<Vehicle> getPrivateVehicles(Client player)
|
|
{
|
|
List<Vehicle> vehlist = new List<Vehicle>();
|
|
if(privates.ContainsKey(player) == true){
|
|
vehlist = privates.Get(player);
|
|
}
|
|
|
|
// PERFOMANCE BOOSTING
|
|
return vehlist;
|
|
}
|
|
|
|
|
|
|
|
private void onGasStationEnter(ColShape colshape, NetHandle entity)
|
|
{
|
|
if(colshape.hasData("Gas_Station") == true && colshape.getData("Gas_Station") == true)
|
|
{
|
|
if (entity != null)
|
|
{
|
|
if (API.getEntityType(entity) == EntityType.Player)
|
|
{
|
|
Client player = API.getPlayerFromHandle(entity);
|
|
if (player.isInVehicle == true)
|
|
{
|
|
openGasMenu(player);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void onMotor(Client sender, string eventName, object[] arguments)
|
|
{
|
|
if (eventName == "triggerVehicleEngine")
|
|
{
|
|
int state = (int)arguments[0];
|
|
NetHandle veh = API.getPlayerVehicle(sender);
|
|
if (state == 0)
|
|
{
|
|
API.setVehicleEngineStatus(veh, false);
|
|
API.setEntitySyncedData(veh, "motor", false);
|
|
}
|
|
else
|
|
{
|
|
API.setVehicleEngineStatus(veh, true);
|
|
API.setEntitySyncedData(veh, "motor", true);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void deletePersonalVehicle(Client player){
|
|
List<NetHandle> fahrzeuge = API.shared.getAllVehicles();
|
|
foreach(NetHandle nh in fahrzeuge){
|
|
if(nh != null){
|
|
Vehicle vh = API.shared.getEntityFromHandle<Vehicle>(nh);
|
|
if(vh != null){
|
|
if(API.shared.getEntityData(vh,"besitzer") == player.name){
|
|
vh.delete();
|
|
privates.Remove(player);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static Dictionary<Client,List<Vehicle>> privates = new Dictionary<Client, List<Vehicle>>();
|
|
public static void loadPrivateVehicles(Client player, API API){
|
|
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
command.CommandText = "SELECT * FROM vehicles WHERE owner = '" + player.name + "'";
|
|
|
|
connection.Open();
|
|
reader = command.ExecuteReader();
|
|
DataTable results = new DataTable();
|
|
results.Load(reader);
|
|
List<Vehicle> list = new List<Vehicle>();
|
|
foreach (DataRow dr in results.Rows)
|
|
{
|
|
string model = Convert.ToString(dr["model"]);
|
|
int spawnx = Convert.ToInt32(dr["spawnx"]);
|
|
int spawny = Convert.ToInt32(dr["spawny"]);
|
|
int spawnz = Convert.ToInt32(dr["spawnz"]);
|
|
int rotation = Convert.ToInt32(dr["rotation"]);
|
|
int garageid = Convert.ToInt32(dr["garageid"]);
|
|
int slot = Convert.ToInt32(dr["slot"]);
|
|
string owner = Convert.ToString(dr["owner"]);
|
|
int id = Convert.ToInt32(dr["ID"]);
|
|
int color = Convert.ToInt32(dr["color"]);
|
|
int color2 = Convert.ToInt32(dr["color2"]);
|
|
int tank = Convert.ToInt32(dr["tank"]);
|
|
string numberplate = Convert.ToString(dr["numberplate"]);
|
|
// TUNINGS
|
|
int spoiler = Convert.ToInt32(dr["Spoiler"]);
|
|
int frontbumper = Convert.ToInt32(dr["FrontBumper"]);
|
|
int rearbumper = Convert.ToInt32(dr["RearBumper"]);
|
|
int sideskirt = Convert.ToInt32(dr["SideSkirt"]);
|
|
int frame = Convert.ToInt32(dr["Frame"]);
|
|
int grille = Convert.ToInt32(dr["Grille"]);
|
|
int hood = Convert.ToInt32(dr["Hood"]);
|
|
int fender = Convert.ToInt32(dr["Fender"]);
|
|
int rightfender = Convert.ToInt32(dr["RightFender"]);
|
|
int roof = Convert.ToInt32(dr["Roof"]);
|
|
int engine = Convert.ToInt32(dr["Engine"]);
|
|
int brakes = Convert.ToInt32(dr["Brakes"]);
|
|
int transmission = Convert.ToInt32(dr["Transmission"]);
|
|
int horn = Convert.ToInt32(dr["Horn"]);
|
|
int suspension = Convert.ToInt32(dr["Suspension"]);
|
|
int armor = Convert.ToInt32(dr["Armor"]);
|
|
int turbo = Convert.ToInt32(dr["Turbo"]);
|
|
int xenon = Convert.ToInt32(dr["Xenon"]);
|
|
int frontwheels = Convert.ToInt32(dr["FrontWheels"]);
|
|
int backwheels = Convert.ToInt32(dr["BackWheels"]);
|
|
int plateholders = Convert.ToInt32(dr["Plateholders"]);
|
|
int trimdesign = Convert.ToInt32(dr["TrimDesign"]);
|
|
int ornaments = Convert.ToInt32(dr["Ornaments"]);
|
|
int dialdesign = Convert.ToInt32(dr["DialDesign"]);
|
|
int steeringwheel = Convert.ToInt32(dr["SteeringWheel"]);
|
|
int shiftlever = Convert.ToInt32(dr["ShiftLever"]);
|
|
int plaques = Convert.ToInt32(dr["Plaques"]);
|
|
int hydraulics = Convert.ToInt32(dr["Hydraulics"]);
|
|
int livery = Convert.ToInt32(dr["Livery"]);
|
|
int plate = Convert.ToInt32(dr["Plate"]);
|
|
int windowtint = Convert.ToInt32(dr["WindowTint"]);
|
|
int exhaust = Convert.ToInt32(dr["Exhaust"]);
|
|
//Vehicle veh = RAPI.MainAPI.createRolePlayVehicle(API.vehicleNameToModel(model),new Vector3(spawnx,spawny,spawnz+1), new Vector3(0,0,rotation),r,g,b,r2,g2,b2,owner);
|
|
Vehicle veh = RAPI.MainAPI.createRolePlayVehicleNonARGB(API.vehicleNameToModel(model), new Vector3(0, 0, 0), new Vector3(0, 0, rotation), owner);
|
|
API.setVehiclePrimaryColor(veh, color);
|
|
API.setVehicleSecondaryColor(veh, color2);
|
|
|
|
API.setEntitySyncedData(veh, "slot", slot);
|
|
API.setEntitySyncedData(veh, "tank", tank);
|
|
API.setEntityData(veh, "id", id);
|
|
|
|
// SETTING TEH MODS
|
|
API.setVehicleMod(veh, Spoilers, spoiler);
|
|
API.setVehicleMod(veh, intFront_Bumper, frontbumper);
|
|
API.setVehicleMod(veh, intRear_Bumper, rearbumper);
|
|
API.setVehicleMod(veh, Side_Skirt, sideskirt);
|
|
API.setVehicleMod(veh, Frame, frame);
|
|
API.setVehicleMod(veh, Grille, grille);
|
|
API.setVehicleMod(veh, Hood, hood);
|
|
API.setVehicleMod(veh, Fender, fender);
|
|
API.setVehicleMod(veh, Exhaust, exhaust);
|
|
API.setVehicleMod(veh, Right_Fender, rightfender);
|
|
API.setVehicleMod(veh, Roof, roof);
|
|
API.setVehicleMod(veh, Engine, engine);
|
|
API.setVehicleMod(veh, Brakes, brakes);
|
|
API.setVehicleMod(veh, Transmission, transmission);
|
|
API.setVehicleMod(veh, Horns, horn);
|
|
API.setVehicleMod(veh, Suspension, suspension);
|
|
API.setVehicleMod(veh, Armor, armor);
|
|
API.setVehicleMod(veh, Turbo, turbo);
|
|
API.setVehicleMod(veh, Xenon, xenon);
|
|
if (backwheels != 0)
|
|
{
|
|
API.setVehicleMod(veh, Back_Wheels, backwheels);
|
|
}
|
|
API.setVehicleMod(veh, Front_Wheels, frontwheels);
|
|
API.setVehicleMod(veh, Plate_holders, plateholders);
|
|
API.setVehicleMod(veh, Trim_Design, trimdesign);
|
|
API.setVehicleMod(veh, Ornaments, ornaments);
|
|
API.setVehicleMod(veh, Dial_Design, dialdesign);
|
|
API.setVehicleMod(veh, Steering_Wheel, steeringwheel);
|
|
API.setVehicleMod(veh, Shift_Lever, shiftlever);
|
|
API.setVehicleMod(veh, Plaques, plaques);
|
|
API.setVehicleMod(veh, Hydraulics, hydraulics);
|
|
API.setVehicleMod(veh, Livery, livery);
|
|
API.setVehicleMod(veh, Window_Tint, windowtint);
|
|
API.setEntityData(veh,"numberplate",numberplate);
|
|
API.setVehicleNumberPlate(veh,numberplate);
|
|
if(list.Contains(veh) != true){
|
|
list.Add(veh);
|
|
}
|
|
}
|
|
if(privates.ContainsValue(list) != true){
|
|
privates.Add(player, list);
|
|
}
|
|
API.consoleOutput("Private Vehicles loaded for " + player.name);
|
|
connection.Close();
|
|
}
|
|
|
|
|
|
|
|
private void onVehicleDead(NetHandle entity)
|
|
{
|
|
|
|
}
|
|
|
|
private void onVehicleFunctions(Client sender, string eventName, object[] arguments)
|
|
{
|
|
if(eventName == "aufabschliessen")
|
|
{
|
|
NetHandle nethandle = (NetHandle) arguments[0];
|
|
Vehicle veh = API.getEntityFromHandle<Vehicle>(nethandle);
|
|
if(API.getEntitySyncedData(veh, "locked") == false)
|
|
{
|
|
|
|
API.setEntitySyncedData(veh, "locked", true);
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
|
|
API.sendNotificationToPlayer(sender, "Fahrzeug ~r~ Abgeschlossen!", true);
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_LIGHTS, sender.vehicle, 3);
|
|
API.delay(1000 * 1, true, () => {
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_LIGHTS, sender.vehicle, 4);
|
|
});
|
|
ClientAPI.playMP3(sender,"sounds//carlock.mp3",false);
|
|
}
|
|
else
|
|
{
|
|
API.setEntitySyncedData(veh, "locked", false);
|
|
API.setVehicleLocked(veh, false);
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 1);
|
|
API.sendNotificationToPlayer(sender, "Fahrzeug ~g~ Aufgeschlossen!", true);
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_LIGHTS, sender.vehicle, 3);
|
|
API.delay(1000 * 1, true, () => {
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_LIGHTS, sender.vehicle, 4);
|
|
});
|
|
ClientAPI.playMP3(sender,"sounds//carlock.mp3",false);
|
|
}
|
|
}
|
|
else if(eventName == "parken")
|
|
{
|
|
NetHandle nethandle = (NetHandle)arguments[0];
|
|
Vehicle vehicle = RAPI.MainAPI.getVehicleFromHandle(API, nethandle);
|
|
parkvehicle(sender, vehicle);
|
|
// VehicleHash vh = API.getEntityModel(vehicle);
|
|
//API.getEntity
|
|
//string displayName = API.getVehicleDisplayName(modelHash);
|
|
API.sendNotificationToPlayer(sender, "Fahrzeug ~g~ geparkt!", true);
|
|
}
|
|
else if(eventName == "respawnen")
|
|
{
|
|
if (Environment.MONEY.Money.hasBarMoney(sender, 500) == true)
|
|
{
|
|
NetHandle nethandle = (NetHandle)arguments[0];
|
|
Vehicle vehicle = RAPI.MainAPI.getVehicleFromHandle(API, nethandle);
|
|
respawnVehicle(sender, vehicle);
|
|
Environment.MONEY.Money.giveBankMoney(sender, -500, API);
|
|
} else
|
|
{
|
|
API.sendNotificationToPlayer(sender, "Du hast nicht genug Geld auf der Hand!");
|
|
}
|
|
} else if(eventName == "openDoor")
|
|
{
|
|
NetHandle nethandle = (NetHandle)arguments[0];
|
|
Vehicle vehicle = RAPI.MainAPI.getVehicleFromHandle(API, nethandle);
|
|
int door = (int)arguments[1];
|
|
if(door != 4)
|
|
{
|
|
API.setVehicleDoorState(vehicle, door, !API.getVehicleDoorState(vehicle, door));
|
|
}
|
|
else
|
|
{
|
|
triggerDoor(vehicle, door);
|
|
}
|
|
|
|
|
|
}
|
|
else if(eventName == "vehiclelock")
|
|
{
|
|
NetHandle ent = (NetHandle)arguments[0];
|
|
Vehicle veh = RAPI.MainAPI.getVehicleFromHandle(API, ent);
|
|
if(API.getEntityData(veh,"Fraktionsfahrzeug") == Fraktionen.Fraktionsmanager.getFraktion(sender))
|
|
{
|
|
if (API.getEntitySyncedData(veh, "locked") == false)
|
|
{
|
|
|
|
API.setEntitySyncedData(veh, "locked", true);
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
|
|
API.sendNotificationToPlayer(sender, "Fahrzeug ~r~ Abgeschlossen!", true);
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_LIGHTS, sender.vehicle, 3);
|
|
API.delay(1000 * 1, true, () => {
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_LIGHTS, sender.vehicle, 4);
|
|
});
|
|
ClientAPI.playMP3(sender,"sounds//carlock.mp3",false);
|
|
}
|
|
else
|
|
{
|
|
API.setEntitySyncedData(veh, "locked", false);
|
|
API.setVehicleLocked(veh, false);
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 1);
|
|
API.sendNotificationToPlayer(sender, "Fahrzeug ~g~ Aufgeschlossen!", true);
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_LIGHTS, sender.vehicle, 3);
|
|
API.delay(1000 * 1, true, () => {
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_LIGHTS, sender.vehicle, 4);
|
|
});
|
|
ClientAPI.playMP3(sender,"sounds//carlock.mp3",false);
|
|
}
|
|
}
|
|
else if(API.getEntityData(veh,"besitzer") == sender.name)
|
|
{
|
|
if (API.getEntitySyncedData(veh, "locked") == false)
|
|
{
|
|
|
|
API.setEntitySyncedData(veh, "locked", true);
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
|
|
API.sendNotificationToPlayer(sender, "Fahrzeug ~r~ Abgeschlossen!", true);
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_LIGHTS, sender.vehicle, 3);
|
|
API.delay(1000 * 1, true, () => {
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_LIGHTS, sender.vehicle, 4);
|
|
});
|
|
ClientAPI.playMP3(sender,"sounds//carlock.mp3",false);
|
|
}
|
|
else
|
|
{
|
|
API.setEntitySyncedData(veh, "locked", false);
|
|
API.setVehicleLocked(veh, false);
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 1);
|
|
API.sendNotificationToPlayer(sender, "Fahrzeug ~g~ Aufgeschlossen!", true);
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_LIGHTS, sender.vehicle, 3);
|
|
API.delay(1000 * 1, true, () => {
|
|
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_LIGHTS, sender.vehicle, 4);
|
|
});
|
|
ClientAPI.playMP3(sender,"sounds//carlock.mp3",false);
|
|
}
|
|
} else
|
|
{
|
|
API.sendNotificationToPlayer(sender, "Du hast keine Rechte!");
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public void triggerDoor(Vehicle veh, int door)
|
|
{
|
|
if(API.getEntityData(veh,"" + door) == true)
|
|
{
|
|
API.sendNativeToAllPlayers(Hash.SET_VEHICLE_DOOR_SHUT, veh, door, true);
|
|
API.setEntityData(veh, "" + door, false);
|
|
}
|
|
else
|
|
{
|
|
API.sendNativeToAllPlayers(Hash.SET_VEHICLE_DOOR_OPEN, veh, door, true, true);
|
|
API.setEntityData(veh, "" + door, true);
|
|
}
|
|
}
|
|
|
|
public void parkvehicle(Client player, Entity vehicle)
|
|
{
|
|
Vector3 position = vehicle.position;
|
|
float rotation = vehicle.rotation.Z;
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
int slot = API.getEntitySyncedData(vehicle, "slot");
|
|
command.CommandText = "UPDATE `vehicles` SET `spawnx` = " + Convert.ToInt16(position.X) + ", `spawnz` = " + Convert.ToInt16(position.Z) + ", `spawny` = " + Convert.ToInt16(position.Y) + ", `rotation` = " + Convert.ToInt16(rotation) + " WHERE owner = '" + player.name + "' AND slot = " + slot + "";
|
|
connection.Open();
|
|
command.ExecuteNonQuery();
|
|
connection.Close();
|
|
}
|
|
|
|
public static void saveTank(NetHandle vehicle)
|
|
{
|
|
int tank = API.shared.getEntitySyncedData(vehicle,"tank");
|
|
string owner = API.shared.getEntityData(vehicle, "besitzer");
|
|
int slot = API.shared.getEntitySyncedData(vehicle, "slot");
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
command.CommandText = "UPDATE `vehicles` SET `tank` = " + tank + " WHERE owner = '" + owner + "' AND slot = " + slot;
|
|
connection.Open();
|
|
command.ExecuteNonQuery();
|
|
connection.Close();
|
|
|
|
}
|
|
|
|
public void respawnVehicle(Client player,Entity vehicle)
|
|
{
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
int slot = API.getEntitySyncedData(vehicle, "slot");
|
|
command.CommandText = "SELECT * FROM `vehicles` WHERE owner = '" + player.name + "' AND slot = " + slot + "";
|
|
//SELECT * FROM `vehicles` WHERE owner = 'Sandy_Cheeks' AND slot = 1
|
|
connection.Open();
|
|
reader = command.ExecuteReader();
|
|
vehicle.delete();
|
|
|
|
while (reader.Read())
|
|
{
|
|
string model = reader.GetString("model");
|
|
int spawnx = reader.GetInt32("spawnx");
|
|
int spawny = reader.GetInt32("spawny");
|
|
int spawnz = reader.GetInt32("spawnz");
|
|
int rotation = reader.GetInt32("rotation");
|
|
string owner = reader.GetString("owner");
|
|
int color = reader.GetInt32("color");
|
|
int color2 = reader.GetInt32("color2");
|
|
int tank = reader.GetInt32("tank");
|
|
string numberplate = reader.GetString("numberplate");
|
|
// TUNINGS
|
|
int spoiler = reader.GetInt32("Spoiler");
|
|
int frontbumper = reader.GetInt32("FrontBumper");
|
|
int rearbumper = reader.GetInt32("RearBumper");
|
|
int sideskirt = reader.GetInt32("SideSkirt");
|
|
int frame = reader.GetInt32("Frame");
|
|
int grille = reader.GetInt32("Grille");
|
|
int hood = reader.GetInt32("Hood");
|
|
int fender = reader.GetInt32("Fender");
|
|
int rightfender = reader.GetInt32("RightFender");
|
|
int roof = reader.GetInt32("Roof");
|
|
int engine = reader.GetInt32("Engine");
|
|
int brakes = reader.GetInt32("Brakes");
|
|
int transmission = reader.GetInt32("Transmission");
|
|
int horn = reader.GetInt32("Horn");
|
|
int suspension = reader.GetInt32("Suspension");
|
|
int armor = reader.GetInt32("Armor");
|
|
int turbo = reader.GetInt32("Turbo");
|
|
int xenon = reader.GetInt32("Xenon");
|
|
int frontwheels = reader.GetInt32("FrontWheels");
|
|
int backwheels = reader.GetInt32("BackWheels");
|
|
int plateholders = reader.GetInt32("Plateholders");
|
|
int trimdesign = reader.GetInt32("TrimDesign");
|
|
int ornaments = reader.GetInt32("Ornaments");
|
|
int dialdesign = reader.GetInt32("DialDesign");
|
|
int steeringwheel = reader.GetInt32("SteeringWheel");
|
|
int shiftlever = reader.GetInt32("ShiftLever");
|
|
int plaques = reader.GetInt32("Plaques");
|
|
int hydraulics = reader.GetInt32("Hydraulics");
|
|
int livery = reader.GetInt32("Livery");
|
|
int plate = reader.GetInt32("Plate");
|
|
int windowtint = reader.GetInt32("WindowTint");
|
|
int exhaust = reader.GetInt32("Exhaust");
|
|
Vehicle veh = RAPI.MainAPI.createRolePlayVehicleNonARGB(API.vehicleNameToModel(model), new Vector3(spawnx, spawny, spawnz + 0.5), new Vector3(0, 0, rotation), owner);
|
|
API.setVehiclePrimaryColor(veh, color);
|
|
API.setVehicleSecondaryColor(veh, color2);
|
|
|
|
API.setEntitySyncedData(veh, "slot", slot);
|
|
API.setEntitySyncedData(veh, "tank", tank);
|
|
// SETTING TEH MODS
|
|
API.setVehicleMod(veh, Spoilers, spoiler);
|
|
API.setVehicleMod(veh, intFront_Bumper, frontbumper);
|
|
API.setVehicleMod(veh, intRear_Bumper, rearbumper);
|
|
API.setVehicleMod(veh, Side_Skirt, sideskirt);
|
|
API.setVehicleMod(veh, Frame, frame);
|
|
API.setVehicleMod(veh, Grille, grille);
|
|
API.setVehicleMod(veh, Hood, hood);
|
|
API.setVehicleMod(veh, Fender, fender);
|
|
API.setVehicleMod(veh, Right_Fender, rightfender);
|
|
API.setVehicleMod(veh, Roof, roof);
|
|
API.setVehicleMod(veh, Engine, engine);
|
|
API.setVehicleMod(veh, Brakes, brakes);
|
|
API.setVehicleMod(veh, Exhaust, exhaust);
|
|
API.setVehicleMod(veh, Transmission, transmission);
|
|
API.setVehicleMod(veh, Horns, horn);
|
|
API.setVehicleMod(veh, Suspension, suspension);
|
|
API.setVehicleMod(veh, Armor, armor);
|
|
API.setVehicleMod(veh, Turbo, turbo);
|
|
API.setVehicleMod(veh, Xenon, xenon);
|
|
if (backwheels != 0)
|
|
{
|
|
API.setVehicleMod(veh, Back_Wheels, backwheels);
|
|
}
|
|
API.setVehicleMod(veh, Front_Wheels, frontwheels);
|
|
API.setVehicleMod(veh, Plate_holders, plateholders);
|
|
API.setVehicleMod(veh, Trim_Design, trimdesign);
|
|
API.setVehicleMod(veh, Ornaments, ornaments);
|
|
API.setVehicleMod(veh, Dial_Design, dialdesign);
|
|
API.setVehicleMod(veh, Steering_Wheel, steeringwheel);
|
|
API.setVehicleMod(veh, Shift_Lever, shiftlever);
|
|
API.setVehicleMod(veh, Plaques, plaques);
|
|
API.setVehicleMod(veh, Hydraulics, hydraulics);
|
|
API.setVehicleMod(veh, Livery, livery);
|
|
API.setVehicleMod(veh, Window_Tint, windowtint);
|
|
API.setEntityData(veh,"numberplate",numberplate);
|
|
API.setVehicleNumberPlate(veh,Environment.Fahrzeuganmeldestelle.getKennzeichen(veh));
|
|
}
|
|
|
|
}
|
|
|
|
public static void deleteVehicle(Client player, int slot)
|
|
{
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
command.CommandText = "DELETE FROM `vehicles` WHERE `owner` = '" + player.name + "' AND `slot` = " + slot ;
|
|
API.shared.consoleOutput("Spieler " + player.name + " hat Fahrzeugslot " + slot + " geloescht!");
|
|
//SELECT * FROM `vehicles` WHERE owner = 'Sandy_Cheeks' AND slot = 1
|
|
connection.Open();
|
|
command.ExecuteNonQuery();
|
|
connection.Close();
|
|
}
|
|
|
|
public static bool isVehicle(Client player, int slot)
|
|
{
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
command.CommandText = "SELECT * FROM `vehicles` WHERE owner = '" + player.name + "' AND slot = " + slot + " LIMIT 1";
|
|
connection.Open();
|
|
reader = command.ExecuteReader();
|
|
while (reader.Read())
|
|
{
|
|
int slot1 = reader.GetInt32("slot");
|
|
if (slot1 == slot)
|
|
{
|
|
connection.Close();
|
|
return true;
|
|
}
|
|
}
|
|
connection.Close();
|
|
return false;
|
|
}
|
|
|
|
public void respawnVehicleWithCustomSlot(Client player, int slot)
|
|
{
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
command.CommandText = "SELECT * FROM `vehicles` WHERE owner = '" + player.name + "' AND slot = " + slot + " LIMIT 1";
|
|
//SELECT * FROM `vehicles` WHERE owner = 'Sandy_Cheeks' AND slot = 1
|
|
connection.Open();
|
|
reader = command.ExecuteReader();
|
|
bool isleer = false;
|
|
foreach(NetHandle veh in API.getAllVehicles())
|
|
{
|
|
if(API.getEntityData(veh, "besitzer") == player.name)
|
|
{
|
|
if(API.getEntitySyncedData(veh,"slot") == slot)
|
|
{
|
|
if(API.getVehicleOccupants(veh).Length == 0)
|
|
{
|
|
API.deleteEntity(veh);
|
|
isleer = true;
|
|
} else
|
|
{
|
|
API.sendNotificationToPlayer(player, "Das Fahrzeug ist nicht leer!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (isleer == true)
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
string model = reader.GetString("model");
|
|
int spawnx = reader.GetInt32("spawnx");
|
|
int spawny = reader.GetInt32("spawny");
|
|
int spawnz = reader.GetInt32("spawnz");
|
|
int rotation = reader.GetInt32("rotation");
|
|
string owner = reader.GetString("owner");
|
|
int color = reader.GetInt32("color");
|
|
int color2 = reader.GetInt32("color2");
|
|
int tank = reader.GetInt32("tank");
|
|
string numberplate = reader.GetString("numberplate");
|
|
// TUNINGS
|
|
int spoiler = reader.GetInt32("Spoiler");
|
|
int frontbumper = reader.GetInt32("FrontBumper");
|
|
int rearbumper = reader.GetInt32("RearBumper");
|
|
int sideskirt = reader.GetInt32("SideSkirt");
|
|
int frame = reader.GetInt32("Frame");
|
|
int grille = reader.GetInt32("Grille");
|
|
int hood = reader.GetInt32("Hood");
|
|
int fender = reader.GetInt32("Fender");
|
|
int rightfender = reader.GetInt32("RightFender");
|
|
int roof = reader.GetInt32("Roof");
|
|
int engine = reader.GetInt32("Engine");
|
|
int brakes = reader.GetInt32("Brakes");
|
|
int transmission = reader.GetInt32("Transmission");
|
|
int horn = reader.GetInt32("Horn");
|
|
int suspension = reader.GetInt32("Suspension");
|
|
int armor = reader.GetInt32("Armor");
|
|
int turbo = reader.GetInt32("Turbo");
|
|
int xenon = reader.GetInt32("Xenon");
|
|
int frontwheels = reader.GetInt32("FrontWheels");
|
|
int backwheels = reader.GetInt32("BackWheels");
|
|
int plateholders = reader.GetInt32("Plateholders");
|
|
int trimdesign = reader.GetInt32("TrimDesign");
|
|
int ornaments = reader.GetInt32("Ornaments");
|
|
int dialdesign = reader.GetInt32("DialDesign");
|
|
int steeringwheel = reader.GetInt32("SteeringWheel");
|
|
int shiftlever = reader.GetInt32("ShiftLever");
|
|
int plaques = reader.GetInt32("Plaques");
|
|
int hydraulics = reader.GetInt32("Hydraulics");
|
|
int livery = reader.GetInt32("Livery");
|
|
int plate = reader.GetInt32("Plate");
|
|
int windowtint = reader.GetInt32("WindowTint");
|
|
int exhaust = reader.GetInt32("Exhaust");
|
|
Vehicle veh = RAPI.MainAPI.createRolePlayVehicleNonARGB(API.vehicleNameToModel(model), new Vector3(spawnx, spawny, spawnz + 0.5), new Vector3(0, 0, rotation), owner);
|
|
API.setVehiclePrimaryColor(veh, color);
|
|
API.setVehicleSecondaryColor(veh, color2);
|
|
API.setEntitySyncedData(veh, "slot", slot);
|
|
API.setEntitySyncedData(veh, "tank", tank);
|
|
// SETTING TEH MODS
|
|
API.setVehicleMod(veh, Spoilers, spoiler);
|
|
API.setVehicleMod(veh, intFront_Bumper, frontbumper);
|
|
API.setVehicleMod(veh, intRear_Bumper, rearbumper);
|
|
API.setVehicleMod(veh, Side_Skirt, sideskirt);
|
|
API.setVehicleMod(veh, Frame, frame);
|
|
API.setVehicleMod(veh, Grille, grille);
|
|
API.setVehicleMod(veh, Hood, hood);
|
|
API.setVehicleMod(veh, Exhaust, exhaust);
|
|
API.setVehicleMod(veh, Fender, fender);
|
|
API.setVehicleMod(veh, Right_Fender, rightfender);
|
|
API.setVehicleMod(veh, Roof, roof);
|
|
API.setVehicleMod(veh, Engine, engine);
|
|
API.setVehicleMod(veh, Brakes, brakes);
|
|
API.setVehicleMod(veh, Transmission, transmission);
|
|
API.setVehicleMod(veh, Horns, horn);
|
|
API.setVehicleMod(veh, Suspension, suspension);
|
|
API.setVehicleMod(veh, Armor, armor);
|
|
API.setVehicleMod(veh, Turbo, turbo);
|
|
API.setVehicleMod(veh, Xenon, xenon);
|
|
if (backwheels != 0)
|
|
{
|
|
API.setVehicleMod(veh, Back_Wheels, backwheels);
|
|
}
|
|
API.setVehicleMod(veh, Front_Wheels, frontwheels);
|
|
API.setVehicleMod(veh, Plate_holders, plateholders);
|
|
API.setVehicleMod(veh, Trim_Design, trimdesign);
|
|
API.setVehicleMod(veh, Ornaments, ornaments);
|
|
API.setVehicleMod(veh, Dial_Design, dialdesign);
|
|
API.setVehicleMod(veh, Steering_Wheel, steeringwheel);
|
|
API.setVehicleMod(veh, Shift_Lever, shiftlever);
|
|
API.setVehicleMod(veh, Plaques, plaques);
|
|
API.setVehicleMod(veh, Hydraulics, hydraulics);
|
|
API.setVehicleMod(veh, Livery, livery);
|
|
API.setVehicleMod(veh, Window_Tint, windowtint);
|
|
API.setEntityData(veh,"numberplate",numberplate);
|
|
API.setVehicleNumberPlate(veh,Environment.Fahrzeuganmeldestelle.getKennzeichen(veh));
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
[Command("respawn")]
|
|
public void respawnVehicleWithASlot(Client player, int slot)
|
|
{
|
|
if (isVehicle(player, slot))
|
|
{
|
|
if (Environment.MONEY.Money.hasBarMoney(player, 450))
|
|
{
|
|
respawnVehicleWithCustomSlot(player, slot);
|
|
API.sendNotificationToPlayer(player, "Du hast das Fahrzeug respawnt!");
|
|
Environment.MONEY.Money.giveBarMoney(player, -450, API);
|
|
}
|
|
} else
|
|
{
|
|
API.sendNotificationToPlayer(player, "~r~Fahrzeug existiert nicht!");
|
|
}
|
|
}
|
|
|
|
public static int getNextSlot(Client player)
|
|
{
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
command.CommandText = "SELECT * FROM vehicles WHERE owner = '" + player.name + "'";
|
|
|
|
|
|
connection.Open();
|
|
reader = command.ExecuteReader();
|
|
DataTable results = new DataTable();
|
|
results.Load(reader);
|
|
int slot = 1;
|
|
foreach (DataRow dr in results.Rows)
|
|
{
|
|
slot = slot + 1;
|
|
}
|
|
connection.Close();
|
|
return slot;
|
|
}
|
|
|
|
public static bool isNumberplate(String numberplate)
|
|
{
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
command.CommandText = "SELECT * FROM vehicles";
|
|
|
|
bool state = false;
|
|
connection.Open();
|
|
reader = command.ExecuteReader();
|
|
DataTable results = new DataTable();
|
|
results.Load(reader);
|
|
|
|
foreach (DataRow dr in results.Rows)
|
|
{
|
|
if(numberplate == Convert.ToString(dr["numberplate"]))
|
|
{
|
|
state = true;
|
|
return true;
|
|
}
|
|
}
|
|
connection.Close();
|
|
return state;
|
|
}
|
|
|
|
public static void remapTunings(Client player, Entity vehicle, API api)
|
|
{
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
int slot = api.getEntitySyncedData(vehicle, "slot");
|
|
command.CommandText = "SELECT * FROM `vehicles` WHERE owner = '" + player.name + "' AND slot = " + slot + "";
|
|
connection.Open();
|
|
reader = command.ExecuteReader();
|
|
Vehicle veh = RAPI.MainAPI.getVehicleFromHandle(api, vehicle);
|
|
|
|
while (reader.Read())
|
|
{
|
|
int color = reader.GetInt32("color");
|
|
int color2 = reader.GetInt32("color2");
|
|
// TUNINGS
|
|
int spoiler = reader.GetInt32("Spoiler");
|
|
int frontbumper = reader.GetInt32("FrontBumper");
|
|
int rearbumper = reader.GetInt32("RearBumper");
|
|
int sideskirt = reader.GetInt32("SideSkirt");
|
|
int frame = reader.GetInt32("Frame");
|
|
int grille = reader.GetInt32("Grille");
|
|
int hood = reader.GetInt32("Hood");
|
|
int fender = reader.GetInt32("Fender");
|
|
int rightfender = reader.GetInt32("RightFender");
|
|
int roof = reader.GetInt32("Roof");
|
|
int engine = reader.GetInt32("Engine");
|
|
int brakes = reader.GetInt32("Brakes");
|
|
int transmission = reader.GetInt32("Transmission");
|
|
int horn = reader.GetInt32("Horn");
|
|
int suspension = reader.GetInt32("Suspension");
|
|
int armor = reader.GetInt32("Armor");
|
|
int turbo = reader.GetInt32("Turbo");
|
|
int xenon = reader.GetInt32("Xenon");
|
|
int frontwheels = reader.GetInt32("FrontWheels");
|
|
int backwheels = reader.GetInt32("BackWheels");
|
|
int plateholders = reader.GetInt32("Plateholders");
|
|
int trimdesign = reader.GetInt32("TrimDesign");
|
|
int ornaments = reader.GetInt32("Ornaments");
|
|
int dialdesign = reader.GetInt32("DialDesign");
|
|
int steeringwheel = reader.GetInt32("SteeringWheel");
|
|
int shiftlever = reader.GetInt32("ShiftLever");
|
|
int plaques = reader.GetInt32("Plaques");
|
|
int hydraulics = reader.GetInt32("Hydraulics");
|
|
int livery = reader.GetInt32("Livery");
|
|
int plate = reader.GetInt32("Plate");
|
|
int windowtint = reader.GetInt32("WindowTint");
|
|
api.setVehiclePrimaryColor(veh, color);
|
|
api.setVehicleSecondaryColor(veh, color2);
|
|
// SETTING TEH MODS
|
|
api.setVehicleMod(veh, Spoilers, spoiler);
|
|
api.setVehicleMod(veh, intFront_Bumper, frontbumper);
|
|
api.setVehicleMod(veh, intRear_Bumper, rearbumper);
|
|
api.setVehicleMod(veh, Side_Skirt, sideskirt);
|
|
api.setVehicleMod(veh, Frame, frame);
|
|
api.setVehicleMod(veh, Grille, grille);
|
|
api.setVehicleMod(veh, Hood, hood);
|
|
api.setVehicleMod(veh, Fender, fender);
|
|
api.setVehicleMod(veh, Right_Fender, rightfender);
|
|
api.setVehicleMod(veh, Roof, roof);
|
|
api.setVehicleMod(veh, Engine, engine);
|
|
api.setVehicleMod(veh, Brakes, brakes);
|
|
api.setVehicleMod(veh, Transmission, transmission);
|
|
api.setVehicleMod(veh, Horns, horn);
|
|
api.setVehicleMod(veh, Suspension, suspension);
|
|
api.setVehicleMod(veh, Armor, armor);
|
|
api.setVehicleMod(veh, Turbo, turbo);
|
|
api.setVehicleMod(veh, Xenon, xenon);
|
|
if (backwheels != 0)
|
|
{
|
|
api.setVehicleMod(veh, Back_Wheels, backwheels);
|
|
}
|
|
api.setVehicleMod(veh, Front_Wheels, frontwheels);
|
|
api.setVehicleMod(veh, Plate_holders, plateholders);
|
|
api.setVehicleMod(veh, Trim_Design, trimdesign);
|
|
api.setVehicleMod(veh, Ornaments, ornaments);
|
|
api.setVehicleMod(veh, Dial_Design, dialdesign);
|
|
api.setVehicleMod(veh, Steering_Wheel, steeringwheel);
|
|
api.setVehicleMod(veh, Shift_Lever, shiftlever);
|
|
api.setVehicleMod(veh, Plaques, plaques);
|
|
api.setVehicleMod(veh, Hydraulics, hydraulics);
|
|
api.setVehicleMod(veh, Livery, livery);
|
|
api.setVehicleMod(veh, Window_Tint, windowtint);
|
|
api.setVehicleNumberPlate(veh,Environment.Fahrzeuganmeldestelle.getKennzeichen(veh));
|
|
}
|
|
connection.Close();
|
|
|
|
}
|
|
|
|
public static void insertDataBaseVehicle(string model, Client owner, int slot, int x, int y, int z, int rotation, string numberplate, int color)
|
|
{
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
command.CommandText = "INSERT INTO `vehicles`(`model`,`owner`,`slot`,`spawnx`,`spawny`,`spawnz`,`rotation`,`numberplate`,`color`,`color2`) VALUES ('" + model + "','" + owner.name + "'," + slot + "," + x + "," + y + "," + z + "," + rotation + ",'" + numberplate + "'," + color + "," + color + ")";
|
|
// "INSERT INTO `userdata`(`socialclub`, `password`, `nickname`, `skinid`,`moneyhand`, `money`, `fraktion`, `fraktion`) VALUES (@socialclub,@password,@nickname,@skinid,@moneyhand,@money,1,1,0,@spawnx,@spawny,@spawnz,@handynummer,0,0,0,0,0)";
|
|
connection.Open();
|
|
command.ExecuteNonQueryAsync();
|
|
Vehicle veh = RAPI.MainAPI.createRolePlayVehicleNonARGB(API.shared.vehicleNameToModel(model), new Vector3(x, y, z), new Vector3(0, 0, rotation), owner.name);
|
|
API.shared.setPlayerIntoVehicle(owner, veh, -1);
|
|
API.shared.sendChatMessageToPlayer(owner, "~r~Parke bitte dein Fahrzeug um! Sonst kann es von einem Administrator gelöscht werden! ");
|
|
API.shared.sendChatMessageToPlayer(owner, "~r~Fahrzeug ist nochnicht angemeldet, es muss umgehend angemeldet werden! ");
|
|
API.shared.setEntitySyncedData(veh, "slot", slot);
|
|
API.shared.setVehiclePrimaryColor(veh, color);
|
|
API.shared.setVehicleSecondaryColor(veh, color);
|
|
//API.shared.setEntityData(veh, "id", id);
|
|
API.shared.delay(2000, true, () =>
|
|
{
|
|
connection.Close();
|
|
});
|
|
}
|
|
|
|
public static String getTuningDatabaseName(int tuningslot)
|
|
{
|
|
if (tuningslot == 0)
|
|
{
|
|
return "Spoiler";
|
|
}
|
|
else if (tuningslot == 1)
|
|
{
|
|
return "FrontBumper";
|
|
}
|
|
else if (tuningslot == 2)
|
|
{
|
|
return "RearBumper";
|
|
}
|
|
else if (tuningslot == 3)
|
|
{
|
|
return "SideSkirt";
|
|
}
|
|
else if (tuningslot == 4)
|
|
{
|
|
return "Exhaust";
|
|
}
|
|
else if (tuningslot == 5)
|
|
{
|
|
return "Frame";
|
|
}
|
|
else if (tuningslot == 6)
|
|
{
|
|
return "Grille";
|
|
}
|
|
else if (tuningslot == 7)
|
|
{
|
|
return "Hood";
|
|
}
|
|
else if (tuningslot == 8)
|
|
{
|
|
return "Fender";
|
|
}
|
|
else if (tuningslot == 9)
|
|
{
|
|
return "RightFender";
|
|
}
|
|
else if (tuningslot == 10)
|
|
{
|
|
return "Roof";
|
|
}
|
|
else if (tuningslot == 11)
|
|
{
|
|
return "Engine";
|
|
}
|
|
else if (tuningslot == 12)
|
|
{
|
|
return "Brakes";
|
|
}
|
|
else if (tuningslot == 13)
|
|
{
|
|
return "Transmission";
|
|
}
|
|
else if (tuningslot == 14)
|
|
{
|
|
return "Horn";
|
|
}
|
|
else if (tuningslot == 15)
|
|
{
|
|
return "Suspension";
|
|
}
|
|
else if (tuningslot == 16)
|
|
{
|
|
return "Armor";
|
|
}
|
|
else if (tuningslot == 18)
|
|
{
|
|
return "Turbo";
|
|
}
|
|
else if (tuningslot == 22)
|
|
{
|
|
return "Xenon";
|
|
}
|
|
else if (tuningslot == 23)
|
|
{
|
|
return "FrontWheels";
|
|
}
|
|
else if (tuningslot == 24)
|
|
{
|
|
return "BackWheels";
|
|
}
|
|
else if (tuningslot == 25)
|
|
{
|
|
return "Plateholders";
|
|
}
|
|
else if (tuningslot == 27)
|
|
{
|
|
return "TrimDesign";
|
|
}
|
|
else if (tuningslot == 28)
|
|
{
|
|
return "Ornaments";
|
|
}
|
|
else if (tuningslot == 30)
|
|
{
|
|
return "DialDesign";
|
|
}
|
|
else if (tuningslot == 33)
|
|
{
|
|
return "SteeringWheel";
|
|
}
|
|
else if (tuningslot == 34)
|
|
{
|
|
return "ShiftLever";
|
|
}
|
|
else if (tuningslot == 35)
|
|
{
|
|
return "Plaques";
|
|
}
|
|
else if (tuningslot == 38)
|
|
{
|
|
return "Hydraulics";
|
|
}
|
|
else if (tuningslot == 48)
|
|
{
|
|
return "Livery";
|
|
}
|
|
else if (tuningslot == 62)
|
|
{
|
|
return "Plate";
|
|
}
|
|
else if (tuningslot == 69)
|
|
{
|
|
return "WindowTint";
|
|
}
|
|
else
|
|
{
|
|
API.shared.consoleOutput("ERROR OCCURED! Func: getTuningDatabaseName(int tuningslot)");
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static void setDatabaseTuning(Client player, Vehicle veh, int tuningslot, int value)
|
|
{
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
command.CommandText = "UPDATE vehicles SET `" + getTuningDatabaseName(tuningslot) + "` = " + value + " WHERE `owner` = @username AND `slot` = @slot;";
|
|
command.Parameters.AddWithValue("@username", player.name);
|
|
command.Parameters.AddWithValue("@slot", API.shared.getEntitySyncedData(veh, "slot"));
|
|
connection.Open();
|
|
command.ExecuteNonQuery();
|
|
connection.Close();
|
|
}
|
|
|
|
public static void setDatabaseVar(Client player, Vehicle veh, string row, int value)
|
|
{
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
command.CommandText = "UPDATE vehicles SET `" + row + "` = " + value + " WHERE `owner` = @username AND `slot` = @slot;";
|
|
command.Parameters.AddWithValue("@username", player.name);
|
|
command.Parameters.AddWithValue("@slot", API.shared.getEntitySyncedData(veh, "slot"));
|
|
connection.Open();
|
|
command.ExecuteNonQuery();
|
|
connection.Close();
|
|
}
|
|
|
|
public static void setDatabaseString(Client player, Vehicle veh, string row, string value)
|
|
{
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
command.CommandText = "UPDATE vehicles SET `" + row + "` = '" + value + "' WHERE `owner` = @username AND `slot` = @slot;";
|
|
command.Parameters.AddWithValue("@username", player.name);
|
|
command.Parameters.AddWithValue("@slot", API.shared.getEntitySyncedData(veh, "slot"));
|
|
connection.Open();
|
|
command.ExecuteNonQuery();
|
|
connection.Close();
|
|
}
|
|
|
|
|
|
public static String getDataBaseString(Vehicle veh, string row)
|
|
{
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
command.CommandText = "SELECT * FROM vehicles WHERE `owner` = '" + API.shared.getEntityData(veh,"besitzer") + "' AND `slot` = " + API.shared.getEntitySyncedData(veh,"slot") + "";
|
|
connection.Open();
|
|
reader = command.ExecuteReader();
|
|
string result = "";
|
|
while (reader.Read())
|
|
{
|
|
result = reader.GetString(row);
|
|
}
|
|
connection.Close();
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|