[Ajuda] Salvar players e gangzonas das gangs
#1

olб pessoal sou novo aqui e gostaria de pedir uma ajuda
meu gm tem um sistema de gang zonas comprбveis mais o problema dele й que nгo salva os players nem as gang dominбveis, e gostaria que ele salvasse na pasta filescripts do server se alguйm poder me ajuda eu ficarei muito grato.
Код:
public PlayerLeaveGang(playerid) {
	new string[256];
	new playername[MAX_PLAYER_NAME];
	new gangnum = playerGang[playerid];

  if(gangnum > 0) {
		for(new i = 0; i < gangInfo[gangnum][1]; i++) {
			if(gangMembers[gangnum][i]==playerid) {

			  gangInfo[gangnum][1]--;

   		  for(new j = i; j < gangInfo[gangnum][1]; j++) {
				  gangMembers[gangnum][j]=gangMembers[gangnum][j+1];
	  		}

			  if(gangInfo[gangnum][1]<1) {
			    gangInfo[gangnum][0]=0;
			    gangInfo[gangnum][1]=0;
			    gangBank[gangnum]=0;
    			}

				for(new j = 0; j < gangInfo[gangnum][1]; j++) {
				  GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
					format(string, sizeof(string),"%s Saiu da sua gang.", playername);
					SendClientMessage(gangMembers[gangnum][j], COLOR_ORANGE, string);
				}

				format(string, sizeof(string),"Vocк saiu da gang '%s' (id: %d)", gangNames[gangnum], gangnum);
				SendClientMessage(playerid, COLOR_ORANGE, string);

				playerGang[playerid]=0;

				SetPlayerColor(playerid,playerColors[playerid]);

				return;
			}
		}
	} else {
		SendClientMessage(playerid, COLOR_RED, "Vocк nгo pode entrar na gang.");
	}
}

public getCheckpointType(playerID) {
	return checkpointType[playerCheckpoint[playerID]];
}

public isPlayerInArea(playerID, Float:data[4])
{
	new Float:X, Float:Y, Float:Z;

	GetPlayerPos(playerID, X, Y, Z);
	if(X >= data[0] && X <= data[2] && Y >= data[1] && Y <= data[3]) {
		return 1;
	}
	return 0;
}

public PayPlayerInArea(playerID, Float:x1, Float:y1, Float:x2, Float:y2, cash)
{

	if(IsPlayerConnected(playerID))
	{
		new Float:X, Float:Y, Float:Z;

		GetPlayerPos(playerID, X, Y, Z);
		if(X >= x1 && X <= x2 && Y >= y1 && Y <= y2)
		{
			GivePlayerMoney(playerID, cash);
			return 1;
		}
	}
	return 0;
}

public PirateShipScoreUpdate()
{
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		PayPlayerInArea(i, 1995.5, 1518.0, 2006.0, 1569.0, 100);
//		{
//      SendClientMessage(i, COLOR_YELLOW, "[INFO]Vocк esta ganhando dinheiro por estar na area de dinheiro.");
//		}
	}
}

public PayPlayerInGz(playerID, GzID, Float:x1, Float:y1, Float:x2, Float:y2, cash) //ID_GZ
{

	if(IsPlayerConnected(playerID))
	{
		new Float:X, Float:Y, Float:Z, Float:Health, Float:Armour;
//		new GzIdx = gangZonaId[GzID];

		GetPlayerPos(playerID, X, Y, Z);
		GetPlayerHealth(playerID,Health);
		GetPlayerArmour(playerID,Armour);

		if((X >= x1) && (X <= x2) && (Y >= y1) && (Y <= y2))
		{
			if(playerGang[playerID] > 0)
			{
//				for(new i = 0 ; i < gangInfo[GzIdx][1]; i++)
//				{
//					if(gangMembers[GzIdx][i] == playerID)
//					{
					if(gangZonaId[GzID] == playerGang[playerID])
					{
						GivePlayerMoney(playerID, cash);

						if(Health < 105)
						{
							SetPlayerHealth(playerID,Health + 2);
						}
					  if(Armour< 105)
					  {
						  SetPlayerArmour(playerID,Armour + 2);
					  }
					}
					else
					{
						if(GZ_EXISTE[GzID][0] == 1)
						{
							if(Health > 2)
							{
								SetPlayerHealth(playerID,Health - 0);
							}
						}
						else
						{
							return 1;
						}
					}
//				}
			}
			else
			{
				if(GZ_EXISTE[GzID][0] == 1)
				{
					if(Health > 2)
					{
						SetPlayerHealth(playerID,Health - 0);
					}
				}
				else
				{
					return 1;
				}
			}
		}
		return 1;
	}
	return 0;
}

