02.09.2015, 23:49
I did a system of war and when the war was over we put send you some messages. The problem is that they sent several times, and do not understand why you may know.
pawn Код:
function WarTimer()
{
new string[100], string2[150];
for(new i = 1; i < sizeof(Turfs); i++)
{
new attackers = WarInfo[i][wAttacker];
new defenders = WarInfo[i][wFaction];
if(WarInfo[i][wTime] >= 2)
{
foreach(Player,j)
{
if(WarInfo[i][wAttacker] == 5)
{
GangZoneFlashForPlayer(j,Turfs[i], 0x00D9FAAA);
}
else if(WarInfo[i][wAttacker] == 6)
{
GangZoneFlashForPlayer(j,Turfs[i], 0x666666AA);
}
else if(WarInfo[i][wAttacker] == 7)
{
GangZoneFlashForPlayer(j,Turfs[i], 0x1EB500AA);
}
else if(WarInfo[i][wAttacker] == 8)
{
GangZoneFlashForPlayer(j,Turfs[i], 0xCC00B4AA);
}
}
}
if(WarInfo[i][wTime] > 0)
{
WarInfo[i][wTime] -= 1;
foreach(Player,j)
{
if(IsPlayerInTurf(j,i) == 1 || IsPlayerInTurf(j, i) == 0)
{
if(PlayerInfo[j][pMember] == attackers)
{
WarScoreF[attackers][i] += 0.002;
if(Wartimeon[j] == 1)
{
format(string,sizeof(string),"~y~TURF TIMER: ~w~%s",CalculeazaTimp2(WarInfo[i][wTime]));
PlayerTextDrawSetString(j, TurfTimer[j], string);
PlayerTextDrawShow(j, TurfTimer[j]);
format(string, sizeof(string), "~y~Deaths: ~w~%d", decese[j][i]);
PlayerTextDrawSetString(j, DeathsWar[j], string);
PlayerTextDrawShow(j, DeathsWar[j]);
format(string, sizeof(string), "~y~Kills: ~w~%d", ucideri[j][i]);
PlayerTextDrawSetString(j, KillsWar[j], string);
PlayerTextDrawShow(j, KillsWar[j]);
format(string, sizeof(string), "~y~Turf ID: ~w~%d", i);
PlayerTextDrawSetString(j, TurfWar[j], string);
PlayerTextDrawShow(j, TurfWar[j]);
}
}
if(PlayerInfo[j][pMember] == defenders)
{
WarScoreF[defenders][i] += 0.002;
if(Wartimeon[j] == 1)
{
format(string,sizeof(string),"~y~TURF TIMER: ~w~%s",CalculeazaTimp2(WarInfo[i][wTime]));
PlayerTextDrawSetString(j, TurfTimer[j], string);
PlayerTextDrawShow(j, TurfTimer[j]);
format(string, sizeof(string), "~y~Deaths: ~w~%d", decese[j][i]);
PlayerTextDrawSetString(j, DeathsWar[j], string);
PlayerTextDrawShow(j, DeathsWar[j]);
format(string, sizeof(string), "~y~Kills: ~w~%d", ucideri[j][i]);
PlayerTextDrawSetString(j, KillsWar[j], string);
PlayerTextDrawShow(j, KillsWar[j]);
format(string, sizeof(string), "~y~Turf ID: ~w~%d", i);
PlayerTextDrawSetString(j, TurfWar[j], string);
PlayerTextDrawShow(j, TurfWar[j]);
}
}
}
else if(Wartimeon[j] == 1)
{
PlayerTextDrawHide(j, TurfTimer[j]);
PlayerTextDrawHide(j, DeathsWar[j]);
PlayerTextDrawHide(j, KillsWar[j]);
PlayerTextDrawHide(j, TurfWar[j]);
}
}
if(WarInfo[i][wTime] == 1)
{
new Float: atscore = 0.0;
new Float: defscore = 0.0;
atscore = WarScoreF[attackers][i];
defscore = WarScoreF[defenders][i];
new winner;
if(atscore > defscore)
{
winner = 1;
}
else
{
winner = 2;
}
new winbest;
new winbestj = -1, losebestj = -1;
new bestname1[25],bestname2[25],bestname[25],worstname[25];
foreach(Player,j)
{
if(winner == 1)
{
if(PlayerInfo[j][pMember] == attackers)
{
winbest = bestscoreat[i];
if(bestmemberat[i] != 999)
{
if(PlayerInfo[bestmemberat[i]][pMember] == attackers)
{
winbestj = bestmemberat[i];
GetPlayerName(winbestj,bestname1,sizeof(bestname1));
strmid(bestname, bestname1, 0, strlen(bestname1), 255);
}
}
else
{
format(bestname,sizeof(bestname),"-");
strmid(bestname, bestname, 0, strlen(bestname), 255);
}
}
if(PlayerInfo[j][pMember] == defenders)
{
//losebest = worstscoredf[i];
if(worstmemberdf[i] != 999)
{
if(PlayerInfo[worstmemberdf[i]][pMember] == defenders)
{
losebestj = worstmemberdf[i];
GetPlayerName(losebestj,bestname2,sizeof(bestname2));
strmid(worstname, bestname2, 0, strlen(bestname2), 255);
}
}
else
{
format(worstname,sizeof(worstname),"-");
strmid(worstname, worstname, 0, strlen(worstname), 255);
}
}
}
if(winner == 2)
{
if(PlayerInfo[j][pMember] == defenders)
{
winbest = bestscoredf[i];
if(bestmemberdf[i] != 999)
{
if(PlayerInfo[bestmemberdf[i]][pMember] == defenders)
{
winbestj = bestmemberdf[i];
GetPlayerName(winbestj,bestname1,sizeof(bestname1));
strmid(bestname, bestname1, 0, strlen(bestname1), 255);
}
}
else
{
format(bestname,sizeof(bestname),"-");
strmid(bestname, bestname, 0, strlen(bestname), 255);
}
}
if(PlayerInfo[j][pMember] == attackers)
{
if(worstmemberat[i] != 999)
{
if(PlayerInfo[worstmemberat[i]][pMember] == attackers)
{
losebestj = worstmemberat[i];
GetPlayerName(losebestj,bestname2,sizeof(bestname2));
strmid(worstname, bestname2, 0, strlen(bestname2), 255);
}
}
else
{
format(worstname,sizeof(worstname),"-");
strmid(worstname, worstname, 0, strlen(worstname), 255);
}
}
}
}
foreach(Player,j)
{
if((PlayerInfo[j][pMember] == attackers) || (PlayerInfo[j][pMember] == defenders))
{
if(winner == 1)
{
TurfInfo[i][zOwned] = WarInfo[i][wAttacker];
Wartimeon[j] = 0;
PlayerTextDrawHide(j, TurfTimer[j]);
PlayerTextDrawHide(j, DeathsWar[j]);
PlayerTextDrawHide(j, KillsWar[j]);
PlayerTextDrawHide(j, TurfWar[j]);
format(string2,sizeof(string2),"{008BC7}Razboi: {ffffff}%s a castigat zona %d. Scor final: %s %.1f - %.1f %s",NumeFactiune(WarInfo[i][wAttacker]), i, NumeFactiune(WarInfo[i][wAttacker]), atscore, defscore, NumeFactiune(WarInfo[i][wFaction]));
OOCNews(-1, string2);
format(string2,sizeof(string2),"{008BC7}Razboi: {ffffff}Cel mai bun gangster: %s ( %d Ucideri ) || Cel mai slab gangster: %s ( %d Decese )", bestname, winbest, worstname, worstscoreat[i]);
OOCNews(-1, string2);
format(string2,sizeof(string2),"{008BC7}Scorul tau: {ffffff}%d ( %d ucideri, %d decese )",ucideri[j][i] - decese[j][i], ucideri[j][i], decese[j][i]);
SendClientMessage(j, -1,string2);
}
if(winner == 2)
{
Wartimeon[j] = 0;
PlayerTextDrawHide(j, TurfTimer[j]);
PlayerTextDrawHide(j, DeathsWar[j]);
PlayerTextDrawHide(j, KillsWar[j]);
PlayerTextDrawHide(j, TurfWar[j]);
format(string2,sizeof(string2),"{008BC7}Razboi: {ffffff}%s a castigat zona %d. Scor final: %s %.1f - %.1f %s",NumeFactiune(WarInfo[i][wFaction]), i, NumeFactiune(WarInfo[i][wFaction]), defscore, atscore, NumeFactiune(WarInfo[i][wAttacker]));
OOCNews(-1, string2);
format(string2,sizeof(string2),"{008BC7}Razboi: {ffffff}Cel mai bun gangster: %s ( %d Ucideri ) || Cel mai slab gangster: %s ( %d Decese )", bestname, winbest, worstname, worstscoreat[i]);
OOCNews(-1, string2);
format(string2,sizeof(string2),"{008BC7}Scorul tau: {ffffff}%d ( %d ucideri, %d decese )",ucideri[j][i] - decese[j][i], ucideri[j][i], decese[j][i]);
SendClientMessage(j, -1,string2);
}
WarScoreF[defenders][i] = 0.0;
WarScoreF[attackers][i] = 0.0;
InWar[attackers] = 0;
InWar[defenders] = 0;
}
if(winner == 1)
{
GangZoneHideForPlayer(j,Turfs[i]);
if(attackers == 5)
{
GangZoneShowForPlayer(j, Turfs[i], 0x00D9FAAA, 0x000000BB); // Aztecas
}
if(attackers == 6)
{
GangZoneShowForPlayer(j, Turfs[i], 0x666666AA, 0x000000BB); // Corleone
}
if(attackers == 7)
{
GangZoneShowForPlayer(j, Turfs[i], 0x1EB500AA, 0x000000BB); // Grove
}
if(attackers == 8)
{
GangZoneShowForPlayer(j, Turfs[i], 0xCC00B4AA, 0x000000BB); // Patterno
}
}
}
if(winner == 1)
{
new str[128];
format(str,128,"UPDATE `turfs` SET `Owned`='%d' WHERE `ID`='%d'",TurfInfo[i][zOwned],i);
mysql_query(handle, str);
}
WarInfo[i][wTime] = 0;
WarInfo[i][wFaction] = 0;
WarInfo[i][wAttacker] = 0;
worstscoreat[i] = 0;
worstmemberat[i] = 999;
bestscoreat[i] = 0;
bestmemberat[i] = 999;
worstscoredf[i] = 0;
worstmemberdf[i] = 999;
bestscoredf[i] = 0;
bestmemberdf[i] = 999;
}
}
}
return 1;
}