Gangwar attack problem
#1

Hello, I am currently developing a TDM gamemode with Turf system.

I've tried to make the attack command for the GM but it has some very nasty bugs:
- When I try to attack it doesn't checks on what turf i am on so on every turf i go when i am in Groove team it says it's already captured (That's turf 1..), although i'm on other turfs.
- If I change the team and attack on a random turf, it somehow attacks every turf (makes them flash) and captures the last one 24 times. (If I have 24 turfs it captures the 24th turf or 23th and so on)
^The turf captured stops flashing but the others still keep on flashing.

Here's the attack command:
Код:
CMD:attack(playerid, params[])
{
	for(new i = 0; i < MAX_ZONES; i++)
	if (IsPlayerInArea(playerid, ZoneInfo[i][zMinX], ZoneInfo[i][zMaxX], ZoneInfo[i][zMinY], ZoneInfo[i][zMaxY]))
	{
		new string[128];
		{
			if(ZoneInfo[i][zTeam] == gTeam[playerid]) return SendClientMessage(playerid, COLOR_RED,"ERROR:{FFFFFF} Your team is the current holder of this zone.");
			if(UnderAttack[i] == 1) return SendClientMessage(playerid, COLOR_RED,"ERROR:{FFFFFF} Somebody is already attacking this zone.");
			if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED,"ERROR:{FFFFFF} You can't capture zones while being in a vehicle.");
			UnderAttack[i] = 1;
			timer[playerid] = SetTimerEx("SetZone", 30000, false, "i", playerid);
			GangZoneFlashForAll(Zone[i],COLOR_ATTACK);
			format(string, sizeof(string), "INFO:{FFFFFF} You're currently attacking the %s, stay in it the marker for 30 seconds to take it over.", ZoneInfo[i][zName]);
			SendClientMessage(playerid, COLOR_GREY, string);
			format(string, sizeof(string), "GANGZONE:{FFFFFF} %s is under attack!", ZoneInfo[i][zName]);
			SendClientMessageToAll(orange, string);
			tCheck[playerid] = i;
		}
	}
	else
	{
	new string[128];
	format(string, sizeof(string), "GANGZONE:{FFFFFF} Nu esti pe vreun turf!");
	SendClientMessageToAll(COLOR_RED, string);
	}
	return 1;
}
Reply
#2

Quote:

for(new i = 0; i < MAX_ZONES; i++)

Foreach it's a better loppy for your flash.
Reply
#3

Quote:
Originally Posted by KillerDVX
Посмотреть сообщение


Foreach it's a better loppy for your flash.
It might be but i don't want to use YSI, will that fix the bugs i listed above?
Reply
#4

BUMP ..
Reply
#5

i didnt check the code yet but :
IsPlayerInArea's parameters are:
pawn Код:
IsPlayerInArea(playerid, Float:MinX, Float:MinY, Float:MaxX, Float:MaxY)
Reply
#6

Here is the majority of the codes, one thing I noticed:
If I remove tCheck from that code the bugs are resolved but now at every team it captures turf 1.

Код:
forward SetZone(playerid);
public SetZone(playerid)
{
   new string[128];
   SetPlayerScore(playerid, GetPlayerScore(playerid) + ZoneInfo[tCheck[playerid]][zEXP]);
   PlayerInfo[playerid][pScore] += ZoneInfo[tCheck[playerid]][zEXP];
   GivePlayerMoney(playerid, ZoneInfo[tCheck[playerid]][zMoney]);
    PlayerInfo[playerid][pMoney] += ZoneInfo[tCheck[playerid]][zMoney];
   PlayerInfo[playerid][pTurfs]++;
   format(string, sizeof(string), "INFO:{FFFFFF} Gangzone captured, +%d EXP points and %d$.", ZoneInfo[tCheck[playerid]][zEXP], ZoneInfo[tCheck[playerid]][zMoney]);
   SendClientMessage(playerid, COLOR_GREY, string);
   UnderAttack[tCheck[playerid]] = 0;
   KillTimer(timer[playerid]);
   SetGangZone(playerid);
   return 1;
}



forward SetGangZone(playerid);
public SetGangZone(playerid)
{
   new string[128];
   GangZoneShowForAll(Zone[tCheck[playerid]],GetTeamZoneColor(playerid));
   format(string, sizeof string, "GANGZONE:{FFFFFF} %s has captured the %s for %s.", GetName(playerid), ZoneInfo[tCheck[playerid]][zName], GetTeamName(playerid));
    SendClientMessageToAll(orange, string);
   GangZoneStopFlashForAll(Zone[tCheck[playerid]]);
   ZoneInfo[tCheck[playerid]][zTeam] = gTeam[playerid];
   SaveZone(tCheck[playerid]);
   return 1;
}
Код:
new tCheck[MAX_PLAYERS];
Код:
stock IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
   new Float:Pos[3];
   GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
   if(Pos[0] > minx && Pos[0] < maxx && Pos[1] > miny && Pos[1] < maxy) return 1;
   else return 0;
}
Reply
#7

BUMPy

Sorry, but i really want to fix this problem..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)