public GzScoreUpdate()
{
	for(new i = 0 ; i < MAX_PLAYERS ; i++)
	{
		// GZ AUTOBASE_LV
		PayPlayerInGz(i, 0, 1017.134948, 1222.946899, 1096.891235, 1361.736572, 500);
		// GZ CONSTRUCAO_LV
		PayPlayerInGz(i, 1, 2372.279052, 1832.521362, 2496.685302, 1962.471801, 500);
		// GZ RECINTO_LV
		PayPlayerInGz(i, 2, 2777.4753, 833.6251, 2894.6955, 1022.9479, 500);
		// GZ FABRICA_LV
		PayPlayerInGz(i, 3, 918.294555, 2043.856567, 996.507202, 2182.339599, 500);
		// GZ AEROPLACE_LV
		PayPlayerInGz(i, 4, 1638.5530, 1284.3757, 1716.3368, 1319.3700, 500);
		// GZ Disney_LV
		PayPlayerInGz(i, 5, 2079.743, 978.1417, 2329.653, 1171.545, 500);
		// GZ_EXERCITO_LV
		PayPlayerInGz(i, 6, 81.74512, 1763.359, 362.0141, 2055.306, 500);
		// GZ CALIGULAS_LV
		PayPlayerInGz(i, 7, 2099.267, 1535.143, 2290.605, 1728.547, 500);
		//GZ GOLF_LV
		PayPlayerInGz(i, 8, 1111.341, 2718.771, 1509.635, 2842.55, 500);
		//GZ_LV_
		PayPlayerInGz(i, 9, 2267.176, 2235.263, 2403.845, 2409.326, 500);
	}
	return 1;
}
Код:
	if(strcmp(cmdtext, "/gzcomprar", true) == 0)
	{
		new property = 999;

		if(IsPlayerInCheckpoint(playerid))
		{
			switch (playerCheckpoint[playerid])
			{
				case CP_GZ_AUTOBASE_LV:
				{
					property = P_GZ_AUTOBASE_LV;
					gz = 0;
				}
				case CP_GZ_CONSTRUCAO_LV:
				{
					property = P_GZ_CONSTRUCAO_LV;
					gz = 1;
				}
				case CP_GZ_RECINTO_LV:
				{
					property = P_GZ_RECINTO_LV;
					gz = 2;
				}
				case CP_GZ_FABRICA_LV:
				{
					property = P_GZ_FABRICA_LV;
					gz = 3;
				}
				case CP_GZ_AEROPLACE_LV:
				{
					property = P_GZ_AEROPLACE_LV;
					gz = 4;
				}
				case CP_GZ_DISNEY_LV:
				{
					property = P_GZ_DISNEY_LV;
					gz = 5;
				}
				case CP_GZ_EXERCITO_LV:
				{
					property = P_GZ_EXERCITO_LV;
					gz = 6;
				}
				case CP_GZ_CALIGULAS_LV:
				{
					property = P_GZ_CALIGULAS_LV;
					gz = 7;
				}
				case CP_GZ_GOLF_LV:
				{
					property = P_GZ_GOLF_LV;
					gz = 8;
				}
				case CP_GZ_LV:
				{
					property = P_GZ_LV;
					gz = 9;
				}
			}

			if(gz == 999 || property == 999)
			{
				SendClientMessage(playerid, COLOR_RED, "[GZ INFO] Vб para o checkpoint e digite /gzcomprar");
				return 1;
			}

			if(GetPlayerMoney(playerid) < propertyValues[property])
			{
				SendClientMessage(playerid, COLOR_RED, "<GZ INFO> Vocк nгo tem dinheiro para comprar essa Gang Zona!");
				return 1;
			}

			if(playerGang[playerid] > 0)
			{
				if(gangZonaId[gz] == playerGang[playerid])
				{
			   SendClientMessage(playerid, COLOR_RED, "[GZ]: Essa Gang Zona jб й da tua Gang!");
			   return 1;
			  }

			  new playerCor = gangInfo[playerGang[playerid]][2];
//			  gangInfo[playerGang[playerid]][2] = playerColors[playerid];

				if(GZ_EXISTE[gz][0] == 1)
				{
					GangZoneDestroy(GZ[gz]);
					GZ[gz] = 555;
				}

				if(gangZonaId[gz] > 0)
				{
					gangZonaIdAnter[gz] = gangZonaId[gz];
				}

				switch(gz)
				{
					case 0:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(1017.134948, 1222.946899, 1096.891235, 1361.736572);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					case 1:
					{

            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(2372.279052, 1832.521362, 2496.685302, 1962.471801);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					case 2:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(2777.4753, 833.6251, 2894.6955, 1022.9479);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					case 3:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(918.294555, 2043.856567, 996.507202, 2182.339599);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					case 4:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(1638.5530, 1284.3757, 1716.3368, 1319.3700);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					case 5:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(2079.743, 978.1417, 2329.653, 1171.545);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					case 6:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(81.74512, 1763.359, 362.0141, 2055.306);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					case 7:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(2099.267, 1535.143, 2290.605, 1728.547);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					case 8:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(1111.341, 2718.771, 1509.635, 2842.55);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}

					case 9:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(2267.176, 2235.263, 2403.845, 2409.326);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					default: return 1;
				}
			}
			else
			{
	      SendClientMessage(playerid, COLOR_RED, "[GZ INFO] Й preciso estar em uma gang para poder comprar!");
	      return 1;
			}

      if(GZ_EXISTE[gz][0] == 1)
      {
        GivePlayerMoney(playerid, 0-propertyValues[property]);

				format(string, sizeof(string), "A gang %s comprou a %s da gang %s!", gangNames[gangZonaId[gz]], propertyNames[property], gangNames[gangZonaIdAnter[gz]]);
				SendClientMessageToAll(COLOR_GREEN, string);
			}
		}
		else
		{
			SendClientMessage(playerid, COLOR_RED, "[GZ INFO] Necessario estar no checkpoint para poder /gzcomprar");
			return 1;
		}

		return 1;
	}
