397 lines
25 KiB
C#
397 lines
25 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using GrandTheftMultiplayer.Server;
|
|
using GrandTheftMultiplayer.Shared;
|
|
using GrandTheftMultiplayer.Server.API;
|
|
using GrandTheftMultiplayer.Shared.Math;
|
|
using GrandTheftMultiplayer.Server.Elements;
|
|
using GrandTheftMultiplayer.Server.Constant;
|
|
using GrandTheftMultiplayer.Server.Managers;
|
|
using MySql.Data.MySqlClient;
|
|
using System.Data;
|
|
|
|
namespace Roleplay.Vehiclesystem
|
|
{
|
|
class VehicleShop : 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 const int VEHICLESHOP_CALLBACKID = 6846564;
|
|
public const int VEHICLESELLER_CALLBACKID = 987465;
|
|
public Vehicle lastvehicle = null;
|
|
public static Dictionary<String, int> modelprice = new Dictionary<string, int>();
|
|
|
|
public VehicleShop()
|
|
{
|
|
API.onClientEventTrigger += TriggerBack;
|
|
API.onClientEventTrigger += TriggerBack2;
|
|
API.onEntityEnterColShape += onCoLShapeHandler;
|
|
// Model X Y Z ROT FARBE PREIS | NACHDEMKAUF X Y Z ROT
|
|
// createShopVehicle("Modelname", "Was drüber steht", x, y, z, rotation, 0, preis, nachdemkaufx, nachdemkaufy, nachdemkaufz, nachdemkaufrot);
|
|
// LUXURY MOTORSPORTS
|
|
API.consoleOutput("Loading VehicleShops...");
|
|
Blip blip = API.createBlip(new Vector3(-53, -1109, 26));
|
|
API.setBlipSprite(blip, 225);
|
|
API.setBlipColor(blip,69);
|
|
// LOW END MOTORSPORTS
|
|
Blip blip2 = API.createBlip(new Vector3(-1137, -752, 19));
|
|
API.setBlipSprite(blip2, 225);
|
|
API.setBlipColor(blip2, 30);
|
|
// LowRider EXTREME TUNING
|
|
Blip blip3 = API.createBlip(new Vector3(-371.88, -106, 38));
|
|
API.setBlipSprite(blip3, 225);
|
|
API.setBlipColor(blip3, 69);
|
|
// Bikes
|
|
Blip bli4 = API.createBlip(new Vector3(105.0611, -134.5674, 54));
|
|
API.setBlipSprite(bli4, 226);
|
|
//Planes
|
|
Blip blip4 = API.createBlip(new Vector3(-970.93, -3001.6, 13.94));
|
|
API.setBlipSprite(blip4, 372);
|
|
API.delay(1000*15, true, () => {populateVehicleShops();});
|
|
|
|
//Classic cars
|
|
Blip classiccarsblip = API.createBlip(new Vector3(-228.3401, -1396.076, 30.59623));
|
|
API.setBlipSprite(classiccarsblip, 225);
|
|
API.setBlipColor(classiccarsblip, 31);
|
|
//Bootshändler
|
|
Blip bootshändler = API.createBlip(new Vector3(-950.85, -1487.29, -0.087));
|
|
API.setBlipSprite(bootshändler, 455);
|
|
//Wüstenhändler (Trucks)
|
|
Blip Trucks = API.createBlip(new Vector3(1348.426, 3610.6, 34.59948));
|
|
API.setBlipSprite(Trucks, 67);
|
|
|
|
|
|
// Vehicle Seller
|
|
Blip seller = API.createBlip(new Vector3(-424, -1686, 19));
|
|
API.setBlipSprite(seller, 478);
|
|
createSeller();
|
|
}
|
|
|
|
|
|
|
|
public void populateVehicleShops()
|
|
{
|
|
new createShopVehicle("Stunt", "Stunt", -964.3136, -2968.922, 14.14174, 151.481, 0, 450000, -946.093, -3174.294, 14.58, 59.9);
|
|
new createShopVehicle("Cuban800", "Cuban800", -954.2507, -2973.098, 14.58322, 148.7396, 0, 500000, -946.093, -3174.294, 14.58, 59.9);
|
|
new createShopVehicle("Velum", "Velum", -942.8292, -2980.186, 14.14174, 149.481, 0, 650000, -946.093, -3174.294, 14.58, 59.9);
|
|
new createShopVehicle("Mammatus", "Mammatus", -939.3107, -2998.599, 14.10188, 60.38273, 0, 250000, -946.093, -3174.294, 14.58, 59.9);
|
|
new createShopVehicle("Vestra", "Vestra", -951.2249, -3020.798, 14.12605, 56.12379, 0, 1000000, -946.093, -3174.294, 14.58, 59.9);
|
|
new createShopVehicle("Nimbus", "Nimbus", -971.1102, -3034.14, 14.58, -30, 0, 4500000, -946.093, -3174.294, 14.58, 59.9);
|
|
new createShopVehicle("Shamal", "Shamal", -989.2783, -3026.545, 14.54833, -31.31121, 0, 3000000, -946.093, -3174.294, 14.58, 59.9);
|
|
new createShopVehicle("Blazer", "Blazer", 105.3862, -146.2185, 54.24884, 66.63, 0, 25000, 97.18728, -147.4777, 54.18098, 157.813);
|
|
new createShopVehicle("CarbonRS", "CarbonRS", 106.23, -143.3743, 54.25838, 66.63, 0, 150000, 97.18728, -147.4777, 54.18098, 157.813);
|
|
new createShopVehicle("Ratbike", "Ratbike", 107.284, -140.52265, 54.21031, 66.63, 0, 21000, 97.18728, -147.4777, 54.18098, 157.813);
|
|
new createShopVehicle("Innovation", "Innovation", 108.2634, -137.2548, 54.26309, 66.63, 0, 57000, 97.18728, -147.4777, 54.18098, 157.813);
|
|
new createShopVehicle("Manchez", "Manchez", 104.044, -150.0571, 54.21702, 66.63, 0, 33000, 97.18728, -147.4777, 54.18098, 157.813);
|
|
new createShopVehicle("Hakuchou", "Hakuchou", 109.7669, -134.3058, 54.26296, 66.63, 0, 200000, 97.18728, -147.4777, 54.18098, 157.813);
|
|
new createShopVehicle("Sanchez2", "Sanchez", 110.95, -131.04, 54, 66.63, 0, 25000, 97.18728, -147.4777, 54.18098, 157.813);
|
|
new createShopVehicle("Vortex", "Vortex", 112.5719, -127.8086, 54.26296, 66.63, 0, 100000, 97.18728, -147.4777, 54.18098, 157.813);
|
|
new createShopVehicle("Bati", "Bati", 113.5525, -124.7784, 54.26296, 78.18, 0, 175000, 97.18728, -147.4777, 54.18098, 157.813);
|
|
new createShopVehicle("Faction3", "~r~Faction", -366.8927, -108.575, 38.13579, 161.0822, 55, 610000, -358, -121.3563, 38.19455, 0);
|
|
new createShopVehicle("SlamVan3", "~r~SlamVan", -373.3079, -106.1343, 38.12644, 160.2239, 55, 650000, -358, -121.3563, 38.19455, 0);
|
|
new createShopVehicle("Voodoo", "~r~Voodoo", -370.4257, -107.8789, 38.17953, 160.2239, 55, 625000, -358, -121.3563, 38.19455, 0);
|
|
new createShopVehicle("Chino2", "~r~Chino", -377.0509, -104.8755, 38.05014, 161.6499, 55, 550000, -358, -121.3563, 38.19455, 0);
|
|
new createShopVehicle("Buccaneer2", "~r~Buccaneer", -380, -104.2962, 37.88273, 162.537, 55, 585000, -358, -121.3563, 38.19455, 0);
|
|
new createShopVehicle("Panto", "Panto", -1142.069, -740.6898, 19.22861, -70.21, 0, 5000, -1168.273, -746.174, 19.03, -49.00);
|
|
new createShopVehicle("Burrito2", "Burrito", -1145.628, -745.7249, 19.45396, 107.2036, 0, 20000, -1168.273, -746.174, 19.03, -49.00);
|
|
new createShopVehicle("Rhapsody", "Rhapsody", -1139.962, -743.7163, 19.45396, -70.21, 0, 7500, -1168.273, -746.174, 19.03, -49.00);
|
|
new createShopVehicle("Feltzer2", "Feltzer", -1142.941, -748.5279, 19.1454, 107.3687, 0, 93000, -1168.273, -746.174, 19.03, -49.00);
|
|
new createShopVehicle("Dukes", "Dukes", -1137.197, -746.7424, 19.1454, -70.21, 0, 35000, -1168.273, -746.174, 19.03, -49.00);
|
|
new createShopVehicle("Tailgater", "Tailgater", -1140, -751.64, 19.01866, 108.446, 0, 30000, -1168.273, -746.174, 19.03, -49.00);
|
|
new createShopVehicle("Ingot", "Ingot", -1138.854, -754.6779, 18.86848, 108.2435, 0, 15000, -1168.273, -746.174, 19.03, -49.00);
|
|
new createShopVehicle("Blista3", "Blista", -1134.673, -749.5567, 19.1011, -71.21, 0, 18500, -1168.273, -746.174, 19.03, -49.00);
|
|
new createShopVehicle("Rocoto", "Rocoto", -1135.271, -757.3561, 18.94624, 108.6064, 0, 117000, -1168.273, -746.174, 19.03, -49.00);
|
|
new createShopVehicle("Oracle", "Oracle", -1132.397, -752.5397, 19.24744, -71.21, 0, 45000, -1168.273, -746.174, 19.03, -49.00);
|
|
new createShopVehicle("Gresley", "Gresley", -1133.625, -760.6332, 18.83885, 107.7306, 0, 85000, -1168.273, -746.174, 19.03, -49.00);
|
|
new createShopVehicle("SabreGT", "SabreGT", -1130.076, -755.4739, 18.78, -71.21, 0, 45000, -1168.273, -746.174, 19.03, -49.00);
|
|
new createShopVehicle("RancherXL", "RancherXL", -1130.572, -764.0083, 18.62108, 108.8393, 0, 35000, -1168.273, -746.174, 19.03, -49.00);
|
|
new createShopVehicle("Phoenix", "Phoenix", -1127.159, -758.3724, 18.54772, -71.21, 0, 50000, -1168.273, -746.174, 19.03, -49.00);
|
|
new createShopVehicle("GP1", "GP1", -47.89257, -1115.849, 25.7691, 0, 0, 1600000, -45.45881, -1083.074, 27.05868, 70.5);
|
|
new createShopVehicle("Banshee2", "Banshee getuned", -45.0299, -1115.903, 25.7691, 2.29, 0, 1000000, -45.45881, -1083.074, 27.05868, 70.5);
|
|
new createShopVehicle("Reaper", "Reaper", -50.71125, -1117.278, 25.96468, 1.5511, 0, 1250000, -45.45881, -1083.074, 27.05868, 70.5);
|
|
new createShopVehicle("Vacca", "Vacca", -53.54739, -1117.307, 25.96021, 2.716155, 0, 1150000, -45.45881, -1083.074, 27.05868, 70.5);
|
|
new createShopVehicle("Adder", "Adder", -56.30697, -1117.2242, 26.02039, 2.831551, 0, 1400000, -45.45881, -1083.074, 27.05868, 70.5);
|
|
new createShopVehicle("Zentorno", "Zentorno", -42.42964, -1116.49, 26.01433, -2.07, 0, 2000000, -45.45881, -1083.074, 27.05868, 70.5);
|
|
new createShopVehicle("Sheava", "Sheava", -58.99161, -1117.492, 25.8624, 2.852704, 0, 1800000, -45.45881, -1083.074, 27.05868, 70.5);
|
|
new createShopVehicle("Superd", "Superd", -61.88922, -1116.99, 25.97186, 2.448304, 0, 2500000, -45.45881, -1083.074, 27.05868, 70.5);
|
|
// Classic Cars
|
|
new createShopVehicle("Tropos","Tropos", -228.3401, -1396.076, 30.59623, 99.5, 0, 2000000, -233.5067, -1411.776, 30.61703, -175.936);
|
|
new createShopVehicle("Feltzer3", "Feltzer", -228.4123, -1399.56, 30.45658, 102.427, 0, 2000000, -233.5067, -1411.776, 30.61703, -175.936);
|
|
new createShopVehicle("Coquette3", "Coquette", -227.263, -1402.43, 30.699, 99.28, 0, 1000000, -233.5067, -1411.776, 30.61703, -175.936);
|
|
new createShopVehicle("Monroe", "Monroe",-228.99, -1392.90, 30.50, 99.82, 0, 3000000, -233.5067, -1411.776, 30.61703, -175.936);
|
|
new createShopVehicle("Stinger", "Stinger", -214.16, -1398.06, 30.68, -3.47, 0, 1500000, -233.5067, -1411.776, 30.61703, -175.936);
|
|
new createShopVehicle("StingerGT", "StingerGT", -211.09, -1396.79, 30.68, 2.33, 0, 2500000, -233.5067, -1411.776, 30.61703, -175.936);
|
|
new createShopVehicle("Casco", "Casco", -207.83, -1395.22, 30.43, -4.828, 0, 2750000, -233.5067, -1411.776, 30.61703, -175.936);
|
|
new createShopVehicle("Mamba", "Mamba", -204.45, -1393.16, 30.54, -4.15, 0, 3000000, -233.5067, -1411.776, 30.61703, -175.936);
|
|
new createShopVehicle("Turismo2", "Turismo", -201.27, -1391.38, 30.88, -4.29, 0, 3500000, -233.5067, -1411.776, 30.61703, -175.936);
|
|
new createShopVehicle("BType", "BType", -174.02, -1377.09, 30.71, 68.57, 0, 3750000, -233.5067, -1411.776, 30.61703, -175.936);
|
|
new createShopVehicle("Comet3", "Comet", -182.48, -1382.58, 30.55, 9.60, 0, 3000000, -233.5067, -1411.776, 30.61703, -175.936);
|
|
//Bootshändler
|
|
new createShopVehicle("Seashark","Seashark", -950.85, -1487.29, -0.087, 21.15, 0, 50000, -838.6624, -1453.943, 0.410, -87.69942);
|
|
new createShopVehicle("Seashark3","SeasharkGT", -953.04, -1481.63, -0.08, 20.30, 0, 75000, -838.6624, -1453.943, 0.410, -87.69942);
|
|
new createShopVehicle("Suntrap","Suntrap", -943.5236, -1485.484, 0.4405, 22.925, 0, 150000, -838.6624, -1453.943, 0.410, -87.69942);
|
|
new createShopVehicle("Dinghy4","Dinghy", -989.5797, -1399.95, 0.1195769, 18.9158, 0, 185000, -838.6624, -1453.943, 0.410, -87.69942);
|
|
new createShopVehicle("Tropic","Tropic", -935.20, -1481.67, 0.30, 18.58, 0, 200000, -838.6624, -1453.943, 0.410, -87.69942);
|
|
new createShopVehicle("Squalo","Squalo", -927.32, -1477.19, 0.39, 19.96, 0, 215000, -838.6624, -1453.943, 0.410, -87.69942);
|
|
new createShopVehicle("Toro","Toro", -918.51, -1475.73, 0.39, 18.01, 0, 1000000, -838.6624, -1453.943, 0.410, -87.69942);
|
|
new createShopVehicle("Jetmax","Jetmax", -910.07, -1471.65, 0.32, 18.72, 0, 1250000, -838.6624, -1453.943, 0.410, -87.69942);
|
|
new createShopVehicle("Speeder2","Speeder", -900.25, -1468.86, -0.09, 21.62, 0, 1500000, -838.6624, -1453.943, 0.410, -87.69942);
|
|
new createShopVehicle("Marquis","Marquis", -891.87, -1463.20, 0.39, 19.07, 0, 2500000, -838.6624, -1453.943, 0.410, -87.69942);
|
|
//Wüstenhänder (Trucks)
|
|
new createShopVehicle("Sadler", "Sadler", 1348.426, 3610.6, 34.59948, 111.0495, 0, 69000, 1335.753, 3599.241, 34.4746, 106.7587);
|
|
new createShopVehicle("BfInjection", "BfInjection", 1351.21, 3601.141, 34.52505, 116.6388, 0, 111000, 1335.753, 3599.241, 34.4746, 106.7587);
|
|
new createShopVehicle("Kalahari", "Kalahari", 1379.433, 3601.303, 34.39941, 109.4478, 0, 50000, 1335.753, 3599.241, 34.4746, 106.7587);
|
|
new createShopVehicle("Mesa", "Mesa", 1380.981, 3598.802, 34.39133, 107.3812, 0, 75000, 1335.753, 3599.241, 34.4746, 106.7587);
|
|
new createShopVehicle("Mesa3", "Mesa Offroad", 1358.571, 3598.294, 34.66017, 110.6759, 0, 199000, 1335.753, 3599.241, 34.4746, 106.7587);
|
|
new createShopVehicle("Camper", "Camper", 1378.172, 3604.766, 34.63292, 110.9256, 0, 135000, 1335.753, 3599.241, 34.4746, 106.7587);
|
|
new createShopVehicle("BobcatXL", "BobcatXL", 1381.893, 3596.021, 34.66385, 105.3144, 0, 72500, 1335.753, 3599.241, 34.4746, 106.7587);
|
|
new createShopVehicle("Sandking", "Sandking", 1361.617, 3591.52, 34.94587, 111.5741, 0, 1299995, 1335.753, 3599.241, 34.4746, 106.7587);
|
|
new createShopVehicle("Rebel2", "Rebel", 1347.098, 3613.753, 34.44533, 113.4638, 0, 60000, 1335.753, 3599.241, 34.4746, 106.7587);
|
|
new createShopVehicle("Surfer2", "Surfer", 1350.245, 3603.531, 34.66228, 115.9452, 0, 38500, 1335.753, 3599.241, 34.4746, 106.7587);
|
|
new createShopVehicle("Bison", "Bison", 1348.839, 3607.232, 34.39073, 108.898, 0, 98000, 1335.753, 3599.241, 34.4746, 106.7587);
|
|
API.consoleOutput("Vehicle Shops loaded!");
|
|
}
|
|
|
|
public void createSeller()
|
|
{
|
|
//API.createPed(PedHash.Autoshop02SMM, new Vector3(-422, -1698, 19), 68, 0);
|
|
//RAPI.Marker.createMarker(1, new Vector3(-422.68, -1697.699, 18.08), 1, 255, 0, 0, "vehiclekaufen", 0, 185, "", 0);
|
|
RAPI.Marker.createMarker(0, new Vector3(-424.2817, -1686.208, 19.02909),1,255,255,0,"vehicleabgabe",0,185,"",0);
|
|
}
|
|
|
|
private void onCoLShapeHandler(ColShape colshape, NetHandle entity)
|
|
{
|
|
if(colshape.hasData("vehicleabgabe") && colshape.getData("vehicleabgabe") == true && colshape != null && entity != null)
|
|
{
|
|
|
|
Client player = API.getPlayerFromHandle(entity);
|
|
if (player != null && player.isInVehicle == true)
|
|
{
|
|
|
|
if (API.hasEntityData(player.vehicle, "besitzer") && API.getEntityData(player.vehicle, "besitzer") == player.name)
|
|
{
|
|
NetHandle nh = API.getPlayerVehicle(player);
|
|
VehicleHash vh = (VehicleHash)API.getEntityModel(nh);
|
|
if (modelprice.ContainsKey(API.getVehicleDisplayName(vh)) == true)
|
|
{
|
|
int price = modelprice[API.getVehicleDisplayName(vh)];
|
|
///////////////////////////////////////////////////////////////
|
|
object[] argumentList = new object[13];
|
|
argumentList[0] = VEHICLESELLER_CALLBACKID;
|
|
argumentList[1] = "Fahrzeug verkaufen";
|
|
argumentList[2] = "Optionen:";
|
|
argumentList[3] = true;
|
|
int itemlength = 2;
|
|
argumentList[4] = itemlength;
|
|
argumentList[5] = "~r~Verlassen";
|
|
argumentList[6] = "~g~Verkaufen";
|
|
argumentList[8] = "~b~Preis: " + price + "$";
|
|
API.triggerClientEvent(player, "menu_handler_create_menu", argumentList);
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
}
|
|
else
|
|
{
|
|
API.sendNotificationToPlayer(player, "Du kannst das Fahrzeug:" + API.getVehicleDisplayName(vh) + " nicht verkaufen!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void TriggerBack2(Client sender, string eventName, object[] arguments)
|
|
{
|
|
if(eventName == "menu_handler_select_item")
|
|
{
|
|
int callback = (int) arguments[0];
|
|
if(callback == VEHICLESELLER_CALLBACKID)
|
|
{
|
|
int index = (int)arguments[1];
|
|
if (index == 0)
|
|
{
|
|
API.triggerClientEvent(sender, "menu_handler_close_menu");
|
|
}
|
|
else if (index == 1)
|
|
{
|
|
NetHandle nh = API.getPlayerVehicle(sender);
|
|
VehicleHash vh = (VehicleHash)API.getEntityModel(nh);
|
|
if (modelprice.ContainsKey(API.getVehicleDisplayName(vh)) == true)
|
|
{
|
|
int price = modelprice[API.getVehicleDisplayName(vh)];
|
|
VehicleMain.deleteVehicle(sender, Convert.ToInt32(API.getEntitySyncedData(sender.vehicle, "slot")));
|
|
insertVehicleIntoSeller(API.getVehicleDisplayName(vh), API.getVehiclePrimaryColor(sender.vehicle), API.getVehicleSecondaryColor(sender.vehicle), price);
|
|
sender.vehicle.delete();
|
|
API.sendNotificationToPlayer(sender, "~g~Fahrzeug verkauft!");
|
|
Environment.MONEY.Money.giveBarMoney(sender, price, API);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static void insertVehicleIntoSeller(string model, int color1, int color2, int buyprice)
|
|
{
|
|
connection = new MySqlConnection(myConnectionString);
|
|
command = connection.CreateCommand();
|
|
command.CommandText = "INSERT INTO `vehicleshop`(`model`, `color1`, `color2`, `buyprice`) VALUES ('" + model +"', " + color1 + ", " + color2 + ", " + buyprice + ")";
|
|
API.shared.consoleOutput("Inserted BuyVehicle!");
|
|
API.shared.consoleOutput("Query: " + command.CommandText);
|
|
connection.Open();
|
|
command.ExecuteNonQuery();
|
|
connection.Close();
|
|
}
|
|
|
|
public const int CALLBACKDUDE = 18923;
|
|
|
|
public static void openFahrzeugKaufen()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
private void TriggerBack(Client sender, string eventName, object[] arguments)
|
|
{
|
|
if(eventName == "triggerKaufBack")
|
|
{
|
|
NetHandle ent = (NetHandle) arguments[0];
|
|
Vehicle veh = RAPI.MainAPI.getVehicleFromHandle(API, ent);
|
|
if(ent != null && veh != null){
|
|
int preis = API.getEntityData(veh, "preis");
|
|
lastvehicle = veh;
|
|
///////////////////////////////////////////////////////////////
|
|
object[] argumentList = new object[13];
|
|
argumentList[0] = VEHICLESHOP_CALLBACKID;
|
|
argumentList[1] = "Fahrzeug kaufen";
|
|
argumentList[2] = "Optionen:";
|
|
argumentList[3] = true;
|
|
int itemlength = 2;
|
|
argumentList[4] = itemlength;
|
|
argumentList[5] = "~r~Verlassen";
|
|
argumentList[6] = "~g~Kaufen";
|
|
argumentList[8] = "~b~Preis: " + preis + "$";
|
|
API.triggerClientEvent(sender, "menu_handler_create_menu", argumentList);
|
|
///////////////////////////////////////////////////////////////
|
|
}
|
|
}
|
|
else if(eventName == "menu_handler_select_item")
|
|
{
|
|
int callback = (int)arguments[0];
|
|
int index = (int)arguments[1];
|
|
|
|
if(callback == VEHICLESHOP_CALLBACKID)
|
|
{
|
|
int color = API.getEntityData(lastvehicle, "color") ;
|
|
if(index == 0)
|
|
{
|
|
API.triggerClientEvent(sender, "menu_handler_close_menu");
|
|
}
|
|
else if(index == 1)
|
|
{
|
|
if (Environment.Fahrschule.doesPlayerHaveFuehrerschein(sender) == true)
|
|
{
|
|
if(Vehiclesystem.VehicleMain.getPrivateVehicles(sender).Count <= 10){
|
|
int preis = API.getEntityData(lastvehicle, "preis");
|
|
if (Environment.MONEY.Money.hasBarMoney(sender, preis))
|
|
{
|
|
API.sendNotificationToPlayer(sender, "~g~Du hast ein neues Fahrzeug erhalten!", true);
|
|
Levelsystem.addPlayerLevelFortschritt(sender,10,API);
|
|
Vector3 pos = new Vector3(Convert.ToInt16(API.shared.getEntityData(lastvehicle, "spawnx")), Convert.ToInt16(API.shared.getEntityData(lastvehicle, "spawny")), Convert.ToInt16(API.shared.getEntityData(lastvehicle, "spawnz")));
|
|
Vehiclesystem.VehicleMain.insertDataBaseVehicle(API.getEntityData(lastvehicle, "model"), sender, Vehiclesystem.VehicleMain.getNextSlot(sender), Convert.ToInt16(pos.X), Convert.ToInt16(pos.Y), Convert.ToInt16(pos.Z), Convert.ToInt16(sender.rotation.Z), "", color);
|
|
Environment.MONEY.Money.giveBarMoney(sender, -preis, API);
|
|
}
|
|
else
|
|
{
|
|
API.sendNotificationToPlayer(sender, "Du hast nicht genuegend Bargeld bei dir!", true);
|
|
}
|
|
} else {
|
|
API.sendNotificationToPlayer(sender,"Du kannst nur mind. 10 Fahrzeuge haben!");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
API.sendNotificationToPlayer(sender, "Du hast keinen Fuehrerschein!", true);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
public class createShopVehicle
|
|
{
|
|
public Vector3 Position { get; set; }
|
|
public String Model { get; set; }
|
|
public String Name { get; set; }
|
|
public double X { get; set; }
|
|
public double Y { get; set; }
|
|
public double Z { get; set; }
|
|
public double ROT { get; set; }
|
|
public int Color { get; set; }
|
|
public int Preis { get; set; }
|
|
public double SpawnX { get; set; }
|
|
public double SpawnY { get; set; }
|
|
public double SpawnZ { get; set; }
|
|
public double SpawnRot { get; set; }
|
|
|
|
|
|
public createShopVehicle(String model, string name, double x, double y , double z, double rot, int color,int preis,double spawnx, double spawny, double spawnz, double spawnrot)
|
|
{
|
|
Model = model;
|
|
Name = name;
|
|
X = x;
|
|
Y = y;
|
|
Z = z;
|
|
ROT = rot;
|
|
Color = color;
|
|
Preis = preis;
|
|
SpawnX = spawnx;
|
|
SpawnY = spawny;
|
|
SpawnZ = spawnz;
|
|
SpawnRot = spawnrot;
|
|
Vehicle veh = RAPI.MainAPI.createAustellVehicle(API.shared.vehicleNameToModel(Model), new Vector3(x, y, z), new Vector3(0, 0, rot), "kauf",color);
|
|
API.shared.setVehicleLocked(veh, true);
|
|
veh.freezePosition = true;
|
|
API.shared.setEntityInvincible(veh, true);
|
|
API.shared.createTextLabel("~g~ Klicke auf das Fahrzeug um es zu kaufen!", new Vector3(x, y, z + 2), 15, 1, false, 0);
|
|
API.shared.createTextLabel(preis + "$", new Vector3(x, y, z + 2.25), 10, 2, false, 0);
|
|
API.shared.createTextLabel(name + "", new Vector3(x, y, z + 2.5), 10, 2, false, 0);
|
|
API.shared.setEntitySyncedData(veh, "besitzer", "kauf");
|
|
API.shared.setEntityData(veh, "preis", preis);
|
|
API.shared.setEntityData(veh, "model", model);
|
|
API.shared.setEntityData(veh, "color", color);
|
|
API.shared.setEntityData(veh, "spawnx", spawnx);
|
|
API.shared.setEntityData(veh, "spawny", spawny);
|
|
API.shared.setEntityData(veh, "spawnz", spawnz);
|
|
API.shared.setEntityData(veh, "spawnrot", spawnrot);
|
|
VehicleHash vh = (VehicleHash)API.shared.getEntityModel(veh);
|
|
String vehiclesystemname = API.shared.getVehicleDisplayName(vh);
|
|
if (vehiclesystemname != null)
|
|
{
|
|
if(modelprice.ContainsKey(API.shared.getVehicleDisplayName(vh)) == false)
|
|
{
|
|
modelprice.Add(API.shared.getVehicleDisplayName(vh), Convert.ToInt32(preis * 0.5));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|