add interactionmenu find cars as member & add funcation give money

This commit is contained in:
Michael
2020-06-02 14:40:54 +02:00
parent 499dced44e
commit 32540c4aa9
3 changed files with 167 additions and 11 deletions

View File

@@ -394,8 +394,24 @@ namespace ReallifeGamemode.Server.Managers
if (selection == "Finden")
{
player.TriggerEvent("SERVER:Util_setWaypoint", veh.Position.X, veh.Position.Y);
}
}
[RemoteEvent("CLIENT:InteractionMenu_FactionVehicleInteractionSell")]
public void FactionVehicleInteractionSell(Player player, int id, string selection)
{
using var dbContext = new DatabaseContext(true);
var user = player.GetUser(dbContext);
var factionVehicle = dbContext.FactionVehicles.ToList().Where(v => v.Id == id && v.GetOwners().Contains(user.FactionId.Value)).FirstOrDefault();
if (factionVehicle == null)
{
ChatService.ErrorMessage(player, "Das Fahrzeug wurde nicht gefunden");
}
else if (selection == "Verkaufen")
GTANetworkAPI.Vehicle veh = VehicleManager.GetVehicleFromServerVehicle(factionVehicle);
if (selection == "Verkaufen")
{
if (dbContext.FactionVehicles.ToList().Where(f => f.GetOwners().Contains(user.FactionId.Value)).Count() <= 6)
{
@@ -588,6 +604,50 @@ namespace ReallifeGamemode.Server.Managers
}
}
[RemoteEvent("CLIENT:InteractionMenu_Pay")]
public void InteractionMenu_Pay(Player player, string jsonNameOrId, string stringAmount)
{
string nameOrId = (string)JsonConvert.DeserializeObject(jsonNameOrId);
int amount = Int32.Parse(stringAmount);
Player target = PlayerService.GetPlayerByNameOrId(nameOrId);
string playername = NAPI.Player.GetPlayerName(player);
string targetname = NAPI.Player.GetPlayerName(target);
if (target == null || !target.IsLoggedIn())
{
ChatService.PlayerNotFound(player);
return;
}
else if (target == player)
{
player.SendNotification("~r~Du kannst dir selber kein Geld geben!");
}
else
{
if (amount > 0 && amount < 5000)
{
player.SendNotification($"~w~Du hast ~y~{targetname} ~w~ ${amount} gegeben.");
target.SendNotification($"~w~ Du hast von ~y~{playername} ~w~ ${amount}$ erhalten.", true);
target.SetData<int>("pay_amount", amount);
player.SendChatMessage("hallo debug player");
target.SendChatMessage("hallo debug target");
using (var dbContext = new DatabaseContext())
{
target.GetUser(dbContext).Handmoney += amount;
player.GetUser(dbContext).Handmoney -= amount;
dbContext.SaveChanges();
}
target.ResetData("pay_amount");
target.ResetData("pay_player");
}
else
{
player.SendNotification("~r~ Du kannst nur zwischen $1 und $5.000 geben!");
}
}
}
#endregion Eigeninteraktionen PFEILTASTE-RUNTER
#region Spielerinteraktionen PFEILTASTE-LINKS