Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // alternative to checking alpha
- local plInfo = {}
- // Check if player is dead or alive
- local function CheckLifeState( pl )
- // Init varaibles if they didn't exist before
- if( !plInfo[pl] ) then
- plInfo[pl] = {};
- // Varaibles
- plInfo[pl].IsAlive = false;
- plInfo[pl].DiedThisFrame = false;
- plInfo[pl].SpawnedThisFrame = false;
- plInfo[pl].IsSpawnProtected = false;
- plInfo[pl].LF = {}
- plInfo[pl].LF.IsAlive = false;
- end
- // Restor these back to normal as they only are true for ONE frame
- plInfo[pl].DiedThisFrame = false;
- plInfo[pl].SpawnedThisFrame = false;
- // Normal check
- plInfo[pl].IsAlive = c.Player['Alive']( pl );
- // Player is DEAD and was ALIVE last frame.
- if( ( plInfo[pl].IsAlive == false ) && ( plInfo[pl].LF.IsAlive == true ) ) then
- plInfo[pl].DiedThisFrame = true;
- end
- // Player is ALIVE and was DEAD last frame.
- if( ( plInfo[pl].IsAlive == true ) && ( plInfo[pl].LF.IsAlive == false ) ) then
- plInfo[pl].SpawnedThisFrame = true;
- end
- // Check if the player has spawn protection
- if( plInfo[pl].SpawnedThisFrame && ( ( GAMEMODE.Name ):lower() ):find( "stronghold" ) ) then
- local bShouldProtect, spawners = true, ents.FindByClass( "sent_spawnpoint" ) || nil;
- if( spawners ) then
- for m, n in pairs( spawners ) do
- local entDist = n:GetPos():Distance( pl:GetPos() );
- if( entDist < 45 ) then
- bShouldProtect = false;
- end
- end
- end
- if( bShouldProtect ) then
- plInfo[pl].IsSpawnProtected = true;
- timer.Simple( 4, function()
- plInfo[pl].IsSpawnProtected = false;
- end )
- end
- end
- // Save data for this frame
- plInfo[pl].LF.IsAlive = c.Player['Alive']( pl );
- end
Advertisement
Add Comment
Please, Sign In to add comment