Код:
	if(strcmp(cmd, "/gang", true) == 0)
	{
	  new tmp[256];
	  new gangcmd, gangnum;
		tmp = strtok(cmdtext, idx);

		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COR_ROSA, "USE: /gang [criar/entrar/convite/sair/kick] [nome/id]");
			return 1;
		}
		giveplayerid = strval(tmp);

		if(strcmp(tmp, "criar", true)==0)
		  gangcmd = 1;
		else if(strcmp(tmp, "convite", true)==0)
		  gangcmd = 2;
		else if(strcmp(tmp, "entrar", true)==0)
		  gangcmd = 3;
		else if(strcmp(tmp, "sair", true)==0)
		  gangcmd = 4;
		else if(strcmp(tmp, "kick", true)==0)
		  gangcmd = 5;

		tmp = strtok(cmdtext, idx);

		if(gangcmd < 3 && !strlen(tmp))
		{
		  if(gangcmd==0)
				SendClientMessage(playerid, COR_ROSA, "<USE> /gang [criar/entrar/convite/sair] [nome/id]");
			else if(gangcmd==1)
				SendClientMessage(playerid, COR_ROSA, "<USE> /gang [criar] [nome]");
			else if(gangcmd==2)
				SendClientMessage(playerid, COR_ROSA, "<USE> /gang [convite] [playerid]");
			return 1;
		}

		if(gangcmd==1)
		{
		  if(playerGang[playerid]>0)
			{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Jб estб em uma gang!");
				return 1;
		  }

			for(new i = 1; i < MAX_GANGS; i++)
			{
				if(gangInfo[i][0]==0)
				{

					format(gangNames[i], MAX_GANG_NAME, "%s", tmp);

					gangInfo[i][0]=1;

					gangInfo[i][1]=1;

					gangInfo[i][2]=playerColors[playerid];


					gangMembers[i][0] = playerid;
					format(string, sizeof(string),"GANG: Vocк criou a gang:'%s' (id: %d)", gangNames[i], i);
					SendClientMessage(playerid, COLOR_GREEN, string);

					playerGang[playerid]=i;

					return 1;
				}
			}

			return 1;
		}
		else if(gangcmd==3)
		{
	 		gangnum = gangInvite[playerid];

		  if(playerGang[playerid] > 0)
			{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Vocк jб estб em uma gang!");
				return 1;
		  }

	 		if(gangInvite[playerid] == 0)
		 	{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Vocк nгo foi convidado para estб gang.");
				return 1;
			}

			if(gangInfo[gangnum][0] == 0)
			{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Essa gang nгo existe!");
				return 1;
			}

			if(gangInfo[gangnum][1] < MAX_GANG_MEMBERS)
			{
			  new i = gangInfo[gangnum][1];
				gangInvite[playerid] = 0;
				gangMembers[gangnum][i] = playerid;
			  GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);

				for(new j = 0; j < gangInfo[gangnum][1]; j++)
				{
					format(string, sizeof(string),"GANG: %s Vocк faz parte da gang.", sendername);
					SendClientMessage(gangMembers[gangnum][j], COLOR_ORANGE, string);
				}

				gangInfo[gangnum][1]++;
				playerGang[playerid] = gangnum;
				SetPlayerColor(playerid,gangInfo[gangnum][2]);

				format(string, sizeof(string),"GANG: Vocк entrou na gang:'%s' (id: %d)", gangNames[gangnum], gangnum);
				SendClientMessage(playerid, COLOR_GREEN, string);

				return 1;
			}

			SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Essa gang estб cheia.");
			return 1;

		}
		else if(gangcmd==2)
		{
	 		giveplayerid = strval(tmp);

			if(playerGang[playerid]==0)
			{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Vocк nгo estб em uma gang!");
				return 1;
			}
//			if(gangMembers[playerGang[playerid]][0] != playerid) {
//				SendClientMessage(playerid, COLOR_MAGENTA, "You need to be the gang leader to send an invite.");
//				return 1;
//			}

			if(IsPlayerConnected(giveplayerid))
			{
				GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
				GetPlayerName(playerid, sendername, sizeof(sendername));

				format(string, sizeof(string),"GANG: Vocк convidou %s.", giveplayer);
				SendClientMessage(playerid, COLOR_GREEN, string);
				format(string, sizeof(string),"GANG: Vocк recebeu um convite %s para se juntar a gang '%s' (id: %d)", sendername, gangNames[playerGang[playerid]],playerGang[playerid]);
				SendClientMessage(giveplayerid, COLOR_GREEN, string);

				gangInvite[giveplayerid] = playerGang[playerid];

			}
			else
			{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Esse player nгo existe!");
			}
		}
		else if(gangcmd==4)
		{
		  PlayerLeaveGang(playerid);
		}
		else if(gangcmd==5)
		{
			giveplayerid = strval(tmp);

			if(playerGang[playerid] == 0)
			{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Vocк nгo estб em uma gang!");
				return 1;
			}

			if(playerGang[giveplayerid] != playerGang[playerid])
			{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Este player nгo estб em sua gang!");
				return 1;
			}

			if(IsPlayerConnected(giveplayerid))
			{
			  gangnum = playerGang[playerid];

				if(gangMembers[gangnum][0] == playerid)
				{
					PlayerLeaveGang(giveplayerid);
				}
				else
				{
				  SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Vocк nгo й o Lider da gang, entгo nгo pode kickar membros de sua gang!");
				  return 1;
				}

				for(new j = 0; j < gangInfo[gangnum][1]; j++)
				{
					format(string, sizeof(string),"GANG: %s foi kickado da gang.", PlayerName(giveplayerid));
					SendClientMessage(gangMembers[gangnum][j], COLOR_ORANGE, string);
				}

				format(string, sizeof(string),"GANG: Vocк foi kickado da gang:'%s' (id: %d)", gangNames[gangnum], gangnum);
				SendClientMessage(giveplayerid, COLOR_ORANGE, string);
			}
			else
			{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Esse player nгo existe!");
			}
			return 1;
		}

		return 1;
	}
	if(strcmp(cmd, "/ganginfo", true) == 0)
	{
	  new tmp[256];
	  new gangnum;
	  new strlider[256];
		tmp = strtok(cmdtext, idx);

		if(!strlen(tmp) && playerGang[playerid]==0)
		{
			SendClientMessage(playerid, COLOR_YELLOW, "USE: /ganginfo [gangid]");
			return 1;
		}
		else if(!strlen(tmp))
		{
			gangnum = playerGang[playerid];
		}
		else
		{
			gangnum = strval(tmp);
		}

		if(gangInfo[gangnum][0]==0)
		{
			SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Essa gangue nгo existe");
			return 1;
		}

		format(string, sizeof(string),"GANG: '%s' Membros da gang (id: %d)", gangNames[gangnum], gangnum);
		SendClientMessage(playerid, COLOR_GREEN, string);

		for(new i = 0; i < gangInfo[gangnum][1]; i++)
		{
			if(i == 0)
			{
				strlider = "Lider: ";
			}
			else
			{
        strlider = "";
			}

			GetPlayerName(gangMembers[gangnum][i], giveplayer, sizeof(giveplayer));
			format(string, sizeof(string),"GANG: %s%s (%d)", strlider, giveplayer, gangMembers[gangnum][i]);
			SendClientMessage(playerid, COLOR_YELLOW, string);
		}

		return 1;
	}

	if(strcmp(cmd, "/gangs", true) == 0)
	{
		new x;

		SendClientMessage(playerid, COLOR_GREEN, "GANGS CRIADAS");

		for(new i=0; i < MAX_GANGS; i++)
		{
			if(gangInfo[i][0]==1)
			{
				format(string, sizeof(string), "%s%s(%d) - %d Membros", string,gangNames[i],i,gangInfo[i][1]);

				x++;
				if(x > 2)
				{
				  SendClientMessage(playerid, COLOR_YELLOW, string);
				  x = 0;
					format(string, sizeof(string), "");
				}
				else
				{
					format(string, sizeof(string), "%s, ", string);
				}
			}
		}

		if(x <= 2 && x > 0)
		{
			string[strlen(string)-2] = '.';
	  	SendClientMessage(playerid, COLOR_YELLOW, string);
		}

		return 1;
	}

	return SendClientMessage(playerid,COLOR_RED,"Comando Inexistente!");
}
ai esta o codigo completo
Reply
#2

