It's based on how recently you joined the server and how much time has passed since the last time you were switched.
Source code needs to be cleaned up. Check line 46.
Not being able to respawn kind of sucks- should be fixable. A forward for sourcepawn would be useful. Then you could use a plugin to check immunity.