02.08.2012, 01:23
With only one per-player global variable you can do all the work. Let me show how that would happen:
pawn Код:
// top of script
new Dming[MAX_PLAYERS];
// We gonna set the value of this variable to 1 when a player joins a dm, and to 0 when a player leaves a dm.
// As I said above we will set it to 1 while in dm, so whenever you initialize a player for dm, put this:
Dming[playerid] = 1; // which tells the script that "playerid" is in a dm
// now you can use OnPlayerSpawn to respawn a player ('dm-er') to the dm arena after death
public OnPlayerSpawn(playerid)
{
if(Dming[playerid] == 1) // if was in a dm (This won't work if you set Dming to 0 under OnPlayerDeath)
{
// Respawn
}
return 1;
}
public OnPlayerConnect(playerid)
{
Dming[playerid] = 0; // when a player connects set it to 0 (To avoid ids conflicts)
return 1;
}
// And in your leavedm command remember to set Dming to 0
Dming[playerid] = 0; // out of dm