Aew cara aprende dini pra criar as files que vгo salvar as strings. sу estuda dini e dudb.
Reply
#3

Quote:
Originally Posted by Phoenix Encoderґs
Aew cara aprende dini pra criar as files que vгo salvar as strings. sу estuda dini e dudb.
usa dini para guardar as coordandas da ggang, a cor (ex: 0xFFFFFFFF), e salva (com o public OnPlayerUpdate, ou algo que tenhas criado, se o tiveres feito)...
Reply
#4

Quote:
Originally Posted by frenetico157
olб pessoal sou novo aqui e gostaria de pedir uma ajuda
meu gm tem um sistema de gang zonas comprбveis mais o problema dele й que nгo salva os players nem as gang dominбveis, e gostaria que ele salvasse na pasta filescripts do server se alguйm poder me ajuda eu ficarei muito grato.
Код:
public PlayerLeaveGang(playerid) {
	new string[256];
	new playername[MAX_PLAYER_NAME];
	new gangnum = playerGang[playerid];

  if(gangnum > 0) {
		for(new i = 0; i < gangInfo[gangnum][1]; i++) {
			if(gangMembers[gangnum][i]==playerid) {

			  gangInfo[gangnum][1]--;

   		  for(new j = i; j < gangInfo[gangnum][1]; j++) {
				  gangMembers[gangnum][j]=gangMembers[gangnum][j+1];
	  		}

			  if(gangInfo[gangnum][1]<1) {
			    gangInfo[gangnum][0]=0;
			    gangInfo[gangnum][1]=0;
			    gangBank[gangnum]=0;
   			}

				for(new j = 0; j < gangInfo[gangnum][1]; j++) {
				  GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
					format(string, sizeof(string),"%s Saiu da sua gang.", playername);
					SendClientMessage(gangMembers[gangnum][j], COLOR_ORANGE, string);
				}

				format(string, sizeof(string),"Vocк saiu da gang '%s' (id: %d)", gangNames[gangnum], gangnum);
				SendClientMessage(playerid, COLOR_ORANGE, string);

				playerGang[playerid]=0;

				SetPlayerColor(playerid,playerColors[playerid]);

				return;
			}
		}
	} else {
		SendClientMessage(playerid, COLOR_RED, "Vocк nгo pode entrar na gang.");
	}
}

