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

389 lines
19 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.KeinName
{
class Vagos : Script
{
public Vagos()
{
LoadVagos();
loadAusleih();
}
public const int FskinCallback = 648516842;
public const int WaffenCallback = 415978599;
public void LoadVagos()
{
RAPI.Marker.createMarker(0, new Vector3(-1072.355, -1676.994, 4.501204), 1, 255, 0, 0, "fskin:vagos", 0, 185, "Vagos Skin's", 0); // FSKIN
RAPI.Marker.createMarker(0, new Vector3(-1077.211, -1646.372, 4.501204), 1, 255, 0, 0, "fhaus:vagos", 0, 185, "Fraktionshaus", 0); // HAUS
RAPI.Marker.createMarker(0, new Vector3(151.3165, -1007.962, -99), 1, 255, 0, 0, "fhaus:vagosout", 634341, 185, "Fraktionshaus", 0); // HAUS
RAPI.Marker.createMarker(0, new Vector3(-1077.355, -1676.994, 4.501204), 1, 255, 0, 0, "waffenmarker:vagos", 0, 185, "Waffen", 0); // HAUS
API.onEntityEnterColShape += EnterColShape;
API.onClientEventTrigger += onTrigger;
}
// AUSLEIH START
public const int CALLBACKDUDE = 852633632;
public const int ausleihfraktionsid = 10;
public Vector3 ped = new Vector3(-1067.037, -1676.108, 4.532598);
public const int heading = -1;
public Vector3 spawnpos = new Vector3(-1074.567, -1665.858, 4.438267);
public const float spawnposrot = -1;
public Vector3 marker = new Vector3(-1067.788, -1673.664, 2.928125);
public const String coldata = "Ausleih:vagos";
public void loadAusleih() // CALL ON INIT!!!!
{
API.onClientEventTrigger += onTriggera;
API.onEntityEnterColShape += onCol;
API.createPed(PedHash.Vagos01GFY, ped, heading, 0);
RAPI.Marker.createMarker(1, marker, 1, 255, 255, 255, coldata, 0, 185, "Fahrzeuge", 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.Bmx, spawnpos, new Vector3(0, 0, spawnposrot), 0, 0, 0);
API.setPlayerIntoVehicle(sender, veh, -1);
API.setVehicleCustomPrimaryColor(veh, 255, 255, 0);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Vagos");
}
}
else if (index == 1)
{
if (Fraktionsmanager.getFraktionsRang(sender) >= 0)
{
Vehicle veh = API.createVehicle(VehicleHash.Moonbeam, spawnpos, new Vector3(0, 0, spawnposrot), 0, 0, 0);
API.setPlayerIntoVehicle(sender, veh, -1);
API.setVehicleCustomPrimaryColor(veh, 255, 255, 0);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Vagos");
}
}
else if (index == 2)
{
if (Fraktionsmanager.getFraktionsRang(sender) >= 0)
{
Vehicle veh = API.createVehicle(VehicleHash.Primo2, spawnpos, new Vector3(0, 0, spawnposrot), 0, 0, 0);
API.setPlayerIntoVehicle(sender, veh, -1);
API.setVehicleCustomPrimaryColor(veh, 255, 255, 0);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Vagos");
}
}
else if (index == 3)
{
if (Fraktionsmanager.getFraktionsRang(sender) >= 0)
{
Vehicle veh = API.createVehicle(VehicleHash.Glendale, spawnpos, new Vector3(0, 0, spawnposrot), 0, 0, 0);
API.setPlayerIntoVehicle(sender, veh, -1);
API.setVehicleCustomPrimaryColor(veh, 255, 255, 0);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Vagos");
}
}
else if (index == 4)
{
if (Fraktionsmanager.getFraktionsRang(sender) >= 0)
{
Vehicle veh = API.createVehicle(VehicleHash.Tornado, spawnpos, new Vector3(0, 0, spawnposrot), 0, 0, 0);
API.setPlayerIntoVehicle(sender, veh, -1);
API.setVehicleCustomPrimaryColor(veh, 255, 255, 0);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Vagos");
}
}
else if (index == 5)
{
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.setVehicleCustomPrimaryColor(veh, 255, 255, 0);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Vagos");
}
}
else if (index == 6)
{
if (Fraktionsmanager.getFraktionsRang(sender) >= 0)
{
Vehicle veh = API.createVehicle(VehicleHash.Rebel, spawnpos, new Vector3(0, 0, spawnposrot), 0, 0, 0);
API.setPlayerIntoVehicle(sender, veh, -1);
API.setVehicleCustomPrimaryColor(veh, 255, 255, 0);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Vagos");
}
}
else if (index == 7)
{
if (Fraktionsmanager.getFraktionsRang(sender) >= 0)
{
Vehicle veh = API.createVehicle(VehicleHash.Peyote, spawnpos, new Vector3(0, 0, spawnposrot), 0, 0, 0);
API.setPlayerIntoVehicle(sender, veh, -1);
API.setVehicleCustomPrimaryColor(veh, 255, 255, 0);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Vagos");
}
}
}
}
}
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!");
}
}
}
}
}
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] = "BMX"; // RANG 0 /ID Police
argumentList[6] = "Moonbeam"; // RANG 0 /ID Police
argumentList[7] = "Primo2"; // RANG 1 - 2 / ID Police2
argumentList[8] = "Glendale"; // RANG 1 - 2 / ID Police2
argumentList[9] = "Tornado"; // RANG 1 - 2 / ID Police2
argumentList[10] = "Dubsta"; // RANG 1 - 2 / ID Police2
argumentList[11] = "Rebel"; // RANG 1 - 2 / ID Police2
argumentList[12] = "Peyote"; // RANG 1 - 2 / ID Police2
for (var i = 0; i < itemlength; i++)
{
argumentList[13 + i] = "";
}
API.shared.triggerClientEvent(player, "menu_handler_create_menu", argumentList);
}
/// AUSLEIH END
private void onTrigger(Client sender, string eventName, object[] arguments)
{
if (eventName == "menu_handler_select_item")
{
int callback = (int)arguments[0];
if (callback == FskinCallback)
{
int index = (int)arguments[1];
if (index == 0)
{
API.setPlayerSkin(sender, PedHash.Tourist01AFY);
PlayerDatabase.setDatabaseDataString(sender, "skinid", "Tourist01AFY");
}
else if (index == 1)
{
API.setPlayerSkin(sender, PedHash.VagosSpeakCutscene);
PlayerDatabase.setDatabaseDataString(sender, "skinid", "VagosSpeakCutscene");
}
else if (index == 2)
{
API.setPlayerSkin(sender, PedHash.VagosFun01);
PlayerDatabase.setDatabaseDataString(sender, "skinid", "VagosFun01");
}
else if (index == 3)
{
API.setPlayerSkin(sender, PedHash.Vagos01GFY);
PlayerDatabase.setDatabaseDataString(sender, "skinid", "Vagos01GFY");
}
else if (index == 4)
{
API.setPlayerSkin(sender, PedHash.Tonya);
PlayerDatabase.setDatabaseDataString(sender, "skinid", "Tonya");
}
else if (index == 5)
{
API.setPlayerSkin(sender, PedHash.Skater01AMY);
PlayerDatabase.setDatabaseDataString(sender, "skinid", "Skater01AMY");
}
else if (index == 6)
{
string skin = PlayerDatabase.getSkin(sender);
PedHash pedskin = API.pedNameToModel(skin);
API.setPlayerSkin(sender, pedskin);
Database.CharacterDatabase.setPlayerDatabaseClothes(sender, API);
}
}
else if (callback == WaffenCallback)
{
int index = (int)arguments[1];
int mats = Aktionen.BadFraktionmanager.getFraktionsMats(10);
if (index == 0)
{
if (mats >= 10)
{
Aktionen.BadFraktionmanager.setFraktionsKassenValue(10, "Materialien", mats - 10);
API.givePlayerWeapon(sender, WeaponHash.KnuckleDuster, 1, false, true);
}
else
{
API.sendNotificationToPlayer(sender, "Ihr habt nicht genug Materialien!");
}
}
else if (index == 1)
{
if (mats >= 20)
{
Aktionen.BadFraktionmanager.setFraktionsKassenValue(10, "Materialien", mats - 20);
API.givePlayerWeapon(sender, WeaponHash.KnuckleDuster, 1, false, true);
API.givePlayerWeapon(sender, WeaponHash.Bat, 1, false, true);
}
else
{
API.sendNotificationToPlayer(sender, "Ihr habt nicht genug Materialien!");
}
}
else if (index == 2)
{
if (mats >= 30)
{
Aktionen.BadFraktionmanager.setFraktionsKassenValue(10, "Materialien", mats - 40);
API.givePlayerWeapon(sender, WeaponHash.KnuckleDuster, 1, false, true);
API.givePlayerWeapon(sender, WeaponHash.Bat, 1, false, true);
API.givePlayerWeapon(sender, WeaponHash.Knife, 1, false, true);
API.givePlayerWeapon(sender, WeaponHash.Pistol, 100, false, true);
API.givePlayerWeapon(sender, WeaponHash.MicroSMG, 200, true, true);
API.givePlayerWeaponComponent(sender, WeaponHash.MicroSMG, WeaponComponent.MicroSMGClip01);
}
else
{
API.sendNotificationToPlayer(sender, "Ihr habt nicht genug Materialien!");
}
}
}
}
}
private void EnterColShape(ColShape colshape, NetHandle entity)
{
if (entity != null && colshape != null)
{
if (colshape.hasData("fskin:vagos") == true && colshape.getData("fskin:vagos") == true)
{
Client player = API.getPlayerFromHandle(entity);
if (Fraktionsmanager.isVagos(player) == true)
{
object[] argumentList = new object[72];
argumentList[0] = FskinCallback;
argumentList[1] = "Vagos";
argumentList[2] = "Skins:";
argumentList[3] = false;
argumentList[4] = 8;
argumentList[5] = "~r~Skin 1";
argumentList[6] = "~r~Skin 2";
argumentList[7] = "~r~Skin 3";
argumentList[8] = "~r~Skin 4";
argumentList[9] = "~r~Skin 5";
argumentList[10] = "~r~Skin 6";
argumentList[11] = "~r~Standart Skin";
API.triggerClientEvent(player, "menu_handler_create_menu", argumentList);
}
}
else if (colshape.hasData("fhaus:vagos") == true && colshape.getData("fhaus:vagos") == true)
{
Client player = API.getPlayerFromHandle(entity);
if (Fraktionsmanager.getFraktion(player) == 10)
{
API.setEntityPosition(player, new Vector3(152.65, -1004, -99));
API.setEntityDimension(player, 634341);
}
}
else if (colshape.hasData("fhaus:vagosout") == true && colshape.getData("fhaus:vagosout") == true)
{
Client player = API.getPlayerFromHandle(entity);
if (player != null && Fraktionsmanager.getFraktion(player) == 10)
{
API.setEntityPosition(player, new Vector3(-1079.211, -1646.372, 4.501204));
API.setEntityDimension(player, 0);
}
}
else if (colshape.hasData("waffenmarker:vagos") == true && colshape.getData("waffenmarker:vagos") == true)
{
Client player = API.getPlayerFromHandle(entity);
if (Fraktionsmanager.getFraktion(player) == 10)
{
object[] argumentList = new object[20];
argumentList[0] = WaffenCallback;
argumentList[1] = "Vagos";
argumentList[2] = "Waffenpackete:";
argumentList[3] = false;
argumentList[4] = 3;
argumentList[5] = "~b~Kleines Packet";
argumentList[6] = "~y~Mittleres Packet";
argumentList[7] = "~r~Grosses Packet";
argumentList[8] = "~c~ 10 Mats";
argumentList[9] = "~c~ 20 Mats";
argumentList[10] = "~c~ 30 Mats";
API.triggerClientEvent(player, "menu_handler_create_menu", argumentList);
}
}
}
}
}
}