aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/mod/scripts/vscripts/_respawn_protection.gnut
blob: 2fb17767795b8d079dde114b0ec0d926d251e142 (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
global function RespawnProtection_Init

void function RespawnProtection_Init(){
	AddCallback_OnPlayerRespawned( OnPlayerRespawned )
}

void function OnPlayerRespawned( entity player )
{
	thread RespawnProtection(player,GetCurrentPlaylistVarFloat("respawnprotection",0.0))
}

void function RespawnProtection( entity player , float time ){
	OnThreadEnd(
		function() : ( player )
		{
			//cancel protect if player attack
			if( IsDemigod( player ) )
			{
				DisableDemigod( player );
			}
		}
	)
	
	player.EndSignal( "OnDeath" )
	player.EndSignal( "OnDestroy" )
	player.EndSignal( "OnPrimaryAttack" )

	if( IsDemigod( player ) )
	{
		DisableDemigod( player );
	}
	else{
		//start protect
		EnableDemigod( player )
		wait time
		//cancel protect
		DisableDemigod( player );
	}
}