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

53 lines
2.3 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.Shared;
namespace Roleplay.Environment
{
class Death : Script
{
public static Boolean canRespawn = false;
public Death()
{
API.onPlayerDeath += onDeath;
}
private void onDeath(Client player, NetHandle entityKiller, int weapon)
{
if (canRespawn == false)
{
//Cancel Wasted!
API.sendNativeToPlayer(player, Hash.DO_SCREEN_FADE_OUT, 200);
API.setEntityData(player, "verletzt", true);
API.triggerClientEvent(player, "triggerKrankenhausfenster");
API.shared.sendNativeToPlayer(player, Hash.IGNORE_NEXT_RESTART, true);
API.shared.sendNativeToPlayer(player, Hash._DISABLE_AUTOMATIC_RESPAWN, true);
API.shared.sendNativeToPlayer(player, Hash.NETWORK_REQUEST_CONTROL_OF_ENTITY, player);
API.shared.sendNativeToPlayer(player, Hash.FREEZE_ENTITY_POSITION, player, true);
API.shared.sendNativeToPlayer(player, Hash.SET_PED_TO_RAGDOLL, player, true);
API.sendNativeToPlayer(player, Hash.DO_SCREEN_FADE_IN, 200);
API.delay(60000 * 3, true, () => { canRespawn = true; });
}else if(canRespawn == true)
{
API.sendNativeToPlayer(player, Hash.DO_SCREEN_FADE_OUT, 200);
API.setEntityData(player, "verletzt", false);
API.shared.sendNativeToPlayer(player, Hash.IGNORE_NEXT_RESTART, true);
API.shared.sendNativeToPlayer(player, Hash.FREEZE_ENTITY_POSITION, player, false);
API.shared.sendNativeToPlayer(player, Hash.SET_PED_TO_RAGDOLL, 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.sendNativeToPlayer(player, Hash.DO_SCREEN_FADE_IN, 200);
canRespawn = false;
API.sendChatMessageToPlayer(player, "~b~Du bist wieder Aufgestanden");
}
}
}
}