SA-MP Forums Archive
0.3 Needs Work God-Mode On Spawn - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: 0.3 Needs Work God-Mode On Spawn (/showthread.php?tid=107279)



0.3 Needs Work God-Mode On Spawn - Veinara - 09.11.2009

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;
}
}



Re: 0.3 Needs Work God-Mode On Spawn - Veinara - 09.11.2009

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.