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

308 lines
15 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.Environment
{
class mobile : Script
{
public const int CALLBACKMOBILE = 651;
public const int CALLBACKMOBILE_ANRUF = 6512;
public const int CALLBACKMOBILE_SMS = 6513;
public const int CALLBACKMOBILE_VEHICLES = 1556468;
public mobile()
{
API.onClientEventTrigger += MObile;
}
public bool canwerbung = true;
private void MObile(Client sender, string eventName, object[] arguments)
{
if (eventName == "openHandy")
{
if (API.hasEntityData(sender,"loggedin") == true && API.getEntityData(sender, "loggedin") == true)
{
if (sender.dimension == 0)
{
Client player = API.getPlayerFromHandle(sender);
object[] argumentList = new object[16];
argumentList[0] = CALLBACKMOBILE;
argumentList[1] = "Handy";
argumentList[2] = "Optionen:";
argumentList[3] = false;
argumentList[4] = 4;
argumentList[5] = "Anrufen";
argumentList[6] = "SMS";
argumentList[7] = "Notruf";
argumentList[8] = "Werbung schalten";
for (var i = 0; i < 4; i++)
{
argumentList[9 + i] = "";
}
API.triggerClientEvent(player, "menu_handler_create_menu", argumentList);
// API.playPlayerScenario(sender, "WORLD_HUMAN_STAND_MOBILE"); PUSH IN UPDATES
}
}
}
else if (eventName == "menu_handler_select_item")
{
int callback = (int)arguments[0];
int index = (int)arguments[1];
if (callback == CALLBACKMOBILE)
{
if (index == 0)
{
var list = API.getAllPlayers();
list.Remove(sender);
var itemsLen = list.Count;
object[] argumentList = new object[5 + itemsLen + itemsLen];
argumentList[0] = CALLBACKMOBILE_ANRUF;
argumentList[1] = "Anrufen";
argumentList[2] = "Waehle einen Spieler aus";
argumentList[3] = false;
argumentList[4] = itemsLen;
var i = 0;
foreach (Client player in list)
{
argumentList[5 + i] = player.name;
argumentList[5 + itemsLen + i] = "";
i++;
}
API.shared.triggerClientEvent(sender, "menu_handler_create_menu", argumentList);
}
else if(index == 1)
{
var list = API.getAllPlayers();
list.Remove(sender);
var itemsLen = list.Count;
object[] argumentList = new object[5 + itemsLen + itemsLen];
argumentList[0] = CALLBACKMOBILE_SMS;
argumentList[1] = "SMS";
argumentList[2] = "Waehle einen Spieler aus";
argumentList[3] = false;
argumentList[4] = itemsLen;
var i = 0;
foreach (Client player in list)
{
argumentList[5 + i] = player.name;
argumentList[5 + itemsLen + i] = "";
i++;
}
API.shared.triggerClientEvent(sender, "menu_handler_create_menu", argumentList);
}
else if (index == 2)
{
object[] argumentList = new object[20];
argumentList[0] = CALLBACKMOBILE_SMS + 88;
argumentList[1] = "Fraktionen";
argumentList[2] = "Waehle eine Fraktion aus";
argumentList[3] = false;
int itemlength = 3;
argumentList[4] = itemlength;
argumentList[5] = "LSPD";
argumentList[6] = "Abschleppdienst";
argumentList[7] = "LSMC";
argumentList[8] = "";
API.triggerClientEvent(sender, "menu_handler_create_menu", argumentList);
}
else if(index == 3)
{
API.triggerClientEvent(sender, "get_user_input", CALLBACKMOBILE_SMS + 1, "Werbung", 35, sender);
}
else if(index == 4)
{
List<Vehicle> privates = Vehiclesystem.VehicleMain.getPrivateVehicles(sender);
object[] argslist = new object[7 + privates.Count * 2];
argslist[0] = CALLBACKMOBILE_VEHICLES;
argslist[1] = "Fahrzeuge";
argslist[2] = "Optionen:";
argslist[3] = true;
argslist[4] = privates.Count + 1;
argslist[5] = "~r~Verlassen";
var i = 0;
foreach (var s in privates)
{
string x = "Unbekannt";
Vehicle veh = privates[i];
x = veh.displayName;
argslist[6 + i] = x;
i++;
}
API.triggerClientEvent(sender, "menu_handler_create_menu", argslist);
}
}
else if(callback == CALLBACKMOBILE_ANRUF)
{
string player = (string) arguments[2];
API.sendNotificationToPlayer(sender, "Anruf wird aufgebaut!");
createAnruf(sender, API.getPlayerFromName(player));
}
else if(callback == CALLBACKMOBILE_SMS)
{
string player = (string)arguments[2];
API.triggerClientEvent(sender, "get_user_input", CALLBACKMOBILE_SMS,"Text",500, player);
} else if(callback == CALLBACKMOBILE_SMS + 88)
{
if(index == 0)
{
// LSPD
API.triggerClientEvent(sender, "get_user_input", CALLBACKMOBILE_SMS + 44, "Text", 500, "LSPD");
} else if(index == 1){
API.triggerClientEvent(sender, "get_user_input", CALLBACKMOBILE_SMS + 44, "Text", 500, "Abschlepp");
} else if(index == 2){
API.triggerClientEvent(sender, "get_user_input", CALLBACKMOBILE_SMS + 44, "Text", 500, "LSMC");
}
} else if(callback == CALLBACKMOBILE_VEHICLES){
if(index != 0){
List<Vehicle> privates = Vehiclesystem.VehicleMain.getPrivateVehicles(sender);
Vehicle selectedVehicle = privates[index - 1];
ClientAPI.createClientBlipTime(sender,selectedVehicle.position,380,49,60*3);
ClientAPI.setClientBlipRouteEnabled(sender,true);
API.sendNotificationToPlayer(sender,"Fahrzeug wurde mit einem Icon für 3 Minutenn auf der Karte markiert! ");
}
}
}
else if(eventName == "menu_handler_user_input")
{
int callback = (int)arguments[0];
if (callback == CALLBACKMOBILE_SMS)
{
string text = (string)arguments[1];
string target = (string)arguments[2];
API.sendNotificationToPlayer(sender, "~g~Versendet!", true);
API.sendPictureNotificationToPlayer(API.getPlayerFromName(target), text, "CHAR_ARTHUR",1,0,sender.name,"SMS");
} else if(callback == CALLBACKMOBILE_SMS + 1)
{
if(canwerbung == true)
{
if (Environment.MONEY.Money.hasBarMoney(sender, 500) == true)
{
string text = (string)arguments[1];
API.sendChatMessageToAll("~b~ Werbung von: " + sender.name + ": " + text);
Environment.MONEY.Money.giveBarMoney(sender, -500, API);
canwerbung = false;
API.delay(60000 * 3, true, () => { canwerbung = true; });
}
else
{
API.sendNotificationToPlayer(sender, "Du hast nicht genug Bargeld dabei!");
}
} else
{
API.sendNotificationToPlayer(sender, "Es kann erst in 3 Minuten wieder Werbung geschaltet werden!");
}
} else if(callback == CALLBACKMOBILE_SMS + 44)
{
string text = (string)arguments[1];
string target = (string)arguments[2];
if(target == "LSPD")
{
API.sendNotificationToPlayer(sender, "~g~Versendet!", true);
Fraktionen.Fraktionsmanager.sendFraktionsChatMessage(1, "~r~ Eingehender Notruf von ID: ~y~" + sender.name + " : ~c~" + text);
API.setEntityData(sender, "notruf", true);
} else if(target == "Abschlepp"){
API.sendNotificationToPlayer(sender, "~g~Versendet!", true);
Fraktionen.Fraktionsmanager.sendFraktionsChatMessage(6, "~r~ Eingehender Auftrag von ID: ~y~" + sender.name + " : ~c~" + text);
API.setEntityData(sender, "notruf", true);
} else if(target == "LSMC"){
API.sendNotificationToPlayer(sender, "~g~Versendet!", true);
Fraktionen.Fraktionsmanager.sendFraktionsChatMessage(7, "~r~ Eingehender Notruf von ID: ~y~" + sender.name + " : ~c~" + text);
API.setEntityData(sender, "notruf", true);
}
}
}
}
[Command("acceptnotruf", Alias = "acn")]
public void acceptnotruf(Client player, Client target)
{
if (player != null && target != null)
{
if (API.hasEntityData(target, "notruf") == true && API.getEntityData(target, "notruf") == true)
{
API.sendNotificationToPlayer(target, "~r~Der Spieler: ~y~" + player.name + " ~r~hat den Notruf entgegen genommen!");
API.sendNotificationToPlayer(player, "~r~Du hast den Notruf von: " + target.name + " entgegen genommen!");
API.triggerClientEvent(player, "showNotrufblip", target.position);
API.sendNotificationToPlayer(player, "~r~ Spieler wurde rot Markiert!");
API.delay(1000 * 60 * 5, true, () => {
API.triggerClientEvent(player, "destroyNotrufblip");
API.sendNotificationToPlayer(player, "~r~ Die Markierung wurde aufgehoben!");
});
}
}
}
public void createAnruf(Client player, Client target)
{
if(player.hasData("anruf:isimanruf") == false && target.hasData("anruf:isimanruf") == false){
API.shared.setEntityData(player,"anruf:partner",target);
API.shared.setEntityData(target,"anruf:partner",player);
API.shared.setEntityData(target,"anruf:isimanruf",true);
API.shared.setEntityData(player,"anruf:isimanruf",true);
API.shared.setEntityData(target,"anruf:gettingcalled",true);
API.sendNotificationToPlayer(player,"Spieler wird angerufen...");
API.sendNotificationToPlayer(target,"Du wirst von: " + player.name + " angerufen! ~g~/abheben ~w~ oder ~r~/auflegen");
ClientAPI.playMP3(target,"sounds//ringtone.mp3", true);
} else {
API.sendNotificationToPlayer(player,"~r~Einer der beiden Teilnehmer telefoniert schon!");
}
}
[Command("abheben")]
public void abheben(Client player)
{
if(player.hasData("anruf:gettingcalled") == true)
{
Client partner = player.getData("anruf:partner");
player.resetData("anruf:gettingcalled");
ClientAPI.stopMp3(player);
ClientAPI.stopMp3(partner );
Teamspeak.addToSpeakingList(player, partner);
Teamspeak.addToSpeakingList(partner, player);
}
else
{
API.sendNotificationToPlayer(player,"~r~Du wirst nicht angerufen!");
}
}
[Command("auflegen")]
public void auflegen(Client player)
{
if(player.hasData("anruf:isimanruf") == true){
Client partner = API.getEntityData(player,"anruf:partner");
API.resetEntityData(partner,"anruf:partner");
API.resetEntityData(player,"anruf:partner");
API.shared.resetEntityData(player,"anruf:isimanruf");
API.shared.resetEntityData(partner,"anruf:isimanruf");
API.shared.resetEntityData(player,"anruf:gettingcalled");
API.shared.resetEntityData(partner,"anruf:gettingcalled");
Teamspeak.removeFromSpeakingList(partner,player);
Teamspeak.removeFromSpeakingList(player,partner);
API.sendNotificationToPlayer(partner,"Der Partner hat aufgelegt!");
API.sendNotificationToPlayer(player,"Du hast aufgelegt!");
ClientAPI.stopMp3(player);
ClientAPI.stopMp3(partner);
} else {
API.sendNotificationToPlayer(player,"~r~Du bist nicht im Anruf!");
}
}
}
}