untyped global function GamemodeSbox_Init struct { array spawnpoints } file void function GamemodeSbox_Init() { SetConVarInt( "sv_cheats", 1 ) // cheats on by default // cache spawnpoints //file.spawnpoints = GetEntArrayByClass_Expensive( "info_spawnpoint_human" ) // todo just use a spawn callback for this rather than weird late cache in spawn AddCallback_OnClientConnected( SboxSpawnPlayer ) AddDeathCallback( "player", SboxRespawnPlayer ) } void function SboxSpawnPlayer( entity player ) { if ( player.GetPlayerSettings() == "spectator" ) // if they haven't spawned yet player.SetPlayerSettings( "pilot_grapple_male" ) if ( file.spawnpoints.len() == 0 ) // have to cache late rather than on init due to spawnpoints not existing in init file.spawnpoints = GetEntArrayByClass_Expensive( "info_spawnpoint_human" ) if ( GetGameState() != eGameState.Playing ) // hacky but can't set this in init either SetGameState( eGameState.Playing ) entity spawnpoint = file.spawnpoints[ RandomInt( file.spawnpoints.len() ) ] ScreenFadeFromBlack( player, 0.0, 0.0 ) // HACK before non-classicmp intros are ready, remove the blackscreen we get from waitingforplayers player.RespawnPlayer( spawnpoint ) player.GiveWeapon( "mp_weapon_toolgun" ) } void function SboxRespawnPlayer( entity player, var damageInfo ) { thread SboxRespawnPlayerThreaded( player ) } void function SboxRespawnPlayerThreaded( entity player ) { // todo: replace this with real respawn logic when that's ready wait 2.5 SboxSpawnPlayer( player ) }