public getCheckpointType(playerID) {
	return checkpointType[playerCheckpoint[playerID]];
}

public isPlayerInArea(playerID, Float:data[4])
{
	new Float:X, Float:Y, Float:Z;

	GetPlayerPos(playerID, X, Y, Z);
	if(X >= data[0] && X <= data[2] && Y >= data[1] && Y <= data[3]) {
		return 1;
	}
	return 0;
}

public PayPlayerInArea(playerID, Float:x1, Float:y1, Float:x2, Float:y2, cash)
{

	if(IsPlayerConnected(playerID))
	{
		new Float:X, Float:Y, Float:Z;

		GetPlayerPos(playerID, X, Y, Z);
		if(X >= x1 && X <= x2 && Y >= y1 && Y <= y2)
		{
			GivePlayerMoney(playerID, cash);
			return 1;
		}
	}
	return 0;
}

public PirateShipScoreUpdate()
{
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		PayPlayerInArea(i, 1995.5, 1518.0, 2006.0, 1569.0, 100);
//		{
//      SendClientMessage(i, COLOR_YELLOW, "[INFO]Vocк esta ganhando dinheiro por estar na area de dinheiro.");
//		}
	}
}

public PayPlayerInGz(playerID, GzID, Float:x1, Float:y1, Float:x2, Float:y2, cash) //ID_GZ
{

	if(IsPlayerConnected(playerID))
	{
		new Float:X, Float:Y, Float:Z, Float:Health, Float:Armour;
//		new GzIdx = gangZonaId[GzID];

		GetPlayerPos(playerID, X, Y, Z);
		GetPlayerHealth(playerID,Health);
		GetPlayerArmour(playerID,Armour);

		if((X >= x1) && (X <= x2) && (Y >= y1) && (Y <= y2))
		{
			if(playerGang[playerID] > 0)
			{
//				for(new i = 0 ; i < gangInfo[GzIdx][1]; i++)
//				{
//					if(gangMembers[GzIdx][i] == playerID)
//					{
					if(gangZonaId[GzID] == playerGang[playerID])
					{
						GivePlayerMoney(playerID, cash);

						if(Health < 105)
						{
							SetPlayerHealth(playerID,Health + 2);
						}
					  if(Armour< 105)
					  {
						  SetPlayerArmour(playerID,Armour + 2);
					  }
					}
					else
					{
						if(GZ_EXISTE[GzID][0] == 1)
						{
							if(Health > 2)
							{
								SetPlayerHealth(playerID,Health - 0);
							}
						}
						else
						{
							return 1;
						}
					}
//				}
			}
			else
			{
				if(GZ_EXISTE[GzID][0] == 1)
				{
					if(Health > 2)
					{
						SetPlayerHealth(playerID,Health - 0);
					}
				}
				else
				{
					return 1;
				}
			}
		}
		return 1;
	}
	return 0;
}

