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

361 lines
18 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 Grove : Script
{
public Grove()
{
LoadGrove();
loadAusleih();
}
public const int FskinCallback = 648516841;
public const int WaffenCallback = 415978598;
public void LoadGrove()
{
RAPI.Marker.createMarker(0,new Vector3(151.8,-1001.229,-99),1,255,0,0,"fskin:grove", 641651, 185, "Grove Skin's", 0); // FSKIN
RAPI.Marker.createMarker(0,new Vector3(1286.731, -1604.463, 54.8249),1,255,0,0, "fhaus:grove", 0,185,"Fraktionshaus",0); // HAUS
RAPI.Marker.createMarker(0, new Vector3(151.3165, -1007.962, -99), 1, 255, 0, 0, "fhaus:groveout", 641651, 185, "Fraktionshaus", 0); // HAUS
RAPI.Marker.createMarker(0, new Vector3(151.3256, -1003.2, -99), 1, 255, 0, 0, "waffenmarker:grove", 641651, 185, "Waffen", 0); // HAUS
API.onEntityEnterColShape += EnterColShape;
API.onClientEventTrigger += onTrigger;
}
// AUSLEIH START
public const int CALLBACKDUDE = 852633631;
public const int ausleihfraktionsid = 4;
public Vector3 ped = new Vector3(1226.284,-1599.727,52.117);
public const int heading = -149;
public Vector3 spawnpos = new Vector3(1227.861,-1605.46,52.3091);
public const float spawnposrot = -151;
public Vector3 marker = new Vector3(1227.166,-1600.975,51.07936);
public const String coldata = "Ausleih:Grove";
public void loadAusleih() // CALL ON INIT!!!!
{
API.onClientEventTrigger += onTriggera;
API.onEntityEnterColShape += onCol;
API.createPed(PedHash.Families01GFY, 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, 28, 90, 17);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Grove");
}
} 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, 28, 90, 17);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Grove");
}
} 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, 28, 90, 17);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Grove");
}
} 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, 28, 90, 17);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Grove");
}
} 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, 28, 90, 17);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Grove");
}
} 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, 28, 90, 17);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Grove");
}
} 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, 28, 90, 17);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Grove");
}
} 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, 28, 90, 17);
API.setEntityData(veh, "Fraktionsfahrzeug", ausleihfraktionsid);
API.setEntitySyncedData(veh, "locked", true);
API.sendNativeToPlayersInDimension(0, Hash.SET_VEHICLE_DOORS_LOCKED, veh, 2);
API.setVehicleNumberPlate(veh, "Grove");
}
}
}
}
}
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.RampGang);
PlayerDatabase.setDatabaseDataString(sender, "skinid", "RampGang");
}
else if(index == 1)
{
API.setPlayerSkin(sender, PedHash.Famca01GMY);
PlayerDatabase.setDatabaseDataString(sender, "skinid", "Famca01GMY");
}
else if(index == 2)
{
API.setPlayerSkin(sender, PedHash.Famdd01);
PlayerDatabase.setDatabaseDataString(sender, "skinid", "Famdd01");
}
else if (index == 3)
{
API.setPlayerSkin(sender, PedHash.Famdnf01GMY);
PlayerDatabase.setDatabaseDataString(sender, "skinid", "Famdnf01GMY");
}
else if (index == 4)
{
API.setPlayerSkin(sender, PedHash.Families01GFY);
PlayerDatabase.setDatabaseDataString(sender, "skinid", "Families01GFY");
}
else if (index == 5)
{
API.setPlayerSkin(sender, PedHash.Famfor01GMY);
PlayerDatabase.setDatabaseDataString(sender, "skinid", "Famfor01GMY");
}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(4);
if (index == 0)
{
if(mats >= 10)
{
Aktionen.BadFraktionmanager.setFraktionsKassenValue(4, "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(4, "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(4, "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:grove") == true && colshape.getData("fskin:grove") == true)
{
Client player = API.getPlayerFromHandle(entity);
if (Fraktionsmanager.isGrove(player) == true)
{
object[] argumentList = new object[30];
argumentList[0] = FskinCallback;
argumentList[1] = "Grove";
argumentList[2] = "Skins:";
argumentList[3] = false;
argumentList[4] = 7;
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:grove") == true && colshape.getData("fhaus:grove") == true)
{
Client player = API.getPlayerFromHandle(entity);
if (Fraktionsmanager.getFraktion(player) == 4)
{
API.setEntityPosition(player, new Vector3(152.65, -1004, -99));
API.setEntityDimension(player, 641651);
}
} else if(colshape.hasData("fhaus:groveout") == true && colshape.getData("fhaus:groveout") == true)
{
Client player = API.getPlayerFromHandle(entity);
if (player != null && Fraktionsmanager.getFraktion(player) == 4)
{
API.setEntityPosition(player, new Vector3(1286.36, -1601.178, 54.24323));
API.setEntityDimension(player, 0);
}
}
else if (colshape.hasData("waffenmarker:grove") == true && colshape.getData("waffenmarker:grove") == true)
{
Client player = API.getPlayerFromHandle(entity);
if (Fraktionsmanager.getFraktion(player) == 4)
{
object[] argumentList = new object[20];
argumentList[0] = WaffenCallback;
argumentList[1] = "Grove";
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);
}
}
}
}
}
}