blob: 27581aeac0097b5f1e5a55884b12b5608dab4c32 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
untyped
global function GamemodeSbox_Init
struct {
array<entity> 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 )
}
|