public GzScoreUpdate()
{
	for(new i = 0 ; i < MAX_PLAYERS ; i++)
	{
		// GZ AUTOBASE_LV
		PayPlayerInGz(i, 0, 1017.134948, 1222.946899, 1096.891235, 1361.736572, 500);
		// GZ CONSTRUCAO_LV
		PayPlayerInGz(i, 1, 2372.279052, 1832.521362, 2496.685302, 1962.471801, 500);
		// GZ RECINTO_LV
		PayPlayerInGz(i, 2, 2777.4753, 833.6251, 2894.6955, 1022.9479, 500);
		// GZ FABRICA_LV
		PayPlayerInGz(i, 3, 918.294555, 2043.856567, 996.507202, 2182.339599, 500);
		// GZ AEROPLACE_LV
		PayPlayerInGz(i, 4, 1638.5530, 1284.3757, 1716.3368, 1319.3700, 500);
		// GZ Disney_LV
		PayPlayerInGz(i, 5, 2079.743, 978.1417, 2329.653, 1171.545, 500);
		// GZ_EXERCITO_LV
		PayPlayerInGz(i, 6, 81.74512, 1763.359, 362.0141, 2055.306, 500);
		// GZ CALIGULAS_LV
		PayPlayerInGz(i, 7, 2099.267, 1535.143, 2290.605, 1728.547, 500);
		//GZ GOLF_LV
		PayPlayerInGz(i, 8, 1111.341, 2718.771, 1509.635, 2842.55, 500);
		//GZ_LV_
		PayPlayerInGz(i, 9, 2267.176, 2235.263, 2403.845, 2409.326, 500);
	}
	return 1;
}
Код:
	if(strcmp(cmdtext, "/gzcomprar", true) == 0)
	{
		new property = 999;

		if(IsPlayerInCheckpoint(playerid))
		{
			switch (playerCheckpoint[playerid])
			{
				case CP_GZ_AUTOBASE_LV:
				{
					property = P_GZ_AUTOBASE_LV;
					gz = 0;
				}
				case CP_GZ_CONSTRUCAO_LV:
				{
					property = P_GZ_CONSTRUCAO_LV;
					gz = 1;
				}
				case CP_GZ_RECINTO_LV:
				{
					property = P_GZ_RECINTO_LV;
					gz = 2;
				}
				case CP_GZ_FABRICA_LV:
				{
					property = P_GZ_FABRICA_LV;
					gz = 3;
				}
				case CP_GZ_AEROPLACE_LV:
				{
					property = P_GZ_AEROPLACE_LV;
					gz = 4;
				}
				case CP_GZ_DISNEY_LV:
				{
					property = P_GZ_DISNEY_LV;
					gz = 5;
				}
				case CP_GZ_EXERCITO_LV:
				{
					property = P_GZ_EXERCITO_LV;
					gz = 6;
				}
				case CP_GZ_CALIGULAS_LV:
				{
					property = P_GZ_CALIGULAS_LV;
					gz = 7;
				}
				case CP_GZ_GOLF_LV:
				{
					property = P_GZ_GOLF_LV;
					gz = 8;
				}
				case CP_GZ_LV:
				{
					property = P_GZ_LV;
					gz = 9;
				}
			}

			if(gz == 999 || property == 999)
			{
				SendClientMessage(playerid, COLOR_RED, "[GZ INFO] Vб para o checkpoint e digite /gzcomprar");
				return 1;
			}

			if(GetPlayerMoney(playerid) < propertyValues[property])
			{
				SendClientMessage(playerid, COLOR_RED, "<GZ INFO> Vocк nгo tem dinheiro para comprar essa Gang Zona!");
				return 1;
			}

			if(playerGang[playerid] > 0)
			{
				if(gangZonaId[gz] == playerGang[playerid])
				{
			   SendClientMessage(playerid, COLOR_RED, "[GZ]: Essa Gang Zona jб й da tua Gang!");
			   return 1;
			  }

			  new playerCor = gangInfo[playerGang[playerid]][2];
//			  gangInfo[playerGang[playerid]][2] = playerColors[playerid];

				if(GZ_EXISTE[gz][0] == 1)
				{
					GangZoneDestroy(GZ[gz]);
					GZ[gz] = 555;
				}

				if(gangZonaId[gz] > 0)
				{
					gangZonaIdAnter[gz] = gangZonaId[gz];
				}

				switch(gz)
				{
					case 0:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(1017.134948, 1222.946899, 1096.891235, 1361.736572);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					case 1:
					{

            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(2372.279052, 1832.521362, 2496.685302, 1962.471801);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					case 2:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(2777.4753, 833.6251, 2894.6955, 1022.9479);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					case 3:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(918.294555, 2043.856567, 996.507202, 2182.339599);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					case 4:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(1638.5530, 1284.3757, 1716.3368, 1319.3700);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					case 5:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(2079.743, 978.1417, 2329.653, 1171.545);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					case 6:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(81.74512, 1763.359, 362.0141, 2055.306);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					case 7:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(2099.267, 1535.143, 2290.605, 1728.547);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					case 8:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(1111.341, 2718.771, 1509.635, 2842.55);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}

					case 9:
					{
            if((!GZ[gz]) || (GZ[gz] == 555))
            {
							GZ[gz] = GangZoneCreate(2267.176, 2235.263, 2403.845, 2409.326);
  						GangZoneShowForAll(GZ[gz], playerCor);
							gangZonaId[gz] = playerGang[playerid];
							GZ_EXISTE[gz][0] = 1;
							GZ_EXISTE[gz][1] = playerCor;
						}
					}
					default: return 1;
				}
			}
			else
			{
	     SendClientMessage(playerid, COLOR_RED, "[GZ INFO] Й preciso estar em uma gang para poder comprar!");
	     return 1;
			}

      if(GZ_EXISTE[gz][0] == 1)
      {
        GivePlayerMoney(playerid, 0-propertyValues[property]);

				format(string, sizeof(string), "A gang %s comprou a %s da gang %s!", gangNames[gangZonaId[gz]], propertyNames[property], gangNames[gangZonaIdAnter[gz]]);
				SendClientMessageToAll(COLOR_GREEN, string);
			}
		}
		else
		{
			SendClientMessage(playerid, COLOR_RED, "[GZ INFO] Necessario estar no checkpoint para poder /gzcomprar");
			return 1;
		}

		return 1;
	}
