09.11.2009, 06:21
Hello, this is something I had made from scratch, and it work nicely 

Код:
new GodModeActive[MAX_PLAYERS];
public OnPlayerSpawn(playerid)
{
GodModeActive[playerid]=1;
PrepareGodMode();
return 1;
}
//---------------------------------------------------------
forward PrepareGodMode();
public PrepareGodMode()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GodModeActive[i] != 0)
{
SendClientMessage(i, COLOR_YELLOW, "You have god mode for 20 seconds.");
}
}
}
SetTimer("StartGodMode", 1000, 0);
return 1;
}
forward StartGodMode();
public StartGodMode()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GodModeActive[i] != 0)
{
SetPlayerHealth(i,1000.0);
}
}
}
SetTimer("GodModeEnded", 20000, 0);
return 1;
}
forward GodModeEnded();
public GodModeEnded()
{
new string[256];
new name[MAX_PLAYER_NAME];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GodModeActive[i] != 0)
{
if(IsPlayerConnected(i))
{
GetPlayerName(i, name, sizeof(name));
SetPlayerHealth(i,100.0);
format(string,sizeof(string), "** %s godmode has ended.",name);
SendClientMessage(i, COLOR_WHITE, string);
}
GodModeActive[i] = 0;
}
}
}
return 1;
}
}

