problem a CMD (attack) +rep
#1

Hello.
i was have a system attack in weeks, now i edited it , i change it is all days can war in time 20pm at 22pm
and when i try to attack can't work me i got message war can be time 20:00 at 22:00 and time is 20:00 and i can't attack do war..

cmd code

Код:
CMD:attack(playerid, params[])
{
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
	if(IsPlayerConnected(playerid))
	{
	    new hour,minn,sec;
	    gettime(hour,minn,sec);
	    if(hour > 20 || hour < 22) return SCM(playerid,COLOR_WHITE,"{FFFFFF}You can't start a war now , war can start in 19:00 at 22:00");
		if(!IsAMember(playerid)) return SCM(playerid,COLOR_WHITE,"You are not a member of a mafia.");
		if(PlayerInfo[playerid][pRank] < 4) return SCM(playerid,COLOR_WHITE,"You don't have rank 4.");
		/*if(hour > 20 || hour < 24) return SCM(playerid,COLOR_WHITE,"{FFB870}Error: You can't start a war now.");*/
		{
			new turf,faction,string[128],sendername[MAX_PLAYER_NAME];
			for(new i = 1; i <= sizeof(TurfInfo); i++)
			{
				if(IsPlayerInTurf(playerid, i) == 1)
				{
					turf = i;
					break;
				}
    		}
    		GetPlayerName(playerid, sendername, sizeof(sendername));
    		if(turf == 0) return SCM(playerid, COLOR_WHITE, "You are not on a turf.");
			if(DeelayWar[PlayerInfo[playerid][pMember]] > 0)
			{
				format(string,sizeof(string),"Your mafia can attack another turf in %d seconds.",DeelayWar[PlayerInfo[playerid][pMember]]);
				SendClientMessage(playerid, COLOR_WHITE, string);
				return 1;
			}
    		faction = PlayerInfo[playerid][pMember];
    		if(TurfInfo[turf][zOwned] == faction) return SCM(playerid, COLOR_WHITE, "You can't attack your own turf.");
			if(WarInfo[turf][wAttacker] != 0) return SCM(playerid, COLOR_WHITE, "Turf is already attacked.");
			if(InWar[faction] == 1) return SCM(playerid, COLOR_WHITE, "You have an active war.");
			if(InWar[TurfInfo[turf][zOwned]] == 1) return SCM(playerid, COLOR_WHITE, "This mafia have active war.");
			new memberss;
			foreach(Player, i)
			{
	    		if(IsPlayerConnected(i))
	    		{
	        		if(PlayerInfo[i][pMember] == TurfInfo[turf][zOwned])
					{
			    		memberss ++;
					}
				}
			}
			if(memberss < 1) return SCM(playerid, COLOR_WHITE, "This mafia don't have members online.");
			WarInfo[turf][wTime] = 1200;
			WarInfo[turf][wAttacker] = faction;
			WarInfo[turf][wFaction] = TurfInfo[turf][zOwned];
			format(string,sizeof(string),"[TURF] %s from your group attacked turf %d (owned by %s).",sendername,turf,NumeFactiune(TurfInfo[turf][zOwned]));
			SendFamilyMessage(faction,COLOR_GREEN,string);
			format(string,sizeof(string),"[TURF] %s from %s attacked turf %d owned by you.",sendername,NumeFactiune(WarInfo[turf][wAttacker]),turf);
			SendFamilyMessage(TurfInfo[turf][zOwned],COLOR_GREEN,string);
			new Cache: abs = mysql_query(SQL, "SELECT * FROM wars");
			new warid = cache_get_row_count() + 1; 
			cache_delete(abs);
			format(string, sizeof(string),"[WAR] %s started a war with %s (war id: %d).",NumeFactiune(WarInfo[turf][wAttacker]),NumeFactiune(TurfInfo[turf][zOwned]),warid);
			ABroadCast(COLOR_ADMCOMMANDS,string,1);
			foreach(Player, i)
			{
				if(PlayerInfo[i][pMember] == TurfInfo[turf][zOwned] || PlayerInfo[i][pMember] == WarInfo[turf][wAttacker])
				{
					SetPlayerVirtualWorld(i, 1024);
					SendClientMessage(i, COLOR_YELLOW, "Ai fost teleportat intr-un Virtual World unde sunt prezenti doar jucatorii ce participa la war.");
				}
			}
			if(WarInfo[turf][wAttacker] == 4 || TurfInfo[turf][zOwned] == 4)
			{
				for(new x = 0; x < sizeof(VehicleInfo); x++) 
				{
					if(VehicleInfo[x][vehGroup] == 4)
					{
						SetVehicleVirtualWorld(VehicleInfo[x][vehCarID], 1024);
					}
				}
			}
			if(WarInfo[turf][wAttacker] == 5 || TurfInfo[turf][zOwned] == 5)
			{
				for(new x = 0; x < sizeof(VehicleInfo); x++) 
				{
					if(VehicleInfo[x][vehGroup] == 5)
					{
						SetVehicleVirtualWorld(VehicleInfo[x][vehCarID], 1024);
					}
				}
			}
			if(WarInfo[turf][wAttacker] == 6 || TurfInfo[turf][zOwned] == 6)
			{
				for(new x = 0; x < sizeof(VehicleInfo); x++) 
				{
					if(VehicleInfo[x][vehGroup] == 6)
					{
						SetVehicleVirtualWorld(VehicleInfo[x][vehCarID], 1024);
					}
				}
			}
			if(WarInfo[turf][wAttacker] == 10 || TurfInfo[turf][zOwned] == 10)
			{
				for(new x = 0; x < sizeof(VehicleInfo); x++) 
				{
					if(VehicleInfo[x][vehGroup] == 10)
					{
						SetVehicleVirtualWorld(VehicleInfo[x][vehCarID], 1024);
					}
				}
			}
			new y,m,d,h,mi,s;
			getdate(y,m,d);
			gettime(h,mi,s);
			worstscoreat[turf] = 0;
			worstmemberat[turf] = 999;
			bestscoreat[turf] = 0;
			bestmemberat[turf] = 999;
			worstscoredf[turf] = 0;
			worstmemberdf[turf] = 999;
			bestscoredf[turf] = 0;
			bestmemberdf[turf] = 999;
			InWar[TurfInfo[turf][zOwned]] = 1;
			InWar[faction] = 1;
			waitwar[faction] = 60;
            }
	  }
	  return 1;
}
this cmd old of week
Код:
CMD:attack(playerid, params[])
{
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
	new hour,minn,sec;
	gettime(hour,minn,sec);
	if(IsPlayerConnected(playerid))
	{
		if(!IsAMember(playerid)) return SCM(playerid,COLOR_WHITE,"You are not a member of a mafia.");
		if(PlayerInfo[playerid][pRank] < 4) return SCM(playerid,COLOR_WHITE,"You don't have rank 4.");
		if(GetWeekDay() == 1 || GetWeekDay() == 4 || GetWeekDay() == 6) return SendClientMessage(playerid, COLOR_WHITE, "War-ul este permis doar Luni, Miercuri, Vineri si Duminica.");
		if(hour == 20 || hour == 21)
		{
			new turf,faction,string[128],sendername[MAX_PLAYER_NAME];
			for(new i = 1; i <= sizeof(TurfInfo); i++)
			{
				if(IsPlayerInTurf(playerid, i) == 1)
				{
					turf = i;
					break;
				}
    		}
    		GetPlayerName(playerid, sendername, sizeof(sendername));
    		if(turf == 0) return SCM(playerid, COLOR_WHITE, "You are not on a turf.");
			if(DeelayWar[PlayerInfo[playerid][pMember]] > 0)
			{
				format(string,sizeof(string),"Your mafia can attack another turf in %d seconds.",DeelayWar[PlayerInfo[playerid][pMember]]);
				SendClientMessage(playerid, COLOR_WHITE, string);
				return 1;
			}
    		faction = PlayerInfo[playerid][pMember];
    		if(TurfInfo[turf][zOwned] == faction) return SCM(playerid, COLOR_WHITE, "You can't attack your own turf.");
			if(WarInfo[turf][wAttacker] != 0) return SCM(playerid, COLOR_WHITE, "Turf is already attacked.");
			if(InWar[faction] == 1) return SCM(playerid, COLOR_WHITE, "You have an active war.");
			if(InWar[TurfInfo[turf][zOwned]] == 1) return SCM(playerid, COLOR_WHITE, "This mafia have active war.");
			new memberss;
			foreach(Player, i)
			{
	    		if(IsPlayerConnected(i))
	    		{
	        		if(PlayerInfo[i][pMember] == TurfInfo[turf][zOwned])
					{
			    		memberss ++;
					}
				}
			}
			if(memberss < 1) return SCM(playerid, COLOR_WHITE, "This mafia don't have members online.");
			WarInfo[turf][wTime] = 1200;
			WarInfo[turf][wAttacker] = faction;
			WarInfo[turf][wFaction] = TurfInfo[turf][zOwned];
			format(string,sizeof(string),"[TURF] %s from your group attacked turf %d (owned by %s).",sendername,turf,NumeFactiune(TurfInfo[turf][zOwned]));
			SendFamilyMessage(faction,COLOR_GREEN,string);
			format(string,sizeof(string),"[TURF] %s from %s attacked turf %d owned by you.",sendername,NumeFactiune(WarInfo[turf][wAttacker]),turf);
			SendFamilyMessage(TurfInfo[turf][zOwned],COLOR_GREEN,string);
			new Cache: abs = mysql_query(SQL, "SELECT * FROM wars");
			new warid = cache_get_row_count() + 1; 
			cache_delete(abs);
			format(string, sizeof(string),"[WAR] %s started a war with %s (war id: %d).",NumeFactiune(WarInfo[turf][wAttacker]),NumeFactiune(TurfInfo[turf][zOwned]),warid);
			ABroadCast(COLOR_ADMCOMMANDS,string,1);
			foreach(Player, i)
			{
				if(PlayerInfo[i][pMember] == TurfInfo[turf][zOwned] || PlayerInfo[i][pMember] == WarInfo[turf][wAttacker])
				{
					SetPlayerVirtualWorld(i, 1024);
					SendClientMessage(i, COLOR_YELLOW, "Ai fost teleportat intr-un Virtual World unde sunt prezenti doar jucatorii ce participa la war.");
				}
			}
			if(WarInfo[turf][wAttacker] == 4 || TurfInfo[turf][zOwned] == 4)
			{
				for(new x = 0; x < sizeof(VehicleInfo); x++) 
				{
					if(VehicleInfo[x][vehGroup] == 4)
					{
						SetVehicleVirtualWorld(VehicleInfo[x][vehCarID], 1024);
					}
				}
			}
			if(WarInfo[turf][wAttacker] == 5 || TurfInfo[turf][zOwned] == 5)
			{
				for(new x = 0; x < sizeof(VehicleInfo); x++) 
				{
					if(VehicleInfo[x][vehGroup] == 5)
					{
						SetVehicleVirtualWorld(VehicleInfo[x][vehCarID], 1024);
					}
				}
			}
			if(WarInfo[turf][wAttacker] == 6 || TurfInfo[turf][zOwned] == 6)
			{
				for(new x = 0; x < sizeof(VehicleInfo); x++) 
				{
					if(VehicleInfo[x][vehGroup] == 6)
					{
						SetVehicleVirtualWorld(VehicleInfo[x][vehCarID], 1024);
					}
				}
			}
			if(WarInfo[turf][wAttacker] == 10 || TurfInfo[turf][zOwned] == 10)
			{
				for(new x = 0; x < sizeof(VehicleInfo); x++) 
				{
					if(VehicleInfo[x][vehGroup] == 10)
					{
						SetVehicleVirtualWorld(VehicleInfo[x][vehCarID], 1024);
					}
				}
			}
			new y,m,d,h,mi,s;
			getdate(y,m,d);
			gettime(h,mi,s);
			worstscoreat[turf] = 0;
			worstmemberat[turf] = 999;
			bestscoreat[turf] = 0;
			bestmemberat[turf] = 999;
			worstscoredf[turf] = 0;
			worstmemberdf[turf] = 999;
			bestscoredf[turf] = 0;
			bestmemberdf[turf] = 999;
			InWar[TurfInfo[turf][zOwned]] = 1;
			InWar[faction] = 1;
			waitwar[faction] = 60;
		}
		else return SCM(playerid,COLOR_WHITE,"War can be attack in 20:00 and 22:00.");
	}
	return 1;
}
any help!
Reply
#2

any help?
Reply
#3

Hello!

I think you used false operators.

Try this:
PHP код:
if(hour 20 || hour 22) return SCM(playerid,COLOR_WHITE,"{FFFFFF}You can't start a war now , war can start in 19:00 at 22:00"); 
to
PHP код:
if(hour 20 || hour 22) return SCM(playerid,COLOR_WHITE,"{FFFFFF}You can't start a war now , war can start in 20:00 at 22:00"); 
Reply
#4

You mean between 20 and 22? or only 20 exact and 22 exact?
If between use the code up
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)