Jump to content

Async OnDeath


Recommended Posts

        public static async Task OnPlayerDeath(GTANetworkAPI.Player player, GTANetworkAPI.Player killer, DeathReason deathReason)
            Player.AccountData account = player.GetData<Player.AccountData>(Player.AccountData.UniqueIdentifier);
            Player.SessionData session = player.GetData<Player.SessionData>(Player.SessionData.UniqueIdentifier);
            int medicalFee = session.ClassData.MedicalFeeOnDeath + random.Next(-200, 200);
            account.Balance -= medicalFee;
            player.SendChatMessage($"You've died and have paid {medicalFee}$ in medical fees.");
            Vector3 spawnPos = new Vector3();
            if (account.SpawnLocation == SpawnLocation.Random)
                spawnPos = new Vector3(-1036.182, -2729.434, 13.75665);
            await Task.Delay(5000);
            NAPI.Player.SpawnPlayer(player, spawnPos);

Hi, I'd like to make it so once the player dies there is a timer of 5 seconds before he is respawned


Could someone put me in the right direction, this is the code I came up with but it doesn't work

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...