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

427 lines
16 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.Admin
{
class admin_cmds : Script
{
// 13 | 10 | 11
public admin_cmds()
{
API.onPlayerExitVehicle += onIceclawexit;
API.onClientEventTrigger += ClientTrigger;
}
private void ClientTrigger(Client sender, string eventName, object[] arguments)
{
if (eventName == "setTorso")
{
string torso = (string)arguments[0];
int torsoid = Convert.ToInt32(torso);
API.setPlayerClothes(sender, 11, torsoid, 1);
}
else if (eventName == "setUnderShirt")
{
string undershirt = (string)arguments[0];
int undershirtid = Convert.ToInt32(undershirt);
API.setPlayerClothes(sender, 8, undershirtid, 1);
}
else if (eventName == "setTorsoFix")
{
string undershirt = (string)arguments[0];
int undershirtid = Convert.ToInt32(undershirt);
API.setPlayerClothes(sender, 3, undershirtid, 0);
}
}
[Command("tank")]
public void setSyncedData(Client player, int value)
{
if (API.getEntityData(player, "adminlevel") > 3)
{
API.setEntitySyncedData(player.vehicle, "tank", value);
}
}
[Command("dcar")]
public void dcar(Client player)
{
if (API.getEntityData(player, "adminlevel") > 3)
{
player.vehicle.delete();
}
}
[Command("novoice")]
public void novoice(Client player){
if(API.getEntityData(player,"novoice") != true && API.getEntityData(player,"adminlevel") > 2){
//ACTIVATE
TextLabel tx = API.createTextLabel("~r~Nicht im Voicechat!", player.position.Add(new Vector3(0,0,1)), 10,1,true,0);
tx.attachTo(player,"SKEL_ROOT", new Vector3(0,0,1), new Vector3(0,0,0));
API.setEntityData(player,"textlabel",tx);
API.setEntityData(player,"novoice",true);
} else {
TextLabel tx = API.getEntityData(player,"textlabel");
tx.delete();
API.setEntityData(player,"novoice",false);
}
}
[Command("u",GreedyArg = true)]
public void Adminchat(Client player, string message)
{
if (API.getEntityData(player, "adminlevel") > 3)
{
API.sendChatMessageToAll("~r~Projektleitung " + player.name + " : ~w~" + message);
}
}
[Command("spectate")]
public void spectate(Client player, int id)
{
if (API.getEntityData(player, "adminlevel") > 3)
{
Client target = Commands.cmdLoginRegister.getPlayerFromID(id);
if (API.isPlayerSpectating(player) == false)
{
foreach (Client all in API.getAllPlayers())
{
if (all != null)
{
if (isAdmin(all, 3))
{
API.sendNotificationToPlayer(all, player.name + " spectated gerade " + target.name + "!", true);
}
}
}
API.setPlayerToSpectatePlayer(player, target);
API.consoleOutput("Administrator: " + player.name + " spectate gerade " + target.name);
}
else
{
API.setPlayerToSpectatePlayer(player, player);
}
}
}
[Command("getID")]
public void getID(Client player, Client target){
if(API.getEntityData(player,"getID") != true && API.getEntityData(player,"adminlevel") > 2){
//ACTIVATE
TextLabel tx = API.createTextLabel("ID:" + Realnames.getPlayerID(target), player.position.Add(new Vector3(0,0,1)), 10,1,true,0);
tx.attachTo(target,"SKEL_ROOT", new Vector3(0,0,1), new Vector3(0,0,0));
API.setEntityData(target,"textlabel",tx);
API.setEntityData(target,"getID",true);
} else {
TextLabel tx = API.getEntityData(target,"textlabel");
tx.delete();
API.setEntityData(target,"getID",false);
}
}
[Command("resolve")]
public void resolveID(Client player, int id)
{
if (API.getEntityData(player, "adminlevel") > 3)
{
Client target = Commands.cmdLoginRegister.getPlayerFromID(id);
API.sendNotificationToPlayer(player, "Name: " + target.name);
API.sendNotificationToPlayer(player, "Fraktion: " + Fraktionen.Fraktionsmanager.getFraktionsName(Fraktionen.Fraktionsmanager.getFraktion(target)));
API.sendNotificationToPlayer(player, "Fraktionsrang: " + Fraktionen.Fraktionsmanager.getFraktionsRang(target));
}
}
[Command("pse")]
public void pse(Client player, string pse)
{
API.triggerClientEvent(player, "pse", pse);
}
[Command("acar")]
public void adminvehicle(Client player, string model, int r = 255, int g = 255, int b = 0)
{
if (API.getEntityData(player, "adminlevel") > 3)
{
if (API.hasEntityData(player, "Adminmode") == true && API.getEntityData(player, "Adminmode") == true)
{
VehicleHash vh = API.vehicleNameToModel(model);
Vehicle veh = RAPI.MainAPI.createRolePlayVehicle(vh, player.position, player.rotation, 0, 255, 0);
/* TextLabel tx = API.createTextLabel("~r~Adminfahrzeug~n~~b~" + player.name, new Vector3(veh.position.X, veh.position.Y, veh.position.Z), 6, 1, false, 0);
tx.attachTo(veh, "SKEL_ROOT", new Vector3(0, 0, 1), new Vector3(0, 0, 0));*/
API.setPlayerIntoVehicle(player, veh, -1);
API.setEntityData(veh, "admin:acar", true);
API.setEntitySyncedData(veh, "tank", 100);
API.setVehicleCustomPrimaryColor(veh, r, g, b);
API.sendNotificationToPlayer(player, "~g~Fahrzeug erstellt!", true);
foreach (Client all in API.getAllPlayers())
{
if (all != null)
{
if (isAdmin(all, 3))
{
API.sendNotificationToPlayer(all, player.name + " hat sich ein Adminfahrzeug gegeben!", true);
}
}
}
} else
{
API.sendNotificationToPlayer(player, "Du musst in den Admin modus gehen!");
}
}
}
private void onIceclawexit(Client player, NetHandle vehicle, int x)
{
if (player != null && vehicle != null)
{
if (API.hasEntityData(vehicle, "admin:acar") == true && API.getEntityData(vehicle, "admin:acar") == true)
{
if (player.name == "Iceclaw.")
{
Vehicle veh = API.getEntityFromHandle<Vehicle>(vehicle);
veh.delete();
API.sendNotificationToPlayer(player, "Für dich immer mein Schnukiii <3 PS Script| Schleimer PS Sascha");
}
}
}
}
[Command("spawnobject")]
public void spawnobject(Client player, int model){
if (API.getEntityData(player, "adminlevel") > 3)
{
API.createObject(model, player.position, player.rotation, 0);
}
}
[Command("weather")]
public void weather(Client player, int weather)
{
if (API.getEntityData(player, "adminlevel") > 3)
{
API.setWeather(weather);
}
}
[Command("tp")]
public void TeleportPlayerToPlayerCommand(Client sender, Client target)
{
if (API.getEntityData(sender, "adminlevel") > 3)
{
var pos = API.getEntityPosition(sender.handle);
sender.dimension = target.dimension;
API.createParticleEffectOnPosition("scr_rcbarry1", "scr_alien_teleport", pos, new Vector3(), 1f);
API.setEntityPosition(sender.handle, API.getEntityPosition(target.handle));
}
}
[Command("tphere")]
public void TeleportPlayerToPlayerCommand2(Client sender, Client target)
{
if (API.getEntityData(sender, "adminlevel") > 3 )
{
var pos = API.getEntityPosition(sender.handle);
target.dimension = sender.dimension;
API.createParticleEffectOnPosition("scr_rcbarry1", "scr_alien_teleport", pos, new Vector3(), 1f);
API.setEntityPosition(target.handle, API.getEntityPosition(sender.handle));
}
}
[Command("weapon", Alias = "w,gun")]
public void GiveWeaponCommand(Client sender, WeaponHash weapon)
{
if (API.getEntityData(sender, "adminlevel") > 3)
{
API.consoleOutput("Administrator: " + sender.name + " gibt sich die Waffe: " + weapon.ToString());
API.givePlayerWeapon(sender, weapon, 9999, true, true);
}
}
[Command("repair")]
public void repair(Client player)
{
if (API.getEntityData(player, "adminlevel") > 3)
{
if (player.isInVehicle == true)
{
API.repairVehicle(player.vehicle);
}
}
}
[Command("nude")]
public void getNude(Client player)
{
if (API.getEntityData(player, "adminlevel") > 3)
{
API.setPlayerClothes(player, 3, 15, 0);
API.setPlayerClothes(player, 11, 35, 12);
API.setPlayerClothes(player, 8, 13, 16);
API.sendNotificationToPlayer(player, "~g~B~y~I~g~T~y~C~g~H ~w~Mode Activated!", true);
}
}
[Command("top")]
public void scrolltrough(Client player, int top)
{
if (API.getEntityData(player, "adminlevel") > 3)
{
//API.setPlayerClothes(player, 8, top, 1); // UNDERSHIRT
API.setPlayerClothes(player, 3, top, 0);
API.setPlayerClothes(player, 11, top, 1);
}
}
[Command("save")]
public void save(Client player)
{
if (API.getEntityData(player, "adminlevel") > 3)
{
PlayerDatabase.setSpawnPosition(player);
}
}
[Command("tploc")]
public void tp(Client player, int x, int y, int z)
{
if (API.getEntityData(player, "adminlevel") > 3)
{
if (player.isInVehicle != true)
{
Vector3 vec = new Vector3(x, y, z);
API.setEntityPosition(player, vec);
}
else
{
Vector3 vec = new Vector3(x, y, z);
API.setEntityPosition(player.vehicle, vec);
}
}
}
[Command("loc")]
public void loc(Client player)
{
if (API.getEntityData(player, "adminlevel") > 3)
{
API.sendChatMessageToPlayer(player, "POSITION: new Vector3(" + player.position.X + ", " + player.position.Y + ", " + player.position.Z + ")");
API.sendChatMessageToPlayer(player, "ROTATION: new Vector3(" + player.rotation.X + ", " + player.rotation.Y + ", " + player.rotation.Z + ")");
}
}
[Command("createSkinCombination")]
public void skinCombination(Client player)
{
if (API.getEntityData(player, "adminlevel") > 3)
{
API.triggerClientEvent(player, "createTorsoMenu");
}
}
[Command("ab")]
public void adminbike(Client player)
{
if(isAdmin(player,3) == true)
{
Vehicle veh = RAPI.MainAPI.createRolePlayVehicle(VehicleHash.Shotaro, player.position, player.rotation, 0, 0, 0, 255, 255, 0,"System");
API.setVehicleSpecialLightStatus(veh, true);
}
}
[Command("lipl")]
public void loadipl(Client player, string ipl)
{
if(isAdmin(player,3) == true)
{
API.requestIpl(ipl);
}
}
[Command("a")]
public void openAdminMenue(Client player)
{
if(isAdmin(player,3) == true)
{
if(API.hasEntityData(player,"Adminmode") == false || API.getEntityData(player,"Adminmode") == false)
{
API.setEntityData(player, "Adminmode", true);
API.sendNotificationToAll("~c~Der Admin: " + player.name + " ist jetzt im ~b~Adminmodus~c~!");
API.setEntityInvincible(player, true);
if(API.hasEntityData(player, "geschlecht") == true && API.getEntityData(player, "geschlecht") == 1)
{
API.setPlayerClothes(player, 4, 77, 0);
API.setPlayerClothes(player, 11, 178, 0);
API.setPlayerClothes(player, 6, 55, 0);
API.setPlayerClothes(player, 8, 57, 0);
API.setPlayerAccessory(player, 0, 91, 0);
}
else if (API.getEntityData(player, "geschlecht") == 0)
{
API.setPlayerClothes(player, 4, 79, 0);
API.setPlayerClothes(player, 11, 180, 0);
API.setPlayerClothes(player, 6, 58, 0);
API.setPlayerClothes(player, 8, 2, 0);
API.setPlayerAccessory(player, 0, 90, 0);
API.setPlayerAccessory(player, 3, 0, 0);
}
API.setEntityData(player, "Adminmode", true);
}
else if(API.getEntityData(player,"Adminmode") == true)
{
API.resetEntityData(player, "Adminmode");
API.sendNotificationToAll("~c~Der Admin: " + player.name + " ist nicht mehr im ~b~Adminmodus~c~!");
API.setEntityInvincible(player, false);
string skin = PlayerDatabase.getSkin(player);
PedHash pedskin = API.pedNameToModel(skin);
API.setPlayerSkin(player, pedskin);
API.setPlayerNametagColor(player, 255, 255, 255);
Database.CharacterDatabase.setPlayerDatabaseClothes(player, API);
API.setPlayerAccessory(player, 0, 11, 0);
}
}
}
public static bool isAdmin(Client player, int level)
{
if(API.shared.hasEntityData(player,"adminlevel") == true && API.shared.getEntityData(player,"adminlevel") >= level)
{
return true;
}
else
{
return false;
}
}
}
}