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

248 lines
12 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GrandTheftMultiplayer.Server.API;
using GrandTheftMultiplayer.Server.Constant;
using GrandTheftMultiplayer.Server.Elements;
using GrandTheftMultiplayer.Server.Managers;
using GrandTheftMultiplayer.Shared;
using GrandTheftMultiplayer.Shared.Math;
namespace Roleplay.Fraktionen.InkassoFraktion
{
class FraktionInkasso : Script
{
public FraktionInkasso()
{
LoadInkasso();
loadAusleih();
}
public void LoadInkasso()
{
Blip fraktionsblip = API.createBlip(new Vector3(-69.85867, -795.8649, 43.80201));
fraktionsblip.sprite = 408;
fraktionsblip.color = 74;
}
public const String coldata = "Ausleih:Inkasso";
public const String coldatabr = "Umkleide:Inkasso";
public const int heading = 0;
public const int CALLBACKDUDE = 852653631;
public const int CALLBACKSKIN = 852673631;
public const int ausleihfraktionsid = 8;
public Vector3 ped = new Vector3(-84.90427, -825.0122, 36.02813);
public Vector3 marker = new Vector3(-84.37603, -820.6373, 35.02793);
public Vector3 spawnpos = new Vector3(-79.46456,-800.2308,36.86352);
public Vector3 markerburaeu = new Vector3(-62.47383, -795.1749, 43.22591);
public const float spawnposrot = -8;
public void loadAusleih() // CALL ON INIT!!!!
{
API.onClientEventTrigger += onTriggera;
API.onEntityEnterColShape += onCol;
API.onClientEventTrigger += onTrigger;
API.onEntityEnterColShape += EnterColShape;
API.createPed(PedHash.Andreas, ped,heading,0);
RAPI.Marker.createMarker(1, marker,1,255,255,255,coldata,0,185,"Inkasso-Fahrzeuge",0);
RAPI.Marker.createMarker(1, markerburaeu,1,255,255,255,coldatabr,0,185,"Inkasso-Umkleide",0);
}
public void onTriggera(Client sender, String eventname, object[] args)
{
if(eventname == "menu_handler_select_item"){
int callback = (int) args[0];
int index = (int) args[1];
if(callback == CALLBACKDUDE){
if(index == 0){
if (Fraktionsmanager.getFraktionsRang(sender) >= 0)
{
Vehicle veh = API.createVehicle(VehicleHash.Dilettante, spawnpos, new Vector3(0, 0, spawnposrot), 0, 0, 0);
API.setPlayerIntoVehicle(sender, veh, -1);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Inkasso");
}
} else if(index == 1){
if (Fraktionsmanager.getFraktionsRang(sender) >= 0)
{
Vehicle veh = API.createVehicle(VehicleHash.Chino2, spawnpos, new Vector3(0, 0, spawnposrot), 0, 0, 0);
API.setPlayerIntoVehicle(sender, veh, -1);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Inkasso");
}
} else if(index == 2){
if (Fraktionsmanager.getFraktionsRang(sender) >= 0)
{
Vehicle veh = API.createVehicle(VehicleHash.Faction, spawnpos, new Vector3(0, 0, spawnposrot), 0, 0, 0);
API.setPlayerIntoVehicle(sender, veh, -1);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Inkasso");
}
} else if(index == 3){
if (Fraktionsmanager.getFraktionsRang(sender) >= 0)
{
Vehicle veh = API.createVehicle(VehicleHash.Windsor2, spawnpos, new Vector3(0, 0, spawnposrot), 0, 0, 0);
API.setPlayerIntoVehicle(sender, veh, -1);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Inkasso");
}
} else if(index == 4){
if (Fraktionsmanager.getFraktionsRang(sender) >= 0)
{
Vehicle veh = API.createVehicle(VehicleHash.Mesa, spawnpos, new Vector3(0, 0, spawnposrot), 0, 0, 0);
API.setPlayerIntoVehicle(sender, veh, -1);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Inkasso");
}
} else if(index == 5){
if (Fraktionsmanager.getFraktionsRang(sender) >= 0)
{
Vehicle veh = API.createVehicle(VehicleHash.Sandking2, spawnpos, new Vector3(0, 0, spawnposrot), 0, 0, 0);
API.setPlayerIntoVehicle(sender, veh, -1);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Inkasso");
}
} else if(index == 6){
if (Fraktionsmanager.getFraktionsRang(sender) >= 0)
{
Vehicle veh = API.createVehicle(VehicleHash.Baller4, spawnpos, new Vector3(0, 0, spawnposrot), 0, 0, 0);
API.setPlayerIntoVehicle(sender, veh, -1);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Inkasso");
}
} else if(index == 7){
if (Fraktionsmanager.getFraktionsRang(sender) >= 0)
{
Vehicle veh = API.createVehicle(VehicleHash.Dubsta, spawnpos, new Vector3(0, 0, spawnposrot), 0, 0, 0);
API.setPlayerIntoVehicle(sender, veh, -1);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Inkasso");
}
}
}
}
}
public void showAusleihMenu(Client player){
object[] argumentList = new object[56];
argumentList[0] = CALLBACKDUDE;
argumentList[1] = "Fahrzeuge";
argumentList[2] = "Fahrzeuge:";
argumentList[3] = false;
int itemlength = 8;
argumentList[4] = itemlength;
argumentList[5] = "Dilettante"; // RANG 0 /ID Police
argumentList[6] = "Chino"; // RANG 0 /ID Police
argumentList[7] = "Faction"; // RANG 1 - 2 / ID Police2
argumentList[8] = "Ruiner"; // RANG 1 - 2 / ID Police2
argumentList[9] = "Mesa"; // RANG 1 - 2 / ID Police2
argumentList[10] = "Sandking"; // RANG 1 - 2 / ID Police2
argumentList[11] = "Baller"; // RANG 1 - 2 / ID Police2
argumentList[12] = "Dubsta"; // RANG 1 - 2 / ID Police2
for (var i = 0; i < itemlength; i++)
{
argumentList[13 + i] = "";
}
API.shared.triggerClientEvent(player, "menu_handler_create_menu", argumentList);
}
public void showUmkleideMenu(Client player)
{
object[] argumentList = new object[56];
argumentList[0] = CALLBACKSKIN;
argumentList[1] = "Inkasso";
argumentList[2] = "Umkleide:";
argumentList[3] = false;
int itemlength = 4;
argumentList[4] = itemlength;
argumentList[5] = "~r~Male1";
argumentList[6] = "~r~Male2";
argumentList[7] = "~r~Male3";
argumentList[8] = "~r~Female1";
for (var i = 0; i < itemlength; i++)
{
argumentList[9 + i] = "";
}
API.triggerClientEvent(player, "menu_handler_create_menu", argumentList);
}
public void onCol(ColShape col, NetHandle nt)
{
if(col != null && nt != null){
if(col.hasData(coldata) == true && col.getData(coldata) == true){
Client player = API.getPlayerFromHandle(nt);
if(player != null){
if(Fraktionsmanager.getFraktion(player) == ausleihfraktionsid){
showAusleihMenu(player);
} else {
API.sendNotificationToPlayer(player,"Du bist nicht in der Richtigen Fraktion!");
}
}
}
}
}
private void EnterColShape(ColShape colshape, NetHandle entity)
{
if(entity != null && colshape != null)
{
if(colshape.hasData("Umkleide:Inkasso") == true && colshape.getData("Umkleide:Inkasso") == true)
{
Client player = API.getPlayerFromHandle(entity);
if (Fraktionsmanager.getFraktion(player) == ausleihfraktionsid)
{
showUmkleideMenu(player);
}
}
}
}
private void onTrigger(Client sender, string eventName, object[] arguments)
{
if(eventName == "menu_handler_select_item")
{
int callback = (int)arguments[0];
if(callback == CALLBACKSKIN)
{
int index = (int) arguments[1];
if(index == 0)
{
API.setPlayerSkin(sender, PedHash.Agent14);
}
else if(index == 1)
{
API.setPlayerSkin(sender, PedHash.Andreas);
}
else if(index == 2)
{
API.setPlayerSkin(sender, PedHash.Barry);
}else if(index == 3)
{
API.setPlayerSkin(sender, PedHash.Abigail);
}
}
}
}
}
}