0.3 Needs Work God-Mode On Spawn
#1

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;
}
}
Reply
#2

Sorry for double reply but, just found out this god mode isn't work properly and I have no clue how to fix it, if anyone could fix it that will be nice! Thanks, what it does it gives everyone the godmode at same time, everyone shares it, and I only want it for each person separately, I feel embarrassed.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)