Zum testen: rentcar system
This commit is contained in:
@@ -30,16 +30,11 @@ cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
|||||||
export default function reportList(globalData: IGlobalData) {
|
export default function reportList(globalData: IGlobalData) {
|
||||||
|
|
||||||
var reportMenu: NativeUI.Menu;
|
var reportMenu: NativeUI.Menu;
|
||||||
|
|
||||||
var users;
|
var users;
|
||||||
var reportTexts;
|
var reportTexts;
|
||||||
|
|
||||||
var user = "";
|
var user = "";
|
||||||
var reportText = "";
|
var reportText = "";
|
||||||
|
|
||||||
|
|
||||||
//Weapon Menu
|
|
||||||
|
|
||||||
mp.events.add('showReportMenu', (userTickets, TicketsArr) => {
|
mp.events.add('showReportMenu', (userTickets, TicketsArr) => {
|
||||||
if (!globalData.InMenu) {
|
if (!globalData.InMenu) {
|
||||||
|
|
||||||
|
|||||||
5
ReallifeGamemode.Client/global.d.ts
vendored
5
ReallifeGamemode.Client/global.d.ts
vendored
@@ -89,4 +89,9 @@ declare type Weapon = {
|
|||||||
declare type WeaponCategory = {
|
declare type WeaponCategory = {
|
||||||
Category: number;
|
Category: number;
|
||||||
Weapons: Weapon[];
|
Weapons: Weapon[];
|
||||||
|
}
|
||||||
|
|
||||||
|
declare type RentcarProperty = {
|
||||||
|
Name: string;
|
||||||
|
Price: number;
|
||||||
}
|
}
|
||||||
@@ -280,6 +280,9 @@ bigmap();
|
|||||||
import notification from './Gui/notification';
|
import notification from './Gui/notification';
|
||||||
notification();
|
notification();
|
||||||
|
|
||||||
|
import rentCar from './util/rentcar';
|
||||||
|
rentCar(globalData);
|
||||||
|
|
||||||
require('./Gui/policedepartment');
|
require('./Gui/policedepartment');
|
||||||
require('./Gui/helptext');
|
require('./Gui/helptext');
|
||||||
require('./admin/spectate');
|
require('./admin/spectate');
|
||||||
|
|||||||
102
ReallifeGamemode.Client/util/rentcar.ts
Normal file
102
ReallifeGamemode.Client/util/rentcar.ts
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
import * as NativeUI from '../libs/NativeUI';
|
||||||
|
|
||||||
|
const Menu = NativeUI.Menu;
|
||||||
|
const UIMenuItem = NativeUI.UIMenuItem;
|
||||||
|
const UIMenuListItem = NativeUI.UIMenuListItem;
|
||||||
|
const Point = NativeUI.Point;
|
||||||
|
const ItemsCollection = NativeUI.ItemsCollection;
|
||||||
|
const Color = NativeUI.Color;
|
||||||
|
|
||||||
|
|
||||||
|
let screenRes = mp.game.graphics.getScreenResolution(0, 0);
|
||||||
|
|
||||||
|
let sendItem = new UIMenuItem("Mieten", "Fahrzeug Mieten");
|
||||||
|
sendItem.BackColor = new Color(13, 71, 161);
|
||||||
|
sendItem.HighlightedBackColor = new Color(25, 118, 210);
|
||||||
|
|
||||||
|
let cancelItem = new UIMenuItem("Abbrechen", "");
|
||||||
|
cancelItem.BackColor = new Color(213, 0, 0);
|
||||||
|
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||||
|
|
||||||
|
|
||||||
|
export default function rentCar(globalData: IGlobalData) {
|
||||||
|
|
||||||
|
var rentcarMenu: NativeUI.Menu;
|
||||||
|
var vehiclesToRent: RentcarProperty[] = [];
|
||||||
|
var vehicleNames: string[] = [];
|
||||||
|
var vehiclePrices: number[] = [];
|
||||||
|
var selectedIndex: number;
|
||||||
|
|
||||||
|
var payTimer;
|
||||||
|
var totalTime: number = 0;
|
||||||
|
var totalBill: number = 0;
|
||||||
|
|
||||||
|
mp.events.add('showRentcarMenu', (vehiclestring, rentcarLocation) => {
|
||||||
|
if (globalData.InMenu) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
globalData.InMenu = true;
|
||||||
|
|
||||||
|
vehiclesToRent = JSON.parse(vehiclestring);
|
||||||
|
|
||||||
|
vehicleNames = [];
|
||||||
|
vehiclePrices = [];
|
||||||
|
for (let entry of vehiclesToRent) {
|
||||||
|
vehicleNames.push(entry.Name);
|
||||||
|
vehiclePrices.push(entry.Price);
|
||||||
|
}
|
||||||
|
|
||||||
|
rentcarMenu = new Menu("Fahrzeugverleih", "", new Point(0, screenRes.y / 3), null, null);
|
||||||
|
rentcarMenu.AddItem(new UIMenuListItem("Fahrzeug", vehiclePrices[0] + "$ alle 5 Minuten", new ItemsCollection(vehicleNames)));
|
||||||
|
|
||||||
|
rentcarMenu.AddItem(sendItem);
|
||||||
|
rentcarMenu.AddItem(cancelItem);
|
||||||
|
rentcarMenu.Visible = true;
|
||||||
|
//outeText = "Route 1";
|
||||||
|
|
||||||
|
selectedIndex = 0;
|
||||||
|
|
||||||
|
rentcarMenu.ListChange.on((item: NativeUI.UIMenuListItem, index) => {
|
||||||
|
switch (item.Text) {
|
||||||
|
case "Fahrzeug":
|
||||||
|
item.Description = vehiclePrices[index] + "$ alle 5 Minuten";
|
||||||
|
selectedIndex = index;
|
||||||
|
//item.Description = item.SelectedValue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
rentcarMenu.ItemSelect.on((item) => {
|
||||||
|
if (item.Text === "Mieten") {
|
||||||
|
mp.events.callRemote("SERVER:rentcarBooked", vehicleNames[selectedIndex], vehiclePrices[selectedIndex], rentcarLocation);
|
||||||
|
rentcarMenu.Close();
|
||||||
|
globalData.InMenu = false;
|
||||||
|
} else if (item.Text === "Abbrechen") {
|
||||||
|
rentcarMenu.Close();
|
||||||
|
globalData.InMenu = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
rentcarMenu.MenuClose.on(() => {
|
||||||
|
globalData.InMenu = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.events.add('triggerRentcarTimer', (interval, pricePerInterval) => {
|
||||||
|
clearInterval(payTimer);
|
||||||
|
|
||||||
|
payTimer = setInterval(() => {
|
||||||
|
totalTime += interval;
|
||||||
|
totalBill += pricePerInterval;
|
||||||
|
|
||||||
|
if (totalTime != 0) {
|
||||||
|
mp.events.callRemote("SERVER:updateRentCarBill", totalBill, totalTime);
|
||||||
|
}
|
||||||
|
}, interval * 1000);
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.events.add('abortRentcarTimer', () => {
|
||||||
|
clearInterval(payTimer);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -17,6 +17,25 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
{
|
{
|
||||||
internal class UserCommands : Script
|
internal class UserCommands : Script
|
||||||
{
|
{
|
||||||
|
[Command("rent", "~m~rent stop")]
|
||||||
|
public void CmdUserStopRent(Player player, String option = "") {
|
||||||
|
if (!player.IsLoggedIn()) return;
|
||||||
|
|
||||||
|
if (option != "stop")
|
||||||
|
{
|
||||||
|
player.SendChatMessage("Mit \"/rent stop\" kannst du die Miete kündigen");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!player.HasData("hasRentcar"))
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(player, "Du hast zurzeit kein Fahrzeug gemietet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rentcar.cancelRent(player);
|
||||||
|
}
|
||||||
|
|
||||||
[Command("eventport", "~m~eventport")]
|
[Command("eventport", "~m~eventport")]
|
||||||
public void CmdUserEventport(Player player, String option = "")
|
public void CmdUserEventport(Player player, String option = "")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -78,6 +78,9 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
player.TriggerEvent("CLIENT:AddPed", 3, "s_m_m_pilot_01", -1621.4542236328125, -3152.724365234375, 13.991769790649414, 50.73009490966797, 0, false, true, 0, "none", true, true, true);//Ped_Pilot LS Airport
|
player.TriggerEvent("CLIENT:AddPed", 3, "s_m_m_pilot_01", -1621.4542236328125, -3152.724365234375, 13.991769790649414, 50.73009490966797, 0, false, true, 0, "none", true, true, true);//Ped_Pilot LS Airport
|
||||||
player.TriggerEvent("CLIENT:AddPed", 4, "u_m_o_finguru_01", -534.4425659179688, -2145.747314453125, 5.992100715637207, 53.96156692504883, 0, false, true, 0, "none", true, true, true);//Ped Busfahrer
|
player.TriggerEvent("CLIENT:AddPed", 4, "u_m_o_finguru_01", -534.4425659179688, -2145.747314453125, 5.992100715637207, 53.96156692504883, 0, false, true, 0, "none", true, true, true);//Ped Busfahrer
|
||||||
player.TriggerEvent("CLIENT:AddPed", 5, "csb_prolsec", 1690.84, 2591.17 , 45.91, -2.66, 0, false, true, 0, "none", true, true, true);//Ped Knast
|
player.TriggerEvent("CLIENT:AddPed", 5, "csb_prolsec", 1690.84, 2591.17 , 45.91, -2.66, 0, false, true, 0, "none", true, true, true);//Ped Knast
|
||||||
|
player.TriggerEvent("CLIENT:AddPed", 6, "ig_siemonyetarian", -1023.1589, -2693.6948, 13.98, 173.95613, 0, false, true, 0, "none", true, true, true);//Ped Rentcar NoobSpawn
|
||||||
|
player.TriggerEvent("CLIENT:AddPed", 7, "ig_siemonyetarian", -369.1589, -230.92816, 36.028805, 150.26433, 0, false, true, 0, "none", true, true, true);//Ped Rentcar KH/Stadthalle
|
||||||
|
player.TriggerEvent("CLIENT:AddPed", 8, "ig_siemonyetarian", 1222.0868, 2726.5286, 38.00415, 113.77263, 0, false, true, 0, "none", true, true, true);//Ped Rentcar Knast
|
||||||
|
|
||||||
TimeSpan currentTime = TimeManager.CurrentTime;
|
TimeSpan currentTime = TimeManager.CurrentTime;
|
||||||
bool disableLightMode = currentTime > LightModeTimeFrom && currentTime < LightModeTimeTo;
|
bool disableLightMode = currentTime > LightModeTimeFrom && currentTime < LightModeTimeTo;
|
||||||
|
|||||||
@@ -127,6 +127,11 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Rentcar.mapPlayerRentcarBill.ContainsKey(player.Name))
|
||||||
|
{
|
||||||
|
Rentcar.cancelRent(player);
|
||||||
|
}
|
||||||
|
|
||||||
//Vehicle LastVehicle = player.GetData<Vehicle>("LastVehicle");
|
//Vehicle LastVehicle = player.GetData<Vehicle>("LastVehicle");
|
||||||
JobBase job = JobManager.GetJob(player.GetUser().JobId ?? -1);
|
JobBase job = JobManager.GetJob(player.GetUser().JobId ?? -1);
|
||||||
if (job != null)
|
if (job != null)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
@@ -188,6 +189,7 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
int ticket_amount = 0;
|
int ticket_amount = 0;
|
||||||
int pay_amount = 0;
|
int pay_amount = 0;
|
||||||
bool house = false;
|
bool house = false;
|
||||||
|
bool hasRentcar = player.GetData<bool>("hasRentcar") == true;
|
||||||
|
|
||||||
if (u.House != null)
|
if (u.House != null)
|
||||||
{
|
{
|
||||||
@@ -203,7 +205,8 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
{
|
{
|
||||||
pay_amount = player.GetData<int>("pay_amount");
|
pay_amount = player.GetData<int>("pay_amount");
|
||||||
}
|
}
|
||||||
player.TriggerEvent("SERVER:InteractionMenu_OpenMenu", JsonConvert.SerializeObject(accountData), factionleader, JsonConvert.SerializeObject(memberList), JsonConvert.SerializeObject(jobData), faction, group, factionInvite, groupInvite, ticket_boolean, ticket_amount, pay_amount, house);
|
|
||||||
|
player.TriggerEvent("SERVER:InteractionMenu_OpenMenu", JsonConvert.SerializeObject(accountData), factionleader, JsonConvert.SerializeObject(memberList), JsonConvert.SerializeObject(jobData), faction, group, factionInvite, groupInvite, ticket_boolean, ticket_amount, pay_amount, JsonConvert.SerializeObject(hasRentcar), house);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RemoteEvent("keyPress:E")]
|
[RemoteEvent("keyPress:E")]
|
||||||
@@ -233,6 +236,7 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
JobPoint nearestJobPoint = PositionManager.JobPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.6);
|
JobPoint nearestJobPoint = PositionManager.JobPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.6);
|
||||||
Player nearestCuffPlayer = PositionManager.cuffPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.6 && user.GetData<bool>("duty"));
|
Player nearestCuffPlayer = PositionManager.cuffPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.6 && user.GetData<bool>("duty"));
|
||||||
AmmunationPoint nearestAmmunationPoint = PositionManager.AmmunationPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);
|
AmmunationPoint nearestAmmunationPoint = PositionManager.AmmunationPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);
|
||||||
|
RentcarPoint nearestRentcarPoint = PositionManager.rentcarPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);
|
||||||
|
|
||||||
if (user?.FactionId != null)
|
if (user?.FactionId != null)
|
||||||
{
|
{
|
||||||
@@ -351,6 +355,31 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
user.SetBlipAndNametagColor();
|
user.SetBlipAndNametagColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Rentcar Points
|
||||||
|
if (nearestRentcarPoint != null)
|
||||||
|
{
|
||||||
|
if (player.IsInVehicle)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Noobspawn
|
||||||
|
if (player.Position.DistanceTo(PositionManager.rentcarPoints[0].Position) <= 1.5)
|
||||||
|
{
|
||||||
|
player.TriggerEvent("showRentcarMenu", JsonConvert.SerializeObject(Rentcar.noobspawnVehicleProperties), "noobspawn");
|
||||||
|
}
|
||||||
|
//Stadthalle
|
||||||
|
else if (player.Position.DistanceTo(PositionManager.rentcarPoints[1].Position) <= 1.5)
|
||||||
|
{
|
||||||
|
player.TriggerEvent("showRentcarMenu", JsonConvert.SerializeObject(Rentcar.stadthalleVehicleProperties), "stadthalle");
|
||||||
|
}
|
||||||
|
//Knast
|
||||||
|
else if (player.Position.DistanceTo(PositionManager.rentcarPoints[2].Position) <= 1.5)
|
||||||
|
{
|
||||||
|
player.TriggerEvent("showRentcarMenu", JsonConvert.SerializeObject(Rentcar.knastVehicleProperties), "knast");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (nearestWeapon != null) // Weapon Point
|
if (nearestWeapon != null) // Weapon Point
|
||||||
{
|
{
|
||||||
List<string> primarys = new List<string>();
|
List<string> primarys = new List<string>();
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ namespace ReallifeGamemode.Server
|
|||||||
Introduction.Setup();
|
Introduction.Setup();
|
||||||
PositionManager.LoadPositionManager();
|
PositionManager.LoadPositionManager();
|
||||||
LoadManager.LoadLoadManager();
|
LoadManager.LoadLoadManager();
|
||||||
|
Rentcar.Setup();
|
||||||
|
|
||||||
TempBlip tempBlip = new TempBlip()
|
TempBlip tempBlip = new TempBlip()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
|
|
||||||
public static List<AmmunationPoint> AmmunationPoints = new List<AmmunationPoint>();
|
public static List<AmmunationPoint> AmmunationPoints = new List<AmmunationPoint>();
|
||||||
|
|
||||||
|
public static List<RentcarPoint> rentcarPoints = new List<RentcarPoint>();
|
||||||
|
|
||||||
public static Vector3 eventportPosition;
|
public static Vector3 eventportPosition;
|
||||||
public static bool eventportActive = false;
|
public static bool eventportActive = false;
|
||||||
|
|
||||||
@@ -307,6 +309,35 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion Shops
|
#endregion Shops
|
||||||
|
|
||||||
|
#region RentCar
|
||||||
|
|
||||||
|
RentcarPoint rentCarNoobSpawn = new RentcarPoint()
|
||||||
|
{
|
||||||
|
Position = Rentcar.noobSpawnBlipPosition
|
||||||
|
};
|
||||||
|
RentcarPoint rentCarStadthalle = new RentcarPoint()
|
||||||
|
{
|
||||||
|
Position = Rentcar.stadthalleBlipPosition
|
||||||
|
};
|
||||||
|
RentcarPoint rentCarKnast = new RentcarPoint()
|
||||||
|
{
|
||||||
|
Position = Rentcar.knastBlipPosition
|
||||||
|
};
|
||||||
|
|
||||||
|
rentcarPoints.Add(rentCarNoobSpawn);
|
||||||
|
rentcarPoints.Add(rentCarStadthalle);
|
||||||
|
rentcarPoints.Add(rentCarKnast);
|
||||||
|
|
||||||
|
foreach (RentcarPoint j in rentcarPoints)
|
||||||
|
{
|
||||||
|
NAPI.Marker.CreateMarker(1, new Vector3(j.Position.X, j.Position.Y, j.Position.Z - 2), new Vector3(j.Position.X, j.Position.Y, j.Position.Z + 1),
|
||||||
|
new Vector3(0, 0, 0), 1.5f, new Color(255, 255, 255, 50), false, 0);
|
||||||
|
NAPI.TextLabel.CreateTextLabel("~y~Fahrzeugverleih\n~w~Drücke ~b~E~w~ um ein Fahrzeug zu mieten", j.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion RentCar
|
||||||
}
|
}
|
||||||
|
|
||||||
[RemoteEvent("sendClientToStage")]
|
[RemoteEvent("sendClientToStage")]
|
||||||
@@ -439,3 +470,9 @@ public class AmmunationPoint
|
|||||||
public Vector3 Position { get; set; }
|
public Vector3 Position { get; set; }
|
||||||
public Ammunation Ammunation { get; set; }
|
public Ammunation Ammunation { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class RentcarPoint
|
||||||
|
{
|
||||||
|
public Vector3 Position { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ using ReallifeGamemode.Database.Entities;
|
|||||||
using ReallifeGamemode.Database.Models;
|
using ReallifeGamemode.Database.Models;
|
||||||
using ReallifeGamemode.Server.Extensions;
|
using ReallifeGamemode.Server.Extensions;
|
||||||
using ReallifeGamemode.Server.Log;
|
using ReallifeGamemode.Server.Log;
|
||||||
|
using ReallifeGamemode.Server.Services;
|
||||||
using ReallifeGamemode.Server.Util;
|
using ReallifeGamemode.Server.Util;
|
||||||
|
using ReallifeGamemode.Services;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -955,6 +957,17 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
[ServerEvent(Event.VehicleDeath)]
|
[ServerEvent(Event.VehicleDeath)]
|
||||||
public static void VehicleManagerVehicleDeath(Vehicle vehicle)
|
public static void VehicleManagerVehicleDeath(Vehicle vehicle)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
String rentCarOwner = Rentcar.mapPlayerRentcarBill.FirstOrDefault(x => x.Value.Item1 == vehicle).Key;
|
||||||
|
|
||||||
|
ChatService.Broadcast("a:" + "");
|
||||||
|
if (rentCarOwner != null)
|
||||||
|
{
|
||||||
|
Player target = PlayerService.GetPlayerByNameOrId(rentCarOwner);
|
||||||
|
Rentcar.cancelRent(target);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
ServerVehicle serverVehicle = GetServerVehicleFromVehicle(vehicle);
|
ServerVehicle serverVehicle = GetServerVehicleFromVehicle(vehicle);
|
||||||
|
|
||||||
if (serverVehicle == null)
|
if (serverVehicle == null)
|
||||||
|
|||||||
180
ReallifeGamemode.Server/Util/Rentcar.cs
Normal file
180
ReallifeGamemode.Server/Util/Rentcar.cs
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using GTANetworkAPI;
|
||||||
|
using ReallifeGamemode.Database.Entities;
|
||||||
|
using ReallifeGamemode.Database.Models;
|
||||||
|
using ReallifeGamemode.Server.Extensions;
|
||||||
|
using ReallifeGamemode.Server.Managers;
|
||||||
|
using ReallifeGamemode.Server.Services;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Server.Util
|
||||||
|
{
|
||||||
|
class Rentcar : Script
|
||||||
|
{
|
||||||
|
//In Sekunden
|
||||||
|
public static int PAY_TIMER = 10;
|
||||||
|
|
||||||
|
//In Stunden
|
||||||
|
private static int PAYTIME_FREE = 30;
|
||||||
|
|
||||||
|
public static List<RentcarProperty> noobspawnVehicleProperties = new List<RentcarProperty>();
|
||||||
|
private static Vector3 noobspawnVehicleSpawnPosition = new Vector3(-1020.18695, -2695.2253, 13.988778);
|
||||||
|
private static double noobspawnVehicleSpawnHeading = 151.39877;
|
||||||
|
public static Vector3 noobSpawnBlipPosition = new Vector3(-1023.3046, -2694.8992, 13.906858);
|
||||||
|
|
||||||
|
public static List<RentcarProperty> stadthalleVehicleProperties = new List<RentcarProperty>();
|
||||||
|
private static Vector3 stadthalleVehicleSpawnPosition = new Vector3(-373, -236.31334, 35.8506);
|
||||||
|
private static double stadthalleVehicleSpawnHeading = 109.96821;
|
||||||
|
public static Vector3 stadthalleBlipPosition = new Vector3(-369.7236, -231.82654, 35.993023);
|
||||||
|
|
||||||
|
public static List<RentcarProperty> knastVehicleProperties = new List<RentcarProperty>();
|
||||||
|
private static Vector3 knastVehicleSpawnPosition = new Vector3(1212.741, 2726.6135, 38.00415);
|
||||||
|
private static double knastVehicleSpawnHeading = 173.14825;
|
||||||
|
public static Vector3 knastBlipPosition = new Vector3(1220.3483, 2725.4932, 38.00414);
|
||||||
|
|
||||||
|
public static Dictionary<string, (Vehicle, int)> mapPlayerRentcarBill = new Dictionary<string, (Vehicle, int)>();
|
||||||
|
|
||||||
|
public static void Setup()
|
||||||
|
{
|
||||||
|
noobspawnVehicleProperties.Add(new RentcarProperty("bmx", 10));
|
||||||
|
noobspawnVehicleProperties.Add(new RentcarProperty("faggio3", 50));
|
||||||
|
|
||||||
|
stadthalleVehicleProperties.Add(new RentcarProperty("bmx", 10));
|
||||||
|
stadthalleVehicleProperties.Add(new RentcarProperty("faggio3", 50));
|
||||||
|
|
||||||
|
knastVehicleProperties.Add(new RentcarProperty("bmx", 10));
|
||||||
|
knastVehicleProperties.Add(new RentcarProperty("faggio3", 50));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void cancelRent(Player player)
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
User user = player.GetUser(dbContext);
|
||||||
|
user.BankAccount.Balance -= mapPlayerRentcarBill[player.Name].Item2;
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
player.SetData("hasRentcar", false);
|
||||||
|
player.TriggerEvent("abortRentcarTimer");
|
||||||
|
player.SendChatMessage("Fahrzeugmiete erfolgreich gekündigt. Kosten: ~g~" + mapPlayerRentcarBill[player.Name].Item2 + "$");
|
||||||
|
VehicleManager.DeleteVehicle(mapPlayerRentcarBill[player.Name].Item1);
|
||||||
|
Rentcar.mapPlayerRentcarBill.Remove(player.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("SERVER:updateRentCarBill")]
|
||||||
|
public void updateRentCarBill(Player player, int bill, int time)
|
||||||
|
{
|
||||||
|
if (canRentForFree(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
User user = player.GetUser(dbContext);
|
||||||
|
|
||||||
|
if (bill > user.BankAccount.Balance)
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(player, "Du hast nicht genügend Geld auf dem Konto. Die Fahrzeugmiete wird somit gekündigt");
|
||||||
|
cancelRent(player);
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mapPlayerRentcarBill.ContainsKey(player.Name))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.TriggerEvent("BN_Show", "Fahrzeug seit ~b~" + time + "~w~ Sekunden gemietet. Gesamtkosten: ~g~" + bill + "$");
|
||||||
|
mapPlayerRentcarBill[player.Name] = (mapPlayerRentcarBill[player.Name].Item1, bill);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("SERVER:rentcarBooked")]
|
||||||
|
public void rentcarBooked(Player player, string vehicleName, int price, String rentcarLocation)
|
||||||
|
{
|
||||||
|
if (player.GetData<bool>("hasRentcar") == true)
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(player, "Du hast bereits ein Fahrzeug gemeietet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!uint.TryParse(vehicleName, out uint uHash))
|
||||||
|
uHash = NAPI.Util.GetHashKey(vehicleName);
|
||||||
|
|
||||||
|
if (!VehicleManager.IsValidHash(uHash))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
User user = player.GetUser(dbContext);
|
||||||
|
|
||||||
|
if (price > user.BankAccount.Balance)
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(player, "Du hast nicht genügend Geld auf dem Konto.");
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
Vehicle v = null;
|
||||||
|
|
||||||
|
if (rentcarLocation == "noobspawn")
|
||||||
|
{
|
||||||
|
v = NAPI.Vehicle.CreateVehicle(uHash, noobspawnVehicleSpawnPosition, (float)noobspawnVehicleSpawnHeading, 111, 111, engine: true);
|
||||||
|
}
|
||||||
|
else if (rentcarLocation == "stadthalle")
|
||||||
|
{
|
||||||
|
v = NAPI.Vehicle.CreateVehicle(uHash, stadthalleVehicleSpawnPosition, (float)stadthalleVehicleSpawnHeading, 111, 111, engine: true);
|
||||||
|
}
|
||||||
|
else if (rentcarLocation == "knast")
|
||||||
|
{
|
||||||
|
v = NAPI.Vehicle.CreateVehicle(uHash, knastVehicleSpawnPosition, (float)knastVehicleSpawnHeading, 111, 111, engine: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VehicleStreaming.SetEngineState(v, true);
|
||||||
|
VehicleStreaming.SetLockStatus(v, false);
|
||||||
|
|
||||||
|
mapPlayerRentcarBill[player.Name] = (v, 0);
|
||||||
|
|
||||||
|
player.SendChatMessage("RentCar: Viel Spaß mit deinem Fahrzeug! Mit '/rent stop' kannst du die Miete kündigen");
|
||||||
|
|
||||||
|
if (canRentForFree(player))
|
||||||
|
{
|
||||||
|
player.SendChatMessage("RentCar: Da du neu in der Stadt bist, wird dir für die Fahrt keine Rechnung gestellt");
|
||||||
|
}
|
||||||
|
|
||||||
|
player.SetData("hasRentcar", true);
|
||||||
|
player.TriggerEvent("triggerRentcarTimer", PAY_TIMER, price);
|
||||||
|
}
|
||||||
|
public static bool canRentForFree(Player player)
|
||||||
|
{
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
User user = player.GetUser(dbContext);
|
||||||
|
|
||||||
|
if (user.PlayedMinutes < PAYTIME_FREE * 60)
|
||||||
|
{
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
ReallifeGamemode.Server/Util/RentcarProperty.cs
Normal file
18
ReallifeGamemode.Server/Util/RentcarProperty.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Server.Util
|
||||||
|
{
|
||||||
|
class RentcarProperty
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int Price { get; set; }
|
||||||
|
|
||||||
|
public RentcarProperty(String n, int p){
|
||||||
|
Name = n;
|
||||||
|
Price = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user