197 lines
8 KiB
C#
197 lines
8 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.LifeGuard
|
|
{
|
|
class LifeGuard : Script
|
|
{
|
|
public LifeGuard()
|
|
{
|
|
API.onEntityEnterColShape += onColShapeHandler;
|
|
API.onClientEventTrigger += onTrigger;
|
|
API.onPlayerExitVehicle += oNCancel;
|
|
|
|
setupJob();
|
|
}
|
|
|
|
List<ColShape> colshapes = new List<ColShape>();
|
|
public const int totalmarkers = 5;
|
|
|
|
public void setupJob()
|
|
{
|
|
API.createPed(PedHash.Baywatch01SMY, new Vector3(-1560.118, -1154.862, 3.911212), 180, 0);
|
|
RAPI.Marker.createMarker(1, new Vector3(-1559.363, -1156.3, 2.911212), 1, 0, 255, 0, "job:LifeGuard", 0, 185, "LifeGuard", 0);
|
|
RAPI.Marker.createMarker(0, new Vector3(-1555.363, -1156.3, 1.911212), 1, 0, 255, 0, "Lifeguardabgeben", 0, 185, "Auto Einlagern", 0);
|
|
colshapes.Add(API.createCylinderColShape(new Vector3(-1518.49, -1272.849, 3.459243), 1, 2));
|
|
colshapes.Add(API.createCylinderColShape(new Vector3(-1466.786, -1388.963, 4.138116), 1, 2));
|
|
colshapes.Add(API.createCylinderColShape(new Vector3(-1431.199, -1508.964, 3.710496), 1, 2));
|
|
colshapes.Add(API.createCylinderColShape(new Vector3(-1372.829, -1624.367, 3.725401), 1, 2));
|
|
colshapes.Add(API.createCylinderColShape(new Vector3(-1290.279, -1752.955, 3.71381), 1, 2));
|
|
Blip blip = API.createBlip(new Vector3(-1560.118, -1154.862, 3.911212), 0);
|
|
blip.sprite = 377;
|
|
foreach(ColShape col in colshapes)
|
|
{
|
|
col.setData("ID", colshapes.IndexOf(col) + 1);
|
|
}
|
|
}
|
|
|
|
public void startMarker(Client player)
|
|
{
|
|
API.triggerClientEvent(player, "job:generate:marker", 1);
|
|
API.setEntityData(player, "job:LifeGuard:next", 1);
|
|
}
|
|
|
|
public int getCurrentId(Client player)
|
|
{
|
|
if (API.hasEntityData(player, "job:LifeGuard:next") == true && API.getEntityData(player, "job:LifeGuard:next") != null)
|
|
{
|
|
return API.getEntityData(player, "job:LifeGuard:next");
|
|
} else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
public void nextMarker(Client player)
|
|
{
|
|
if (API.hasEntityData(player, "job:LifeGuard:next") == true)
|
|
{
|
|
int current = API.getEntityData(player, "job:LifeGuard:next");
|
|
if (current >= 4)
|
|
{
|
|
API.triggerClientEvent(player, "destroyMarker");
|
|
API.triggerClientEvent(player, "job:generate:marker", 1);
|
|
API.setEntityData(player, "job:LifeGuard:next", 1);
|
|
}
|
|
else
|
|
{
|
|
API.triggerClientEvent(player, "destroyMarker");
|
|
API.triggerClientEvent(player, "job:generate:marker", current + 1);
|
|
API.setEntityData(player, "job:LifeGuard:next", current + 1);
|
|
}
|
|
} else
|
|
{
|
|
API.triggerClientEvent(player, "destroyMarker");
|
|
API.triggerClientEvent(player, "job:generate:marker", 1);
|
|
API.setEntityData(player, "job:LifeGuard:next", 1);
|
|
}
|
|
}
|
|
|
|
private void onTrigger(Client sender, string eventName, object[] arguments)
|
|
{
|
|
if (eventName == "triggerBackFromClient")
|
|
{
|
|
string job = (string)arguments[0];
|
|
if (job == "job:start:" + Jobmanager.Jobnames.LifeGuard[0])
|
|
{
|
|
if (Jobmanager.getJob(sender) == Jobmanager.Jobnames.LifeGuard[0])
|
|
{
|
|
API.sendNotificationToPlayer(sender, "~g~Job gestartet!");
|
|
Vehicle veh = RAPI.MainAPI.createRolePlayVehicle(VehicleHash.Lguard, new Vector3(-1575.387, -1158.269, 2.133404), new Vector3(0, 0, -147), 0, 100, 0, 0, 255, 0, "System");
|
|
API.setPlayerIntoVehicle(sender, veh, -1);
|
|
API.setVehicleLocked(veh, true);
|
|
API.setEntityData(veh, "job:LifeGuard:Lguard", true);
|
|
API.setEntityData(sender,"job:LifeGuard",true);
|
|
API.setEntityData(sender, "job:LifeGuard:next", 1);
|
|
API.triggerClientEvent(sender, "job:generate:marker", 1);
|
|
}
|
|
else
|
|
{
|
|
API.sendNotificationToPlayer(sender, "~r~Du musst den Job erstmal annehmen!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void onColShapeHandler(ColShape colshape, NetHandle entity)
|
|
{
|
|
if (entity != null && colshape != null)
|
|
{
|
|
if (colshape.hasData("job:LifeGuard") == true && colshape.getData("job:LifeGuard") == true)
|
|
{
|
|
Client player = API.getPlayerFromHandle(entity);
|
|
if (player != null)
|
|
{
|
|
Jobmanager.acceptFenster(player, Jobmanager.Jobnames.LifeGuard, 0);
|
|
}
|
|
}
|
|
else if (colshape.hasData("ID") == true)
|
|
{
|
|
Client player = API.getPlayerFromHandle(entity);
|
|
if (player != null)
|
|
{
|
|
if (player.isInVehicle != true)
|
|
{
|
|
int colshapeid = colshape.getData("ID");
|
|
if (colshapeid == getCurrentId(player))
|
|
{
|
|
if (colshapeid == 4)
|
|
{
|
|
API.triggerClientEvent(player, "destroyMarker");
|
|
}
|
|
nextMarker(player);
|
|
API.playPlayerScenario(player, "WORLD_HUMAN_BINOCULARS");
|
|
API.delay(1000 * 10, true, () =>
|
|
{
|
|
API.stopPlayerAnimation(player);
|
|
Jobmanager.addPayDayMoney(player, 500);
|
|
Levelsystem.addPlayerLevelFortschritt(player,1,API);
|
|
});
|
|
}
|
|
}
|
|
else
|
|
{
|
|
API.sendNotificationToPlayer(player, "Du musst absteigen!");
|
|
}
|
|
}
|
|
}else if(colshape.hasData("Lifeguardabgeben") == true){
|
|
Client player = API.getPlayerFromHandle(entity);
|
|
if(player != null && player.isInVehicle == true){
|
|
|
|
|
|
Vehicle veh = player.vehicle;
|
|
if(veh != null)
|
|
{
|
|
if(API.hasEntityData(veh, "job:LifeGuard:Lguard") == true)
|
|
{
|
|
if (Jobmanager.getJob(player) == Jobmanager.Jobnames.LifeGuard[0])
|
|
{
|
|
veh.delete();
|
|
API.sendNotificationToPlayer(player, "Du hast das Fahrzeug abgegeben!");
|
|
}else{
|
|
API.sendNotificationToPlayer(player, "Du hast nicht den richtigen Job!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void oNCancel(Client player, NetHandle vehicle, int x)
|
|
{
|
|
if (API.getEntityData(vehicle, "job:LifeGuard:mower") == true)
|
|
{
|
|
//API.delay(1000 * 60, true, () =>
|
|
//{
|
|
// if(player.isInVehicle != true)
|
|
// {
|
|
// API.deleteEntity(vehicle);
|
|
// API.triggerClientEvent(player, "destroyMarker");
|
|
// }
|
|
//});
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|