[Release] Simple spawnmanager in C#

Use this class anywhere in your project

4 Likes

Neat, a spawn manager port to C#. Also you can look at the //todo comments in the spawnmanager.lua :o

Maybe something to consider:

  • List of spawn points, pick one randomly (if you don’t specify any coordinates).
  • Configurable if player wanted level gets cleared and the RemoveAllPedWeapons option configurable.
  • Automatic respawning, where you automatically spawn. (also configurable, i.e. useAutoSpawn and autoSpawnDelay)
  • Option to not spawn the player, but still shutdown the loadingscreen. (i.e. for any UI between the loadingscreen and actually spawning).
  • Trigger appropiate events so other scripts can use it x)
  • Use exports for the SpawnPlayer method instead of static :slight_smile:
  • Some export that will allow this: [help] to respawn timer

Enough to work on and make this a truly awesome resource x)


Here, have a more neat FreezePlayer function. Keeping it DRY x)

public static void FreezePlayer(int playerId, bool freeze)
{
    var ped = GetPlayerPed(playerId);

    //True when player was visible and frozen
    var visibility = freeze && IsEntityVisible(ped); 

    SetPlayerControl(playerId, !freeze, 0);
    SetEntityVisible(ped, visibility, false);
    SetEntityCollision(ped, !freeze, true);
    FreezeEntityPosition(ped, freeze);
    SetPlayerInvincible(playerId, freeze);
   
    if (IsPedFatallyInjured(ped))
    {
        ClearPedTasksImmediately(ped);
    }
}
5 Likes

Would this by chance come back or maybe someone revive it?

I would not call this a “spawnmanager”. You still have to have the [system]\spawnmanager for the game mode to work. Write a replacement for [system]\spawnmanager and I would be interested.

[EDIT]
I am wrong. Thank you, nice contribution.

How is this different from the default resource? I’m not good enough to read complex lua or C# yet…
edit- Its basically to handle spawns and freezes using this class in your script instead of using exports or events. Super useful :slight_smile: