454 lines
21 KiB
C#
454 lines
21 KiB
C#
using GrandTheftMultiplayer.Server.API;
|
|
using GrandTheftMultiplayer.Shared.Math;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using GrandTheftMultiplayer.Server.Managers;
|
|
using GrandTheftMultiplayer.Shared;
|
|
using GrandTheftMultiplayer.Server.Elements;
|
|
using GrandTheftMultiplayer.Server.Constant;
|
|
|
|
namespace Roleplay.Fraktionen.Rescue
|
|
{
|
|
|
|
[Flags]
|
|
public enum AnimationFlags
|
|
{
|
|
Loop = 1 << 0,
|
|
StopOnLastFrame = 1 << 1,
|
|
OnlyAnimateUpperBody = 1 << 4,
|
|
AllowPlayerControl = 1 << 5,
|
|
Cancellable = 1 << 7
|
|
}
|
|
|
|
class Rescue : Script
|
|
{
|
|
|
|
public PedHash doctor = PedHash.Doctor01SMM;
|
|
public PedHash neuen = PedHash.Uscg01SMY;
|
|
public PedHash paramedic = PedHash.Paramedic01SMM;
|
|
public static Vector3 tpdraussen = new Vector3(341.3809, -1396.395, 32.50);
|
|
public Vector3 tpdrinnen = new Vector3(273.8751, -1359.976, 24.53781);
|
|
public const int RESCUE_CALLBACK1 = 273875113;
|
|
public const int RESCUE_CALLBACK2 = 273875112;
|
|
public const int RESCUE_CALLBACK3 = 545684;
|
|
|
|
public Dictionary<int, string> verletzungen = new Dictionary<int, string>();
|
|
public Dictionary<Client, Client> clickedPlayer = new Dictionary<Client, Client>();
|
|
|
|
public Rescue()
|
|
{
|
|
RAPI.Marker.createMarker(1, new Vector3(275, -1361, 23.5), 1, 255, 0, 0, "rescuegoout", 0, 185, "Exit", 0);
|
|
RAPI.Marker.createMarker(1, new Vector3(267, -1365.273, 23.5), 1, 255, 0, 0, "rescueduty", 0, 185, "LSMS Duty", 0);
|
|
RAPI.Marker.createMarker(1, new Vector3(245, -1355, 23.5), 1, 255, 0, 0, "rescueunduty", 0, 185, "LSMS Unduty", 0);
|
|
RAPI.Marker.createMarker(1, new Vector3(343.5174, -1398.608, 31.5), 1, 255, 0, 0, "rescuegoin", 0, 185, "Krankenhaus Eingang", 0);
|
|
API.createPed(PedHash.Scientist01SMM, new Vector3(318.321, -1476.291, 29.9), -132, 0);
|
|
RAPI.Marker.createMarker(1, new Vector3(319.1114, -1476.874, 28.78632), 1, 0, 255, 0, "rescueausleih", 0, 185, "Dienstfahrzeuge", 0);
|
|
API.requestIpl("Coroner_Int_on");
|
|
Blip blip = API.createBlip(new Vector3(343.5174, -1398.608, 31.5));
|
|
blip.sprite = 153;
|
|
blip.color = 76;
|
|
blip.name = "Krankenhaus";
|
|
|
|
insertverletzungen();
|
|
API.onClientEventTrigger += onClient;
|
|
API.onClientEventTrigger += Interaction;
|
|
API.onEntityEnterColShape += onKrankenhausHander;
|
|
API.onPlayerDeath += onPlayerDead;
|
|
}
|
|
|
|
private void Interaction(Client sender, string eventName, object[] arguments)
|
|
{
|
|
if (eventName == "playerinteraction")
|
|
{
|
|
NetHandle ent = (NetHandle)arguments[0];
|
|
Client clickedplayer = API.getPlayerFromHandle(ent);
|
|
if (API.getEntityData(sender, "busy") != true)
|
|
{
|
|
if (API.getEntityData(clickedplayer, "verletzt") == true)
|
|
{
|
|
if (API.getEntityData(clickedplayer, "verletzung:id") != 0)
|
|
{
|
|
if (Fraktionsmanager.getFraktion(sender) == 7)
|
|
{
|
|
if (Fraktionsmanager.isParaDuty(sender) == true)
|
|
{
|
|
if (!clickedPlayer.ContainsKey(sender))
|
|
{
|
|
clickedPlayer.Add(sender, clickedplayer);
|
|
}
|
|
else
|
|
{
|
|
clickedPlayer.Set(sender, clickedplayer);
|
|
}
|
|
object[] argslist = new object[13];
|
|
argslist[0] = RESCUE_CALLBACK2;
|
|
argslist[1] = "Wiederbeleben";
|
|
argslist[2] = "Optionen:";
|
|
argslist[3] = false;
|
|
int itemlength = 1;
|
|
argslist[4] = itemlength;
|
|
argslist[5] = "~r~Reanimation";
|
|
for (var i = 0; i < itemlength; i++)
|
|
{
|
|
argslist[6 + i] = "";
|
|
}
|
|
//////////////////////////////////////////////////////////////
|
|
API.triggerClientEvent(sender, "menu_handler_create_menu", argslist);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
API.sendNotificationToPlayer(sender, "~r~ Dieser Spieler ist verwundet. Ein Krankenwagen ist auf dem Weg!", false);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (Fraktionsmanager.getFraktion(sender) == 7)
|
|
{
|
|
if (Fraktionsmanager.isParaDuty(sender) == true)
|
|
{
|
|
object[] argslist = new object[13];
|
|
argslist[0] = RESCUE_CALLBACK3;
|
|
argslist[1] = "LSMS";
|
|
argslist[2] = "Optionen:";
|
|
argslist[3] = false;
|
|
int itemlength = 1;
|
|
argslist[4] = itemlength;
|
|
argslist[5] = "~r~Healen";
|
|
for (var i = 0; i < itemlength; i++)
|
|
{
|
|
argslist[6 + i] = "";
|
|
}
|
|
//////////////////////////////////////////////////////////////
|
|
API.triggerClientEvent(sender, "menu_handler_create_menu", argslist);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (eventName == "menu_handler_select_item")
|
|
{
|
|
int callback = (int)arguments[0];
|
|
int index = (int)arguments[1];
|
|
if (callback == RESCUE_CALLBACK2)
|
|
{
|
|
if (index == 0)
|
|
{
|
|
Client clicked = clickedPlayer[sender];
|
|
wiederbeleben(sender, clicked);
|
|
|
|
}
|
|
}
|
|
else if (callback == RESCUE_CALLBACK3)
|
|
{
|
|
if (index == 0)
|
|
{
|
|
Client clicked = clickedPlayer[sender];
|
|
API.setPlayerHealth(clicked, API.getPlayerHealth(clicked) + 25);
|
|
API.sendNotificationToPlayer(clicked, "Du wurdest geheilt!");
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
private void insertverletzungen()
|
|
{
|
|
verletzungen.Add(1, "Innere Blutungen");
|
|
verletzungen.Add(2, "Knochenbruch");
|
|
verletzungen.Add(3, "Herzstillstand");
|
|
verletzungen.Add(4, "Schlaganfall");
|
|
verletzungen.Add(5, "Prellungen");
|
|
verletzungen.Add(6, "Schusswunde");
|
|
}
|
|
|
|
private void onKrankenhausHander(ColShape colshape, NetHandle entity)
|
|
{
|
|
if (colshape.getData("rescuegoin") == true)
|
|
{
|
|
Client player = API.getPlayerFromHandle(entity);
|
|
API.setEntityPosition(player, tpdrinnen);
|
|
API.setEntityRotation(player, new Vector3(0, 0, 46.15838));
|
|
}
|
|
else if (colshape.getData("rescuegoout") == true)
|
|
{
|
|
Client player = API.getPlayerFromHandle(entity);
|
|
API.setEntityPosition(player, tpdraussen);
|
|
}
|
|
else if (colshape.getData("rescueduty") == true)
|
|
{
|
|
Client player = API.getPlayerFromHandle(entity);
|
|
if (Fraktionsmanager.getFraktion(player) == 7)
|
|
{
|
|
if (Fraktionsmanager.isParaDuty(player) == false)
|
|
{
|
|
Fraktionsmanager.setParamedicDuty(player, true);
|
|
Fraktionsmanager.sendFraktionsNotification(7, "~b~Der Spieler " + player.name + " ist nun im Dienst!", false);
|
|
API.givePlayerWeapon(player, WeaponHash.Flashlight, 1, true, true);
|
|
if (Fraktionsmanager.getFraktionsRang(player) == 4)
|
|
{
|
|
API.setPlayerSkin(player, PedHash.GentransportSMM);
|
|
}
|
|
else if (Fraktionsmanager.getFraktionsRang(player) == 5)
|
|
{
|
|
API.setPlayerSkin(player, neuen);
|
|
}
|
|
else
|
|
{
|
|
API.setPlayerSkin(player, paramedic);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
API.sendNotificationToPlayer(player, "~r~Du bist nicht in der richtigen Fraktion!");
|
|
}
|
|
}
|
|
else if (colshape.getData("rescueunduty") == true)
|
|
{
|
|
Client player = API.getPlayerFromHandle(entity);
|
|
if (Fraktionsmanager.getFraktion(player) == 7)
|
|
{
|
|
if (Fraktionsmanager.isParaDuty(player) == true)
|
|
{
|
|
Fraktionsmanager.setParamedicDuty(player, false);
|
|
Fraktionsmanager.sendFraktionsNotification(7, "~r~Der Spieler " + player.name + " ist nicht mehr im Dienst!", false);
|
|
if (API.getEntityData(player, "geschlecht") == 0)
|
|
{
|
|
API.setPlayerSkin(player, PedHash.FreemodeFemale01);
|
|
}
|
|
else
|
|
{
|
|
API.setPlayerSkin(player, PedHash.FreemodeMale01);
|
|
}
|
|
Database.CharacterDatabase.setPlayerDatabaseClothes(player, API);
|
|
}
|
|
}
|
|
}
|
|
else if (colshape.getData("rescueausleih") == true)
|
|
{
|
|
|
|
Client player = API.getPlayerFromHandle(entity);
|
|
if (Fraktionsmanager.isParaDuty(player) == true)
|
|
{
|
|
object[] argslist = new object[16];
|
|
argslist[0] = RESCUE_CALLBACK1;
|
|
argslist[1] = "Dienstfahrzeuge";
|
|
argslist[2] = "Fahrzeuge:";
|
|
argslist[3] = false;
|
|
int itemlength = 4;
|
|
argslist[4] = itemlength;
|
|
argslist[5] = "~r~Rettungswagen ~m~(Rang 0)";
|
|
argslist[6] = "~r~Noteinsatzfahrzeug~m~(Rang 4)";
|
|
argslist[7] = "~r~Kommandowagen ~m~(Rang 5)";
|
|
argslist[8] = "~r~Helikopter ~m~(Rang 3)";
|
|
for (var i = 0; i < itemlength; i++)
|
|
{
|
|
argslist[9 + i] = "";
|
|
}
|
|
//////////////////////////////////////////////////////////////
|
|
API.triggerClientEvent(player, "menu_handler_create_menu", argslist);
|
|
}
|
|
else
|
|
{
|
|
API.sendNotificationToPlayer(player, "Du bist nicht im Dienst!");
|
|
}
|
|
}
|
|
}
|
|
|
|
private void onClient(Client sender, string eventName, object[] arguments)
|
|
{
|
|
if (eventName == "menu_handler_select_item")
|
|
{
|
|
int callback = (int)arguments[0];
|
|
|
|
if (callback == RESCUE_CALLBACK1)
|
|
{
|
|
int index = (int)arguments[1];
|
|
if (index == 0)
|
|
{
|
|
if (Fraktionsmanager.getFraktionsRang(sender) >= 0)
|
|
{
|
|
Vehicle veh = API.createVehicle(VehicleHash.Ambulance, new Vector3(331.2365, -1468.399, 29.47), new Vector3(0, 0, -130), 0, 0, 0);
|
|
API.setEntityData(veh, "Fraktionsfahrzeug", 7);
|
|
API.setPlayerIntoVehicle(sender, veh, -1);
|
|
API.setVehicleNumberPlate(veh, "LSMS");
|
|
}
|
|
}
|
|
else if (index == 1)
|
|
{
|
|
if (Fraktionsmanager.getFraktionsRang(sender) >= 4)
|
|
{
|
|
Vehicle veh = API.createVehicle(VehicleHash.FBI2, new Vector3(331.2365, -1468.399, 29.47), new Vector3(0, 0, -130), 0, 0, 0);
|
|
API.setEntityData(veh, "Fraktionsfahrzeug", 7);
|
|
API.setVehicleCustomPrimaryColor(veh, 255, 60, 60);
|
|
API.setPlayerIntoVehicle(sender, veh, -1);
|
|
API.setVehicleNumberPlate(veh, "LSMS");
|
|
}
|
|
}
|
|
else if (index == 2)
|
|
{
|
|
if (Fraktionsmanager.getFraktionsRang(sender) >= 5)
|
|
{
|
|
Vehicle veh = API.createVehicle(VehicleHash.Police4, new Vector3(331.2365, -1468.399, 29.47), new Vector3(0, 0, -130), 0, 0, 0);
|
|
API.setEntityData(veh, "Fraktionsfahrzeug", 7);
|
|
API.setVehicleCustomPrimaryColor(veh, 255, 60, 60);
|
|
API.setPlayerIntoVehicle(sender, veh, -1);
|
|
API.setVehicleNumberPlate(veh, "LSMS");
|
|
}
|
|
}
|
|
else if (index == 3)
|
|
{
|
|
if (Fraktionsmanager.getFraktionsRang(sender) >= 3)
|
|
{
|
|
Vehicle veh = API.createVehicle(VehicleHash.Swift, new Vector3(314.3139, -1463.902, 46.90362), new Vector3(0, 0, 139.1774), 0, 0, 0);
|
|
API.setEntityData(veh, "Fraktionsfahrzeug", 7);
|
|
API.setVehicleCustomPrimaryColor(veh, 255, 60, 60);
|
|
API.setVehicleLivery(veh, 1);
|
|
API.setPlayerIntoVehicle(sender, veh, -1);
|
|
API.setVehicleNumberPlate(veh, "LSMS");
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private void onPlayerDead(Client player, NetHandle entityKiller, int weapon)
|
|
{
|
|
cancelWasted(player);
|
|
Random r = new Random();
|
|
if (weapon == 0)
|
|
{
|
|
int verletzung = r.Next(1, 5);
|
|
API.setEntityData(player, "verletzung:id", verletzung);
|
|
}
|
|
else
|
|
{
|
|
int verletzung = 6;
|
|
API.setEntityData(player, "verletzung:id", verletzung);
|
|
}
|
|
int time = r.Next(8, 15);
|
|
API.playPlayerAnimation(player, (int)AnimationFlags.Loop, "random@crash_rescue@wounded@base", "base");
|
|
|
|
Fraktionsmanager.sendFraktionsNotification(2, "~r~NOTFALL: Der Spieler: ~y~" + player.name + " ~r~ist am Sterben!", true);
|
|
Fraktionsmanager.sendBlipForFraktion(2, player.position.X, player.position.Y, player.position.Z, 489, 59, time);
|
|
API.setEntityPositionFrozen(player, true);
|
|
PlayerDatabase.setDatabaseData(player, "dead", 1);
|
|
API.setEntityData(player, "verletzt", true);
|
|
API.setEntityInvincible(player, true);
|
|
|
|
if (Convert.ToInt32(Fraktionsmanager.getAllOnlineFraktionsMember(2).Count) > 1)
|
|
{
|
|
API.sendNotificationToPlayer(player, "~r~ Du bist verwundet! Du liegst auf dem Boden und wartest auf Hilfe. Dir verbleiben ~y~" + time + " Minuten~r~!", true);
|
|
API.delay(60000 * 1, true, () => {
|
|
API.playPlayerAnimation(player, (int)AnimationFlags.Loop, "mini@cpr@char_b@cpr_str", "cpr_kol_idle");
|
|
API.sendNotificationToPlayer(player, "Du bist bewusstlos!");
|
|
});
|
|
API.delay(60000 * time, true, () => { respawnPlayer(player); });
|
|
}
|
|
else
|
|
{
|
|
API.sendNotificationToPlayer(player, "~r~ Du bist verwundet! Du liegst auf dem Boden und wartest auf Hilfe. Dir verbleiben ~y~" + 1 + " Minute~r~!", true);
|
|
API.delay(60000 * 3, true, () => { respawnPlayer(player); });
|
|
}
|
|
|
|
}
|
|
|
|
public void respawnwithoutpos(Client player)
|
|
{
|
|
API.setEntityPositionFrozen(player, false);
|
|
API.setEntityInvincible(player, false);
|
|
API.setEntityData(player, "verletzung:id", 0);
|
|
PlayerDatabase.setDatabaseData(player, "dead", 0);
|
|
}
|
|
|
|
public static void respawnPlayer(Client player)
|
|
{
|
|
if (API.shared.getEntityData(player, "verletzung:id") != 0)
|
|
{
|
|
API.shared.setEntityPositionFrozen(player, false);
|
|
API.shared.setEntityInvincible(player, false);
|
|
API.shared.stopPlayerAnimation(player);
|
|
PlayerDatabase.setDatabaseData(player, "dead", 0);
|
|
API.shared.setEntityData(player, "verletzung:id", 0);
|
|
API.shared.setEntityPosition(player, tpdraussen);
|
|
}
|
|
}
|
|
|
|
public void cancelWasted(Client player)
|
|
{
|
|
API.sendNativeToPlayer(player, Hash._RESET_LOCALPLAYER_STATE, player);
|
|
API.sendNativeToPlayer(player, Hash.RESET_PLAYER_ARREST_STATE, player);
|
|
API.removeAllPlayerWeapons(player);
|
|
API.sendNativeToPlayer(player, Hash.IGNORE_NEXT_RESTART, true);
|
|
API.sendNativeToPlayer(player, Hash._DISABLE_AUTOMATIC_RESPAWN, true);
|
|
|
|
API.sendNativeToPlayer(player, Hash.SET_FADE_IN_AFTER_DEATH_ARREST, true);
|
|
API.sendNativeToPlayer(player, Hash.SET_FADE_OUT_AFTER_DEATH, false);
|
|
API.sendNativeToPlayer(player, Hash.NETWORK_REQUEST_CONTROL_OF_ENTITY, player);
|
|
|
|
API.sendNativeToPlayer(player, Hash.FREEZE_ENTITY_POSITION, player, false);
|
|
API.shared.sendNativeToPlayer(player, Hash.NETWORK_RESURRECT_LOCAL_PLAYER, player.position.X, player.position.Y, player.position.Z, player.rotation.Z, false, false);
|
|
API.shared.sendNativeToPlayer(player, Hash.RESURRECT_PED, player);
|
|
}
|
|
|
|
|
|
|
|
public void wiederbeleben(Client paramedic, Client hurt)
|
|
{
|
|
API.setEntityPositionFrozen(paramedic, true);
|
|
API.setEntityPositionFrozen(hurt, true);
|
|
API.setEntityData(hurt, "verletzt", true);
|
|
API.setEntityData(paramedic, "busy", true);
|
|
API.setEntityRotation(hurt, new Vector3(0, 0, 0));
|
|
if (API.getEntityData(hurt, "geschlecht") == 0)
|
|
{
|
|
API.setEntityPosition(paramedic, new Vector3(hurt.position.X, hurt.position.Y, hurt.position.Z).Add(new Vector3(0.7, -0.3, +0.1)));
|
|
API.setEntityRotation(paramedic, new Vector3(hurt.rotation.X, hurt.rotation.Y, hurt.rotation.Z + 90));
|
|
}
|
|
else
|
|
{
|
|
API.setEntityPosition(paramedic, new Vector3(hurt.position.X, hurt.position.Y, hurt.position.Z).Add(new Vector3(0.7, -0.3, 0)));
|
|
API.setEntityRotation(paramedic, new Vector3(hurt.rotation.X, hurt.rotation.Y, hurt.rotation.Z + 90));
|
|
}
|
|
API.setEntityCollisionless(hurt, true);
|
|
API.playPlayerAnimation(hurt, (int)AnimationFlags.Loop, "mini@cpr@char_b@cpr_str", "cpr_pumpchest");
|
|
API.playPlayerAnimation(paramedic, (int)AnimationFlags.Loop, "mini@cpr@char_a@cpr_str", "cpr_pumpchest");
|
|
API.delay(60000 * 1, true, () => {
|
|
API.playPlayerAnimation(hurt, (int)AnimationFlags.StopOnLastFrame, "mini@cpr@char_b@cpr_str", "cpr_success");
|
|
API.playPlayerAnimation(paramedic, (int)AnimationFlags.StopOnLastFrame, "mini@cpr@char_a@cpr_str", "cpr_success");
|
|
API.delay(1000 * 25, true, () => {
|
|
respawnwithoutpos(hurt);
|
|
API.stopPlayerAnimation(paramedic);
|
|
API.stopPlayerAnimation(hurt);
|
|
PlayerDatabase.setDatabaseData(hurt, "dead", 0);
|
|
API.setEntityData(hurt, "verletzt", false);
|
|
API.setEntityData(paramedic, "busy", false);
|
|
API.setEntityCollisionless(hurt, false);
|
|
API.setEntityPositionFrozen(hurt, false);
|
|
API.setEntityPositionFrozen(paramedic, false);
|
|
API.setEntityCollisionless(paramedic, false);
|
|
});
|
|
});
|
|
}
|
|
|
|
|
|
|
|
// ANIMATION INTRO mini@cpr@char_a@cpr_def cpr_intro -- DER PARAMEDIC
|
|
// ANIMATION INTRO mini@cpr@char_b@cpr_def cpr_intro -- DER VERLETZTE
|
|
|
|
|
|
// PUMPEN mini@cpr@char_a@cpr_str cpr_pumpchest -- DER PARAMEDIC
|
|
// PUMPEN mini@cpr@char_b@cpr_str cpr_pumpchest -- DER VERLETZTE
|
|
|
|
// SUCCESS mini@cpr@char_a@cpr_str cpr_success -- DER PARAMEDIC
|
|
// SUCCESS mini@cpr@char_b@cpr_str cpr_success -- VERLETZTE
|
|
|
|
|
|
}
|
|
}
|