Ragemp-roleplay-skript/Fraktionen/Fraktionsmanager.cs
2019-04-16 13:59:07 +02:00

1026 lines
31 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;
namespace Roleplay.Fraktionen
{
class Fraktionsmanager : Script
{
public Fraktionsmanager()
{
}
public static String getFraktionsName(int id)
{
if(id == 0)
{
return "Zivilist";
}
else if(id == 1)
{
return "LSPD";
}
else if(id == 2)
{
return "Weazel News";
}
else if (id == 3)
{
return "Front Yard Ballas";
}
else if (id == 4)
{
return "Grove Street";
}
else if (id == 5)
{
return "Regierung";
}
else if (id == 6)
{
return "Abschleppdienst";
}
else if(id == 7)
{
return "LSMC";
}else if(id == 8)
{
return "Inkasso";
}else if(id == 9)
{
return "Bloods";
}else if(id == 10)
{
return "Vagos";
}else if(id == 11)
{
return "FIB";
}
else
{
return "Zivilist";
}
}
public static String getWithColorCodesFraktionsName(int id)
{
if (id == 0)
{
return "Zivilist";
}
else if (id == 1)
{
return "~b~LSPD";
}else if(id == 2)
{
return "~y~Weazel News";
}
else if (id == 3)
{
return "~p~Front Yard Ballas";
}
else if (id == 4)
{
return "~g~Grove Street";
}
else if (id == 5)
{
return "~w~Regierung";
}
else if (id == 6)
{
return "~r~Abschleppdienst";
}
else if(id == 7)
{
return "~r~LSMC";
}else if(id == 8)
{
return "~b~Inkasso";
}else if(id == 9)
{
return ("~r~Bloods");
}else if(id == 10)
{
return ("~y~Vagos");
}else if(id == 11)
{
return ("~b~FIB");
}
else
{
return "Zivilist";
}
}
public static int getFraktionsRang(Client player)
{
int rang = API.shared.getEntityData(player, "fraktionsrang");
return rang;
}
public static int getFraktion(Client player)
{
int rang = API.shared.getEntityData(player, "fraktion");
return rang;
}
[Command("frespawn")]
public void frespawn(Client player)
{
if(Fraktionsmanager.getFraktion(player) > 1)
{
if(Fraktionsmanager.getFraktion(player) != 1 && Fraktionsmanager.getFraktion(player) != 2){
Aktionen.BadFraktionmanager.loadFraktionsFahrzeugebyid(getFraktion(player));
API.sendNotificationToPlayer(player, "Fahrzeuge wurden respawnt!");
}
}
}
public static Boolean isPD(Client player)
{
bool state = false;
if (API.shared.getEntityData(player, "fraktion") == 1)
{
state = true;
}
return state;
}
public static Boolean isStateFraktion(Client player) ///////////////////////////////////////////////
{
bool state = false;
if (API.shared.getEntityData(player, "fraktion") == 1 || API.shared.getEntityData(player,"fraktion") == 2 || API.shared.getEntityData(player,"fraktion") == 5)
{
state = true;
}
return state;
}
public static Boolean isBallas(Client player)
{
bool state = false;
if (API.shared.getEntityData(player, "fraktion") == 3)
{
state = true;
}
return state;
}
public static Boolean isInkasso(Client player)
{
bool state = false;
if(API.shared.getEntityData(player, "fraktion") == 8)
{
state = true;
}
return state;
}
public static Boolean isGrove(Client player)
{
bool state = false;
if (API.shared.getEntityData(player, "fraktion") == 4)
{
state = true;
}
return state;
}
public static Boolean isEvil(Client player)
{
bool state2 = false;
if (API.shared.getEntityData(player, "fraktion") == 3 || API.shared.getEntityData(player, "fraktion") == 4|| API.shared.getEntityData(player, "fraktion") == 9 || API.shared.getEntityData(player, "fraktion") == 10)
{
state2 = true;
}
return state2;
}
public static Boolean isWeazelNews(Client player)
{
bool state3 = false;
if (API.shared.getEntityData(player, "fraktion") == 2 )
{
state3 = true;
}
return state3;
}
public static Boolean isRegierung(Client player)
{
bool state3 = false;
if (API.shared.getEntityData(player, "fraktion") == 5 )
{
state3 = true;
}
return state3;
}
public static Boolean isAbschleppdienst(Client player)
{
bool state3 = false;
if (API.shared.getEntityData(player, "fraktion") == 6 )
{
state3 = true;
}
return state3;
}
public static Boolean isBloods(Client player)
{
bool state3 = false;
if (API.shared.getEntityData(player, "fraktion") == 9)
{
state3 = true;
}
return state3;
}
public static Boolean isVagos(Client player)
{
bool state3 = false;
if (API.shared.getEntityData(player, "fraktion") == 10)
{
state3 = true;
}
return state3;
}
public static Boolean isFIB(Client player)
{
bool state = false;
if(API.shared.getEntityData(player, "fraktion") == 11)
{
state = true;
}
return state;
}
public static bool isDuty(Client player)
{
bool state = false;
if (API.shared.getEntityData(player, "duty") == true)
{
state = true;
}
return state;
}
public static int getFraktionsgehalt(Client player)
{
int gehalt = 0;
if (Fraktionsmanager.getFraktion(player) == 1)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if(rang == 0)
{
gehalt = 2000;
} else if(rang == 1)
{
gehalt = 2500;
} else if(rang == 2)
{
gehalt = 2900;
}else if(rang == 3)
{
gehalt = 3500;
} else if(rang == 4)
{
gehalt = 3800;
} else if(rang == 5)
{
gehalt = 4200;
}
else if (rang == 6)
{
gehalt = 6000;
}
}else if(Fraktionsmanager.getFraktion(player) == 2)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if (rang == 0)
{
gehalt = 500;
}
else if (rang == 1)
{
gehalt = 1000;
}
else if (rang == 2)
{
gehalt = 1250;
}
else if (rang == 3)
{
gehalt = 1500;
}
else if (rang == 4)
{
gehalt = 1900;
}
}
else if(Fraktionsmanager.getFraktion(player) == 3)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if (rang == 0)
{
gehalt = 1000;
}
else if (rang == 1)
{
gehalt = 2000;
}
else if (rang == 2)
{
gehalt = 2300;
}
else if (rang == 3)
{
gehalt = 2700;
}
else if (rang == 4)
{
gehalt = 3500;
}
}
else if (Fraktionsmanager.getFraktion(player) == 4)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if (rang == 0)
{
gehalt = 1000;
}
else if (rang == 1)
{
gehalt = 2000;
}
else if (rang == 2)
{
gehalt = 2300;
}
else if (rang == 3)
{
gehalt = 2700;
}
else if (rang == 4)
{
gehalt = 3500;
}
}
else if (Fraktionsmanager.getFraktion(player) == 5)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if (rang == 0)
{
gehalt = 2500;
}
else if (rang == 1)
{
gehalt = 2000;
}
else if (rang == 2)
{
gehalt = 3000;
}
else if (rang == 3)
{
gehalt = 5000;
}
else if (rang == 4)
{
gehalt = 100000;
}
}
else if (Fraktionsmanager.getFraktion(player) == 6)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if (rang == 0)
{
gehalt = 1000;
}
else if (rang == 1)
{
gehalt = 3000;
}
else if (rang == 2)
{
gehalt = 3900;
}
else if (rang == 3)
{
gehalt = 4600;
}
else if (rang == 4)
{
gehalt = 5000;
}
}else if (Fraktionsmanager.getFraktion(player) == 7)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if (rang == 0)
{
gehalt = 1000;
}
else if (rang == 1)
{
gehalt = 3000;
}
else if (rang == 2)
{
gehalt = 3900;
}
else if (rang == 3)
{
gehalt = 4600;
}
else if (rang == 4)
{
gehalt = 5000;
}else if(rang == 5)
{
gehalt = 7000;
}
}else if(Fraktionsmanager.getFraktion(player) == 8)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if(rang == 0 )
{
gehalt = 1000;
}else if(rang == 1)
{
gehalt = 2000;
}else if(rang == 2)
{
gehalt = 3000;
}else if(rang == 3)
{
gehalt = 4000;
}else if(rang == 4)
{
gehalt = 30000;
}
}else if(Fraktionsmanager.getFraktion(player) == 9)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if(rang == 0)
{
gehalt = 1000;
}else if(rang == 1)
{
gehalt = 2000;
}else if(rang == 2)
{
gehalt = 3000;
}else if(rang == 3)
{
gehalt = 4000;
}else if(rang == 4)
{
gehalt = 5000;
}
}else if(Fraktionsmanager.getFraktion(player) == 10)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if (rang == 0)
{
gehalt = 1000;
}
else if (rang == 1)
{
gehalt = 2000;
}
else if (rang == 2)
{
gehalt = 3000;
}
else if (rang == 3)
{
gehalt = 4000;
}
else if (rang == 4)
{
gehalt = 5000;
}
}else if(Fraktionsmanager.getFraktion(player) == 11)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if(rang == 0)
{
gehalt = 2500;
}else if(rang == 1)
{
gehalt = 3500;
}else if(rang == 2)
{
gehalt = 4500;
}else if(rang == 3)
{
gehalt = 5000;
}else if(rang == 4)
{
gehalt = 6000;
}
}
return gehalt;
}
public static String getFraktionsRangName(Client player)
{
string rangname = "";
if (Fraktionsmanager.getFraktion(player) == 1)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if (rang == 0)
{
rangname = "Cadet";
}
else if (rang == 1)
{
rangname = "Officer";
}
else if (rang == 2)
{
rangname = "Corporal";
}
else if (rang == 3)
{
rangname = "Sergeant";
}
else if (rang == 4)
{
rangname = "Lieutenant";
}
else if (rang == 5)
{
rangname = "Captain";
}
else if (rang == 6)
{
rangname = "Chief";
}
} else if(Fraktionsmanager.getFraktion(player) == 3)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if (rang == 0)
{
rangname = "NGY";
}
else if (rang == 1)
{
rangname = "TY";
}
else if (rang == 2)
{
rangname = "BG";
}
else if (rang == 3)
{
rangname = "OBG";
}
else if (rang == 4)
{
rangname = "OG";
}
}
else if (Fraktionsmanager.getFraktion(player) == 4)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if (rang == 0)
{
rangname = "Rang 0";
}
else if (rang == 1)
{
rangname = "Rang 1";
}
else if (rang == 2)
{
rangname = "Rang 2";
}
else if (rang == 3)
{
rangname = "Rang 3";
}
else if (rang == 4)
{
rangname = "Rang 4";
}
}
else if (Fraktionsmanager.getFraktion(player) == 2)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if (rang == 0)
{
rangname = "Rang 0";
}
else if (rang == 1)
{
rangname = "Rang 1";
}
else if (rang == 2)
{
rangname = "Rang 2";
}
else if (rang == 3)
{
rangname = "Rang 3";
}
else if (rang == 4)
{
rangname = "Rang 4";
}
}
else if (Fraktionsmanager.getFraktion(player) == 5)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if (rang == 0)
{
rangname = "Sekretaerin";
}
else if (rang == 1)
{
rangname = "Special Officer";
}
else if (rang == 2)
{
rangname = "Special Agent";
}
else if (rang == 3)
{
rangname = "Chief of Staff";
}
else if (rang == 4)
{
rangname = "Praesident";
}
}
else if (Fraktionsmanager.getFraktion(player) == 6)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if (rang == 0)
{
rangname = "Lehrling";
}
else if (rang == 1)
{
rangname = "Geselle";
}
else if (rang == 2)
{
rangname = "Praktikantin";
}
else if (rang == 3)
{
rangname = "Fachmann";
}
else if (rang == 4)
{
rangname = "Opa";
}
}
else if(Fraktionsmanager.getFraktion(player) == 7)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if (rang == 0)
{
rangname = "Anfänger";
}
else if (rang == 1)
{
rangname = "Praktikant";
}
else if (rang == 2)
{
rangname = "Notartzt";
}
else if (rang == 3)
{
rangname = "Artz";
}
else if (rang == 4)
{
rangname = "Ersthelfer";
}
else if (rang == 5)
{
rangname = "Chief";
}
}else if(Fraktionsmanager.getFraktion(player) == 8)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if (rang == 0)
{
rangname = "Azubi";
}
else if(rang == 1)
{
rangname = "Helfer";
}
else if(rang == 2)
{
rangname = "Sekretär";
}
else if(rang == 3)
{
rangname = "Eintreiber";
}
else if(rang == 4)
{
rangname = "Chef";
}
}else if(Fraktionsmanager.getFraktion(player) == 9)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if (rang == 0)
{
rangname = "Rang 0";
}
else if (rang == 1)
{
rangname = "Rang 1";
}
else if (rang == 2)
{
rangname = "Rang 2";
}
else if (rang == 3)
{
rangname = "Rang 3";
}
else if (rang == 4)
{
rangname = "Rang 4";
}
}else if(Fraktionsmanager.getFraktion(player) == 10)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if (rang == 0)
{
rangname = "Rang 0";
}
else if (rang == 1)
{
rangname = "Rang 1";
}
else if (rang == 2)
{
rangname = "Rang 2";
}
else if (rang == 3)
{
rangname = "Rang 3";
}
else if (rang == 4)
{
rangname = "Rang 4";
}
}else if(Fraktionsmanager.getFraktion(player) == 11)
{
int rang = Fraktionsmanager.getFraktionsRang(player);
if(rang == 0)
{
rangname = "Azubi";
}else if(rang == 1)
{
rangname = "Verdeckter Ermittler";
}else if(rang == 2)
{
rangname = "Ermittler";
}else if(rang == 3)
{
rangname = "Richter";
}else if(rang == 4)
{
rangname = "Cheff";
}
}
return rangname;
}
public static bool isParaDuty(Client player)
{
bool state = false;
if (API.shared.getEntityData(player, "paraduty") == true)
{
state = true;
}
return state;
}
public static void sendBlipForFraktion(int fraktion,float x, float y, float z, int sprite = 0, int color = 0, int time = 1)
{
List<Client> all = API.shared.getAllPlayers();
foreach (Client player in all)
{
if (API.shared.getEntityData(player, "fraktion") == fraktion)
{
API.shared.triggerClientEvent(player,"createClientSideBlip",x,y,z,sprite,color,time);
}
}
}
public static List<Client> getAllOnlineFraktionsMember(int fraktion)
{
List<Client> all = API.shared.getAllPlayers();
List<Client> fraktionsmember = new List<Client>();
foreach (Client player in all)
{
if (getFraktion(player) == fraktion)
{
fraktionsmember.Add(player);
}
}
return fraktionsmember;
}
public static int getAllOnlineFraktionsMemberInt(int fraktion)
{
List<Client> all = API.shared.getAllPlayers();
List<Client> fraktionsmember = new List<Client>();
foreach (Client player in all)
{
if (getFraktion(player) == fraktion)
{
fraktionsmember.Add(player);
}
}
return Convert.ToInt32(fraktionsmember.Count);
}
public static void setDuty(Client player)
{
API.shared.setEntityData(player, "duty", true);
}
public static void setParamedicDuty(Client player, bool state)
{
API.shared.setEntityData(player, "paraduty", state);
}
public static void sendFraktionsChatMessage(int id, string message)
{
List<Client> all = API.shared.getAllPlayers();
foreach (Client player in all)
{
if (API.shared.getEntityData(player, "fraktion") == id)
{
API.shared.sendChatMessageToPlayer(player, message);
}
}
}
public static void sendFraktionsNotification(int id, string message, bool flashing)
{
List<Client> all = API.shared.getAllPlayers();
foreach (Client player in all)
{
if (API.shared.getEntityData(player, "fraktion") == id)
{
API.shared.sendNotificationToPlayer(player, message, flashing);
}
}
}
[Command("giverang")]
public void giverang(Client player, int playerid, int rang)
{
if (getFraktionsRang(player) >= 4)
{
Client target = Commands.cmdLoginRegister.getPlayerFromID(playerid);
API.setEntityData(target, "fraktionsrang", rang);
PlayerDatabase.setDatabaseData(target, PlayerDatabase.PlayerDatabaseFlags.fraktionrang, rang);
API.sendChatMessageToPlayer(target, "~r~Dein Fraktionsrang wurde auf: " + rang + " erhöht!");
API.sendNotificationToPlayer(player, "Du hast den Fraktionsrang des Spielers erhoeht!");
}
else
{
API.sendNotificationToPlayer(player, "Du hast nicht den erforderlichen Rang!");
}
}
[Command("invite")]
public void invite(Client player, int playerid)
{
if (getFraktionsRang(player) >= 4)
{
Client target = Commands.cmdLoginRegister.getPlayerFromID(playerid);
if (getFraktion(target) == 0)
{
API.setEntityData(target, "fraktion", getFraktion(player));
PlayerDatabase.setDatabaseData(target, PlayerDatabase.PlayerDatabaseFlags.fraktion, getFraktion(player));
API.sendChatMessageToPlayer(target, "~r~Du wurdest in eine Fraktion aufgenommen!");
API.sendNotificationToPlayer(player, "Du hast den Spieler: " + target.name + " in die Fraktion eingeladen!");
} else
{
API.sendNotificationToPlayer(player, "Der Spieler ist schon in einer Fraktion!");
}
}
else
{
API.sendNotificationToPlayer(player, "Du hast nicht den erforderlichen Rang!");
}
}
[Command("uninvite")]
public void uninvite(Client player, int playerid)
{
if (getFraktionsRang(player) >= 4)
{
Client target = Commands.cmdLoginRegister.getPlayerFromID(playerid);
API.setEntityData(target, "fraktion", 0);
PlayerDatabase.setDatabaseData(target, PlayerDatabase.PlayerDatabaseFlags.fraktion, 0);
API.sendChatMessageToPlayer(target, "~r~Du wurdest aus einer Fraktion gekickt!");
API.sendNotificationToPlayer(player, "~r~ Du hast den Spieler: " + target.name + " aus der Fraktion gekickt!");
}
else
{
API.sendNotificationToPlayer(player, "Du hast nicht den erforderlichen Rang!");
}
}
[Command("info")]
public void info(Client player)
{
API.sendNotificationToPlayer(player, "[INFO] FraktionsID: " + getFraktion(player));
API.sendNotificationToPlayer(player, "[INFO] FraktionsRang: " + getFraktionsRang(player));
}
public static int getWanteds(Client player)
{
return API.shared.getEntityData(player, "wanted");
}
public static void giveWanted(Client player,Client giver, int Wanteds, string reason){
if(getWanteds(player) + Wanteds < 60)
{
API.shared.sendPictureNotificationToPlayer(player, "~r~Officer " + giver.name + " hat dir " + Wanteds + " Wanteds gegeben!~y~ Grund: " + reason, "CHAR_CALL911",1,0,giver.name,"Verbrechen begangen!");
sendFraktionsNotification(1, "~r~" + giver.name + " hat " + player.name + " " + Wanteds + " Wanteds gegeben!",true);
API.shared.setEntityData(player, "wanted", Wanteds + getWanteds(player));
PlayerDatabase.setDatabaseData(player, "wanteds", getWanteds(player));
API.shared.triggerClientEvent(player, "update_wanted_display", getWanteds(player));
}
else
{
API.shared.sendNotificationToPlayer(giver, "Der Spieler hat schon mehr als 60 Wanteds!");
}
}
public static void setWanteds(Client player, int Wanteds)
{
API.shared.setEntityData(player, "wanted", Wanteds);
PlayerDatabase.setDatabaseData(player, "wanteds", Wanteds);
API.shared.triggerClientEvent(player, "update_wanted_display", Wanteds);
}
[Command("o", GreedyArg = true)]
public void staatchat(Client player, string nachricht)
{
if (isStateFraktion(player))
{
// STAATSFRAKTIONEN EINTRAGEN!
sendFraktionsChatMessage(1, "~r~~h~" + player.name +" : " + nachricht);
sendFraktionsChatMessage(5, "~r~~h~" + player.name +" : " + nachricht);
} else
{
API.sendNotificationToPlayer(player, "Du bist in keiner Staatsfraktion!");
}
}
[Command("f", GreedyArg = true)]
public void fraktionchat(Client player, string nachricht)
{
if (getFraktion(player) > 0)
{
sendFraktionsChatMessage(getFraktion(player), "~g~~h~ Rang: " + getFraktionsRangName(player) + " " + player.name + " : " + nachricht);
}
else
{
API.sendNotificationToPlayer(player, "Du bist in keiner Fraktion!");
}
}
}
}