Код:
	if(strcmp(cmd, "/gang", true) == 0)
	{
	  new tmp[256];
	  new gangcmd, gangnum;
		tmp = strtok(cmdtext, idx);

		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COR_ROSA, "USE: /gang [criar/entrar/convite/sair/kick] [nome/id]");
			return 1;
		}
		giveplayerid = strval(tmp);

		if(strcmp(tmp, "criar", true)==0)
		  gangcmd = 1;
		else if(strcmp(tmp, "convite", true)==0)
		  gangcmd = 2;
		else if(strcmp(tmp, "entrar", true)==0)
		  gangcmd = 3;
		else if(strcmp(tmp, "sair", true)==0)
		  gangcmd = 4;
		else if(strcmp(tmp, "kick", true)==0)
		  gangcmd = 5;

		tmp = strtok(cmdtext, idx);

		if(gangcmd < 3 && !strlen(tmp))
		{
		  if(gangcmd==0)
				SendClientMessage(playerid, COR_ROSA, "<USE> /gang [criar/entrar/convite/sair] [nome/id]");
			else if(gangcmd==1)
				SendClientMessage(playerid, COR_ROSA, "<USE> /gang [criar] [nome]");
			else if(gangcmd==2)
				SendClientMessage(playerid, COR_ROSA, "<USE> /gang [convite] [playerid]");
			return 1;
		}

		if(gangcmd==1)
		{
		  if(playerGang[playerid]>0)
			{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Jб estб em uma gang!");
				return 1;
		  }

			for(new i = 1; i < MAX_GANGS; i++)
			{
				if(gangInfo[i][0]==0)
				{

					format(gangNames[i], MAX_GANG_NAME, "%s", tmp);

					gangInfo[i][0]=1;

					gangInfo[i][1]=1;

					gangInfo[i][2]=playerColors[playerid];


					gangMembers[i][0] = playerid;
					format(string, sizeof(string),"GANG: Vocк criou a gang:'%s' (id: %d)", gangNames[i], i);
					SendClientMessage(playerid, COLOR_GREEN, string);

					playerGang[playerid]=i;

					return 1;
				}
			}

			return 1;
		}
		else if(gangcmd==3)
		{
	 		gangnum = gangInvite[playerid];

		  if(playerGang[playerid] > 0)
			{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Vocк jб estб em uma gang!");
				return 1;
		  }

	 		if(gangInvite[playerid] == 0)
		 	{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Vocк nгo foi convidado para estб gang.");
				return 1;
			}

			if(gangInfo[gangnum][0] == 0)
			{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Essa gang nгo existe!");
				return 1;
			}

			if(gangInfo[gangnum][1] < MAX_GANG_MEMBERS)
			{
			  new i = gangInfo[gangnum][1];
				gangInvite[playerid] = 0;
				gangMembers[gangnum][i] = playerid;
			  GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);

				for(new j = 0; j < gangInfo[gangnum][1]; j++)
				{
					format(string, sizeof(string),"GANG: %s Vocк faz parte da gang.", sendername);
					SendClientMessage(gangMembers[gangnum][j], COLOR_ORANGE, string);
				}

				gangInfo[gangnum][1]++;
				playerGang[playerid] = gangnum;
				SetPlayerColor(playerid,gangInfo[gangnum][2]);

				format(string, sizeof(string),"GANG: Vocк entrou na gang:'%s' (id: %d)", gangNames[gangnum], gangnum);
				SendClientMessage(playerid, COLOR_GREEN, string);

				return 1;
			}

			SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Essa gang estб cheia.");
			return 1;

		}
		else if(gangcmd==2)
		{
	 		giveplayerid = strval(tmp);

			if(playerGang[playerid]==0)
			{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Vocк nгo estб em uma gang!");
				return 1;
			}
//			if(gangMembers[playerGang[playerid]][0] != playerid) {
//				SendClientMessage(playerid, COLOR_MAGENTA, "You need to be the gang leader to send an invite.");
//				return 1;
//			}

			if(IsPlayerConnected(giveplayerid))
			{
				GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
				GetPlayerName(playerid, sendername, sizeof(sendername));

				format(string, sizeof(string),"GANG: Vocк convidou %s.", giveplayer);
				SendClientMessage(playerid, COLOR_GREEN, string);
				format(string, sizeof(string),"GANG: Vocк recebeu um convite %s para se juntar a gang '%s' (id: %d)", sendername, gangNames[playerGang[playerid]],playerGang[playerid]);
				SendClientMessage(giveplayerid, COLOR_GREEN, string);

				gangInvite[giveplayerid] = playerGang[playerid];

			}
			else
			{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Esse player nгo existe!");
			}
		}
		else if(gangcmd==4)
		{
		  PlayerLeaveGang(playerid);
		}
		else if(gangcmd==5)
		{
			giveplayerid = strval(tmp);

			if(playerGang[playerid] == 0)
			{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Vocк nгo estб em uma gang!");
				return 1;
			}

			if(playerGang[giveplayerid] != playerGang[playerid])
			{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Este player nгo estб em sua gang!");
				return 1;
			}

			if(IsPlayerConnected(giveplayerid))
			{
			  gangnum = playerGang[playerid];

				if(gangMembers[gangnum][0] == playerid)
				{
					PlayerLeaveGang(giveplayerid);
				}
				else
				{
				  SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Vocк nгo й o Lider da gang, entгo nгo pode kickar membros de sua gang!");
				  return 1;
				}

				for(new j = 0; j < gangInfo[gangnum][1]; j++)
				{
					format(string, sizeof(string),"GANG: %s foi kickado da gang.", PlayerName(giveplayerid));
					SendClientMessage(gangMembers[gangnum][j], COLOR_ORANGE, string);
				}

				format(string, sizeof(string),"GANG: Vocк foi kickado da gang:'%s' (id: %d)", gangNames[gangnum], gangnum);
				SendClientMessage(giveplayerid, COLOR_ORANGE, string);
			}
			else
			{
				SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Esse player nгo existe!");
			}
			return 1;
		}

		return 1;
	}
	if(strcmp(cmd, "/ganginfo", true) == 0)
	{
	  new tmp[256];
	  new gangnum;
	  new strlider[256];
		tmp = strtok(cmdtext, idx);

		if(!strlen(tmp) && playerGang[playerid]==0)
		{
			SendClientMessage(playerid, COLOR_YELLOW, "USE: /ganginfo [gangid]");
			return 1;
		}
		else if(!strlen(tmp))
		{
			gangnum = playerGang[playerid];
		}
		else
		{
			gangnum = strval(tmp);
		}

		if(gangInfo[gangnum][0]==0)
		{
			SendClientMessage(playerid, COLOR_MAGENTA, "GANG: Essa gangue nгo existe");
			return 1;
		}

		format(string, sizeof(string),"GANG: '%s' Membros da gang (id: %d)", gangNames[gangnum], gangnum);
		SendClientMessage(playerid, COLOR_GREEN, string);

		for(new i = 0; i < gangInfo[gangnum][1]; i++)
		{
			if(i == 0)
			{
				strlider = "Lider: ";
			}
			else
			{
        strlider = "";
			}

			GetPlayerName(gangMembers[gangnum][i], giveplayer, sizeof(giveplayer));
			format(string, sizeof(string),"GANG: %s%s (%d)", strlider, giveplayer, gangMembers[gangnum][i]);
			SendClientMessage(playerid, COLOR_YELLOW, string);
		}

		return 1;
	}

	if(strcmp(cmd, "/gangs", true) == 0)
	{
		new x;

		SendClientMessage(playerid, COLOR_GREEN, "GANGS CRIADAS");

		for(new i=0; i < MAX_GANGS; i++)
		{
			if(gangInfo[i][0]==1)
			{
				format(string, sizeof(string), "%s%s(%d) - %d Membros", string,gangNames[i],i,gangInfo[i][1]);

				x++;
				if(x > 2)
				{
				  SendClientMessage(playerid, COLOR_YELLOW, string);
				  x = 0;
					format(string, sizeof(string), "");
				}
				else
				{
					format(string, sizeof(string), "%s, ", string);
				}
			}
		}

		if(x <= 2 && x > 0)
		{
			string[strlen(string)-2] = '.';
	  	SendClientMessage(playerid, COLOR_YELLOW, string);
		}

		return 1;
	}

	return SendClientMessage(playerid,COLOR_RED,"Comando Inexistente!");
}
ai esta o codigo completo
ae Vey Aki ta o link do tutorial : http://forum.sa-mp.com/index.php?topic=169012.0
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)