add interactionmenu find cars as member & add funcation give money
This commit is contained in:
@@ -151,6 +151,8 @@ namespace ReallifeGamemode.Server.Events
|
||||
adminLevel = u.AdminLevel.GetName(),
|
||||
points = u.Points,
|
||||
faction = u.Faction?.Name ?? "Zivilist",
|
||||
factionleader = u.Faction?.Name ?? "Zivilist",
|
||||
//factionleader = u.FactionLeader,
|
||||
stateFaction = u.Faction?.StateOwned,
|
||||
factionRank = u.GetFactionRank().RankName,
|
||||
group = u.Group?.Name ?? "Keine",
|
||||
@@ -163,18 +165,26 @@ namespace ReallifeGamemode.Server.Events
|
||||
nextPayday = u.PaydayTimer
|
||||
};
|
||||
|
||||
string faction = u.FactionLeader ? u.Faction.Name : null;
|
||||
string faction = u.Faction.Name;
|
||||
string factionleader = u.FactionLeader ? u.Faction.Name : null;
|
||||
string group = u.Group != null && u.GroupRank >= GroupRank.MANAGER ? u.Group.Name : null;
|
||||
bool factionInvite = player.HasData("accept_faction_invite");
|
||||
bool groupInvite = player.HasData("accept_group_invite");
|
||||
bool ticket_boolean = player.HasData("ticket_boolean");
|
||||
int ticket_amount = 0;
|
||||
int pay_amount = 0;
|
||||
|
||||
if (player.HasData("ticket_amount"))
|
||||
{
|
||||
ticket_amount = player.GetData<int>("ticket_amount");
|
||||
}
|
||||
|
||||
player.TriggerEvent("SERVER:InteractionMenu_OpenMenu", JsonConvert.SerializeObject(accountData), faction, group, factionInvite, groupInvite, ticket_boolean, ticket_amount);
|
||||
if(player.HasData("pay_amount"))
|
||||
{
|
||||
pay_amount = player.GetData<int>("pay_amount");
|
||||
}
|
||||
|
||||
player.TriggerEvent("SERVER:InteractionMenu_OpenMenu", JsonConvert.SerializeObject(accountData), factionleader, faction, group, factionInvite, groupInvite, ticket_boolean, ticket_amount, pay_amount);
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:E")]
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user