Added /invite, removed some unneccessary debug lines
This commit is contained in:
52
Server/Commands/User.cs
Normal file
52
Server/Commands/User.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Model;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace reallife_gamemode.Server.Commands
|
||||
{
|
||||
class User : Script
|
||||
{
|
||||
[Command("accept", "~m~Benutzung: ~s~/accept [invite]")]
|
||||
public void CmdUserAccept(Client player, string option)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
|
||||
option = option.ToLower();
|
||||
|
||||
switch(option)
|
||||
{
|
||||
case "invite":
|
||||
{
|
||||
if(!player.HasData("accept_invite"))
|
||||
{
|
||||
player.SendChatMessage("~r~[FEHLER]~s~ Du hast keine Einladung in eine Fraktion erhalten.");
|
||||
return;
|
||||
}
|
||||
|
||||
using(var dbContext = new DatabaseContext())
|
||||
{
|
||||
Client leader = NAPI.Player.GetPlayerFromHandle((NetHandle)player.GetData("accept_invite"));
|
||||
Entities.User u = leader.GetUser(dbContext);
|
||||
Entities.User own = player.GetUser(dbContext);
|
||||
|
||||
own.FactionId = u.FactionId;
|
||||
own.FactionLeader = false;
|
||||
own.FactionRankId = dbContext.FactionRanks.
|
||||
OrderBy(x => x.Order)
|
||||
.FirstOrDefault(r => r.FactionId == own.FactionId)?.Id ?? null;
|
||||
|
||||
leader.SendChatMessage("!{02FCFF}" + player.Name + " hat die Einladung angenommen.");
|
||||
player.SendChatMessage("!{02FCFF}Du hast die Einladung angenommen.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user