229 lines
9.2 KiB
C#
229 lines
9.2 KiB
C#
using GrandTheftMultiplayer.Server.API;
|
|
using GrandTheftMultiplayer.Server.Constant;
|
|
using GrandTheftMultiplayer.Server.Elements;
|
|
using GrandTheftMultiplayer.Server.Managers;
|
|
using GrandTheftMultiplayer.Shared.Math;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Roleplay.Jobs
|
|
{
|
|
class Jobmanager : Script
|
|
{
|
|
public const int CALLBACK = 56461;
|
|
public Jobmanager()
|
|
{
|
|
API.onClientEventTrigger += onTrigger;
|
|
API.delay(60000 * 1, false,() => { oneminute(); });
|
|
}
|
|
|
|
public static class Jobnames{
|
|
// Job ident description requirements
|
|
public static string[] transporter = {"Transporter","Du musst Waren von A nach B fahren.","LKW-Schein"};
|
|
public static string[] greenkeeper = { "Greenkeeper", "Du musst den Golfplatz pflegen.", "Keine" };
|
|
public static string[] LifeGuard = { "LifeGuard", "Du musst den Strand abfahren.", "PKW Schein" };
|
|
public static string[] taxifahrer = { "Taxifahrer", "Du musst Spieler von A nach B fahren ( Spielerbasierend ).", "PKW Schein" };
|
|
public static string[] pilot = { "Pilot", "Du musst Waren oder Passagiere durch Los Santos fliegen.", "Flugzeug Schein" };
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Dictionary<Client, string[]> clientjob = new Dictionary<Client, string[]>();
|
|
|
|
public static string getJob(Client player)
|
|
{
|
|
return API.shared.getEntityData(player, "job");
|
|
}
|
|
|
|
public static void setJob(Client player, String job)
|
|
{
|
|
API.shared.setEntityData(player, "job", job);
|
|
PlayerDatabase.setDatabaseDataString(player, "job", job);
|
|
}
|
|
|
|
public static bool isJob(Client player, String job)
|
|
{
|
|
bool boolean = false;
|
|
if(getJob(player) == job)
|
|
{
|
|
boolean = true;
|
|
}
|
|
return boolean;
|
|
}
|
|
|
|
public static void createJobPed(PedHash ph,Vector3 pos,float heading, string text, string scenario = "")
|
|
{
|
|
Ped ped = API.shared.createPed(ph, pos, heading, 0);
|
|
TextLabel textlabel = API.shared.createTextLabel(text, pos.Add(new Vector3(0, 0, +1)), 5, 1, true, 0);
|
|
if(!(scenario == ""))
|
|
{
|
|
API.shared.playPedScenario(ped, scenario);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static void acceptFenster(Client player, String[] job, int gehalt)
|
|
{
|
|
if (clientjob.ContainsKey(player))
|
|
{
|
|
clientjob.Remove(player);
|
|
clientjob.Add(player, job);
|
|
}
|
|
else
|
|
{
|
|
clientjob.Add(player, job);
|
|
}
|
|
object[] argumentList = new object[13];
|
|
argumentList[0] = CALLBACK;
|
|
argumentList[1] = "" + job[0];
|
|
argumentList[2] = "Optionen:";
|
|
argumentList[3] = false;
|
|
int itemlength = 4;
|
|
argumentList[4] = itemlength;
|
|
argumentList[5] = "~g~~h~Job Annehmen";
|
|
argumentList[6] = "~y~~h~Job Informationen";
|
|
argumentList[7] = "~r~~h~Job Kuendigen";
|
|
argumentList[8] = "~g~~h~Job Starten";
|
|
for (var i = 0; i < itemlength; i++)
|
|
{
|
|
argumentList[9 + i] = "";
|
|
}
|
|
API.shared.triggerClientEvent(player, "menu_handler_create_menu", argumentList);
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onTrigger(Client sender, string eventName, object[] arguments)
|
|
{
|
|
if(eventName == "menu_handler_select_item")
|
|
{
|
|
int callback = (int)arguments[0];
|
|
if(callback == CALLBACK)
|
|
{
|
|
string[] selectedJob = clientjob[sender];
|
|
int index = (int)arguments[1];
|
|
if(index == 0)
|
|
{
|
|
if(!(getJob(sender) == ""))
|
|
{
|
|
API.sendNotificationToPlayer(sender, "~r~Du hast schon einen Job, kuendige erst deinen alten Job und komme dann wieder!");
|
|
}
|
|
else
|
|
{
|
|
setJob(sender, selectedJob[0]);
|
|
API.sendNotificationToPlayer(sender, "~g~Du hast nun eine neue Arbeitsstelle!");
|
|
}
|
|
}
|
|
else if(index == 1)
|
|
{
|
|
API.sendChatMessageToPlayer(sender, "~y~Job: " + selectedJob[0]);
|
|
API.sendChatMessageToPlayer(sender, "~y~Beschreibung: " + selectedJob[1]);
|
|
API.sendChatMessageToPlayer(sender, "~y~Vorrausetzung: " + selectedJob[2]);
|
|
}
|
|
else if(index == 2)
|
|
{
|
|
if (getJob(sender) == "")
|
|
{
|
|
API.sendNotificationToPlayer(sender, "~r~Du hast noch keinen Job!");
|
|
}
|
|
else
|
|
{
|
|
setJob(sender, "");
|
|
API.sendNotificationToPlayer(sender, "~g~Du bist nun Arbeitslos!");
|
|
}
|
|
}
|
|
else if (index == 3)
|
|
{
|
|
API.triggerClientEvent(sender, "triggerServerEvent", "job:start:" + selectedJob[0]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static int getPlayingTime(Client player) {
|
|
return API.shared.getEntityData(player, "playingtime");
|
|
}
|
|
|
|
public static int getPlayingHOURS(Client player)
|
|
{
|
|
return getPlayingTime(player) / 60;
|
|
}
|
|
|
|
public static int fahrzeugpreis = 150;
|
|
public void payday(Client player)
|
|
{
|
|
API.sendChatMessageToPlayer(player, "~y~ --- ~o~ PAYDAY ~y~ ---");
|
|
API.sendChatMessageToPlayer(player, "~g~Gehalt: $" + getPayDayMoney(player));
|
|
API.sendChatMessageToPlayer(player, "~o~Spielstunden: " + getPlayingHOURS(player));
|
|
int calcprice = 0;
|
|
List<Vehicle> privates = Vehiclesystem.VehicleMain.getPrivateVehicles(player);
|
|
if(privates != null){
|
|
foreach(Vehicle veh in privates){
|
|
if(Environment.Fahrzeuganmeldestelle.hasKennzeichen(veh) == true){
|
|
calcprice = calcprice + fahrzeugpreis;
|
|
}
|
|
}
|
|
}
|
|
API.sendChatMessageToPlayer(player, "~o~Fahrzeug anmeldegebühren: $" + calcprice);
|
|
|
|
API.sendChatMessageToPlayer(player, "~b~Fraktion: " + Fraktionen.Fraktionsmanager.getWithColorCodesFraktionsName(Fraktionen.Fraktionsmanager.getFraktion(player)));
|
|
API.sendChatMessageToPlayer(player, "~b~ Fraktionsgehalt: " + Fraktionen.Fraktionsmanager.getFraktionsgehalt(player));
|
|
API.sendChatMessageToPlayer(player, "~y~ ---------------------------");
|
|
API.sendChatMessageToPlayer(player, "Alter Kontostand: " + Environment.MONEY.Money.getBankMoney(player));
|
|
|
|
Environment.MONEY.Money.giveBankMoney(player, getPayDayMoney(player) + Fraktionen.Fraktionsmanager.getFraktionsgehalt(player) - calcprice, API);
|
|
|
|
setPayDayMoney(player, 0);
|
|
API.sendChatMessageToPlayer(player, "Neuer Kontostand: " + Environment.MONEY.Money.getBankMoney(player));
|
|
API.triggerClientEvent(player, "update_playingtime_display", Jobs.Jobmanager.getPlayingHOURS(player));
|
|
}
|
|
|
|
public static int getPayDayMoney(Client player)
|
|
{
|
|
return API.shared.getEntityData(player, "payday");
|
|
}
|
|
|
|
public static void addPayDayMoney(Client player, int value)
|
|
{
|
|
setPayDayMoney(player, getPayDayMoney(player) + value);
|
|
API.shared.sendNotificationToPlayer(player, "Dir wurden " + value + "$ auf dein PayDay hinzugefuegt! Dein naechster Payday: " + getPayDayMoney(player) + "$");
|
|
}
|
|
|
|
public static void setPayDayMoney(Client player, int payday)
|
|
{
|
|
API.shared.setEntityData(player, "payday", payday);
|
|
}
|
|
|
|
[Command("spielstunden")]
|
|
public void check(Client player)
|
|
{
|
|
API.sendNotificationToPlayer(player, "Spielstunden: " + getPlayingTime(player) / 60);
|
|
}
|
|
|
|
|
|
public void oneminute()
|
|
{
|
|
List<Client> clientlist = API.getAllPlayers();
|
|
foreach(Client player in clientlist)
|
|
{
|
|
if(API.getEntityData(player,"loggedin") == true)
|
|
{
|
|
API.setEntityData(player, "playingtime", getPlayingTime(player) + 1);
|
|
//API.setEntityData(player, "lastplayinghour", System.Convert.ToInt32(playingtime / 60));
|
|
if(getPlayingHOURS(player) > API.getEntityData(player,"lastplayinghour"))
|
|
{
|
|
payday(player);
|
|
API.setEntityData(player, "lastplayinghour", getPlayingTime(player) / 60);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|