Author Topic: Respawn time  (Read 1361 times)

How can i make it so the players cant respawn in a certain ammount of time.

For this you must modify a few things. First, we make it so a schedule starts when you die...

Code: [Select]
package TimedRespawn1 {
function Armor::onDisabled(%this,%obj,%state){
%client = %obj.client;
%client.canspawn = 0;
schedule(5000,0,"AllowRespawn",%client); //Change 5000 to whatever you want, its the time
parent::onDisabled(%this,%obj,%state);
}
};
activatepackage(TimedRespawn);

Then make a function to set a variable to 1 that will be read on spawn to allow spawning...

Code: [Select]
function AllowSpawn(%client){
%client.canspawn = 1;
}

Then modify the spawnplayer function to only work when you can spawn...

Code: [Select]
package TimedRespawn2 {
function GameConnection::spawnPlayer(%this)
{
if(%this.canspawn == 1){
parent::spawnPlayer(%this);
%this.canspawn = 0; //Reset it to 0 so you dont spawn next time
}else{
commandtoclient(%this,'centerPrint',"You cannot spawn yet!",1.5); //Tells the client they cant spawn
}
}
};
activatepackage(TimedRespawn2);

Ought to work...untested.

Code: [Select]
package TimedRespawn1 {
function Armor::onDisabled(%this,%obj,%state){
%client = %obj.client;
%client.canspawn = 0;
schedule(5000,0,eval,"%client.canspawn = 1;"); //Change 5000 to whatever you want, its the time
parent::onDisabled(%this,%obj,%state);
}
};
activatepackage(TimedRespawn);
That makes no need for a new command :P plus, no one can change it to be evil unless the host does so, and the point of it being evil would be the client doing it...I've been learning to script
Code: [Select]
package TimedRespawn2 {
function GameConnection::spawnPlayer(%this)
{
if(%this.canspawn == 1){
parent::spawnPlayer(%this);
%this.canspawn = 0; //Reset it to 0 so you dont spawn next time
}else{
commandtoclient(%this,'centerPrint',"You cannot spawn yet!",1.5); //Tells the client they cant spawn
}
}
};
activatepackage(TimedRespawn2);

Ought to work...untested.
Wouldn't that not let people who spawn after loading from joining not spawn at all?