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

284 lines
13 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.Jobs.Pilot
{
class Pilot : Script
{
public Pilot()
{
Jobmanager.createJobPed(PedHash.Pilot01SMM, new Vector3(-1070.3, -2867.536,14.30582), 143, "", "");
RAPI.Marker.createMarker(1, new Vector3(-1070.737, -2868.138, 12.95191), 1, 0, 255, 0, "pilotjob", 0, 185, "Pilot", 0);
API.onEntityEnterColShape += onJobGUI;
Blip blip = API.createBlip(new Vector3(-1070.3, -2867.536,14.30582));
blip.sprite = 360;
blip.name = "Pilot";
API.onEntityEnterColShape += onMarkerHit;
API.onClientEventTrigger += onTrigger;
}
int level0gehalt = 3500;
int level1gehalt = 4500;
private void onTrigger(Client sender, string eventName, object[] arguments)
{
if (eventName == "triggerBackFromClient")
{
string job = (string)arguments[0];
if (job == "job:start:" + Jobmanager.Jobnames.pilot[0])
{
if (Environment.Fahrschule.doesPlayerhaveFlugzeugschein(sender))
{
if(Jobmanager.getPlayingHOURS(sender) >= 65)
{
if (Jobmanager.getJob(sender) == Jobmanager.Jobnames.pilot[0])
{
levelManager(sender);
}
else
{
API.sendNotificationToPlayer(sender, "~r~Du musst den Job erstmal annehmen!");
}
} else {
API.sendNotificationToPlayer(sender,"Du musst mind. 65 Spielstunden haben!");
}
}
else
{
API.sendNotificationToPlayer(sender, "~r~Du hast kein Flugzeug Schein!");
}
}
}
}
public void levelManager(Client sender)
{
int level = Levelsystem.getPlayerLevel(sender);
if(level == 0){
generateLevel0(sender);
} else {
generateLevel1(sender);
}
}
//////////////
//// LEVEL 0
/////////////
public void generateLevel0(Client player)
{
if(player.vehicle != null){
player.vehicle.delete();
}
Random zufall = new Random();
int next = zufall.Next(1,5);
Vector3 ziellinie = new Vector3();
Vehicle veh = API.createVehicle(VehicleHash.Buzzard2, new Vector3(-1112.863,-2884.622,13.84463), new Vector3(0,0,-30),0,0,0 );
RAPI.MainAPI.requestGhostMode(veh,10, API);
API.setPlayerIntoVehicle(player, veh, -1);
API.sendNotificationToPlayer(player,"Fliege die Fracht nun zu der Markierung!");
ClientAPI.ShowColorShard(player,"Piloten Job Level: 0", "Fliege die Fracht zum Marker!",0,2,5000);
// Ziellinie generation
if(next == 0){
ziellinie = new Vector3(112.323,2659.808,37); // NOT WORKIN reported by Sonny_Alcapone
} else if(next == 1){
ziellinie = new Vector3(1767.292,3239.237,41);
} else if(next == 2){
ziellinie = new Vector3(1773.665,3656.118,34.277);
}else if(next == 3){
ziellinie = new Vector3(1423.438,3613.816,34.860725);
} else if(next == 4){
ziellinie = new Vector3(2531.421,4211.238,38.9);
} else if(next == 5){
ziellinie = new Vector3(2701.502,3445.892,55.69925);
}
// Setting Playerdata for verification
API.setEntityData(player,"pilot",true);
API.setEntityData(veh,"pilot",true);
API.sendNotificationToPlayer(player,"Random: " + next);
// Creating the Marker
ColShape col = API.createCylinderColShape(ziellinie,5,10);
col.setData("pilot:marker:level:0",true);
ClientAPI.createClientMarker(player,7, ziellinie,6,255,255,0,100);
// Creating a blip for localization
ClientAPI.createClientBlip(player, ziellinie, 515,0);
// Verschönerung des Fahrzeugs
GrandTheftMultiplayer.Server.Elements.Object box = API.createObject(377646791, new Vector3(0,0,0),new Vector3(0,0,0),0);
API.setEntityCollisionless(box,false);
API.attachEntityToEntity(box,veh,"SKEL_ROOT",new Vector3(0,0,0.3),new Vector3(0,0,0));
API.setEntityData(veh,"box",box);
}
//////////////
//// LEVEL 1
/////////////
public void generateLevel1(Client player)
{
if(player.vehicle != null){
player.vehicle.delete();
}
Random zufall = new Random();
int next = zufall.Next(0,5);
Vector3 ziellinie = new Vector3();
Vehicle veh = API.createVehicle(VehicleHash.Buzzard2, new Vector3(-1112.863,-2884.622,13.84463), new Vector3(0,0,-30),0,0,0 );
RAPI.MainAPI.requestGhostMode(veh,10, API);
API.setPlayerIntoVehicle(player, veh, -1);
API.sendNotificationToPlayer(player,"Fliege die Fracht nun zu der Markierung!");
ClientAPI.ShowColorShard(player,"Piloten Job Level: 1", "Fliege die Fracht zum Marker!",0,2,5000);
// Ziellinie generation
if(next == 0){
ziellinie = new Vector3(112.323,2659.808,37);
} else if(next == 1){
ziellinie = new Vector3(1767.292,3239.237,41);
} else if(next == 2){
ziellinie = new Vector3(1773.665,3656.118,34.277);
}else if(next == 3){
ziellinie = new Vector3(1423.438,3613.816,34.860725);
} else if(next == 4){
ziellinie = new Vector3(2531.421,4211.238,38.9);
} else if(next == 5){
ziellinie = new Vector3(2701.502,3445.892,55.69925);
}
// Setting Playerdata for verification
API.setEntityData(player,"pilot",true);
API.setEntityData(veh,"pilot",true);
API.sendNotificationToPlayer(player,"Random: " + next);
// Creating the Marker
ColShape col = API.createCylinderColShape(ziellinie,5,10);
col.setData("pilot:marker:level:1",true);
ClientAPI.createClientMarker(player,7, ziellinie,6,255,255,0,100);
// Creating a blip for localization
ClientAPI.createClientBlip(player, ziellinie, 515,0);
// Verschönerung des Fahrzeugs
GrandTheftMultiplayer.Server.Elements.Object box = API.createObject(1916770868, new Vector3(0,0,0),new Vector3(0,0,0),0);
API.setEntityCollisionless(box,false);
API.attachEntityToEntity(box,veh,"SKEL_ROOT",new Vector3(0,0,0.3),new Vector3(0,0,0));
API.setEntityData(veh,"box",box);
}
//////////////
//// Bring back home
/////////////
public void bringBackHome(Client player)
{
Vector3 home = new Vector3(-1112.863,-2884.622,13.84463);
ColShape col = API.createCylinderColShape(home,3,3);
col.setData("pilot:marker:home",true);
col.setData("pilot:owner", player);
ClientAPI.createClientMarker(player,7,home,6,255,0,0,100);
ClientAPI.ShowColorShard(player,"Job Erfolgreich!", "Fliege wieder zum Flughafen!",0,2,5000);
}
private void onMarkerHit(ColShape colshape, NetHandle entity)
{
if(colshape != null && entity != null)
{
if(colshape.hasData("pilot:marker:level:0") == true && colshape.getData("pilot:marker:level:0") == true)
{
Client player = API.getPlayerFromHandle(entity);
if(player != null){
Vehicle veh = player.vehicle;
if(veh.hasData("pilot") == true && veh.getData("pilot") == true){
Client driver = player;
if(driver.hasData("pilot") == true && driver.getData("pilot") == true)
{
Levelsystem.addPlayerLevelFortschritt(driver,1,API);
ClientAPI.deleteClientMarker(driver);
ClientAPI.deleteClientBlip(driver);
API.deleteColShape(colshape);
bringBackHome(driver);
Jobmanager.setPayDayMoney(driver,Jobmanager.getPayDayMoney(driver) + level0gehalt);
API.sendChatMessageToPlayer(driver,"Du hast $" + level0gehalt + " Gehalt zum Payday bekommen!");
GrandTheftMultiplayer.Server.Elements.Object ob = API.getEntityData(veh,"box");
ob.delete();
}
}
}
} else if(colshape.hasData("pilot:marker:level:1") == true && colshape.getData("pilot:marker:level:1") == true){
Client player = API.getPlayerFromHandle(entity);
if(player != null){
Vehicle veh = player.vehicle;
if(veh.hasData("pilot") == true && veh.getData("pilot") == true){
Client driver = player;
if(driver.hasData("pilot") == true && driver.getData("pilot") == true)
{
GrandTheftMultiplayer.Server.Elements.Object ob = API.getEntityData(veh,"box");
ob.delete();
Levelsystem.addPlayerLevelFortschritt(driver,1,API);
ClientAPI.deleteClientMarker(driver);
ClientAPI.deleteClientBlip(driver);
API.deleteColShape(colshape);
bringBackHome(driver);
Jobmanager.setPayDayMoney(driver,Jobmanager.getPayDayMoney(driver) + level1gehalt);
API.sendChatMessageToPlayer(driver,"Du hast $" + level1gehalt + " Gehalt zum Payday bekommen!");
}
}
}
}
else if(colshape.hasData("pilot:marker:home") == true && colshape.getData("pilot:marker:home") == true)
{
Client player = API.getEntityFromHandle<Client>(entity);
if(colshape.hasData("pilot:owner") == true && colshape.getData("pilot:owner") == player){
if(player.vehicle != null){
Vehicle veh = player.vehicle;
if(veh.occupants != null)
{
if(veh.hasData("pilot") == true && veh.getData("pilot") == true){
Client driver = veh.occupants[0];
if(driver.hasData("pilot") == true && driver.getData("pilot") == true)
{
ClientAPI.deleteClientMarker(driver);
ClientAPI.deleteClientBlip(driver);
API.deleteColShape(colshape);
levelManager(driver);
}
}
}
}
}
}
}
}
/// GIT TESTING
private void onJobGUI(ColShape colshape, NetHandle entity)
{
if (colshape != null && entity != null)
{
if (colshape.getData("pilotjob") == true)
{
Client player = API.getPlayerFromHandle(entity);
Jobmanager.acceptFenster(player, Jobmanager.Jobnames.pilot, 100);
}
}
}
}
}