Код:
CMD:attack(playerid, params[])
{
if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "Trebuie sa te loghezi mai intai.");
if(!IsAMember(playerid)) return SCM(playerid,COLOR_YELLOW2, "Eroare: You are not a member of the Mafia.");
if(PlayerInfo[playerid][pRank] < 3) return SCM(playerid,TEAM_AZTECAS_COLOR,"Eroare: You do not have rank 3.");
new turf,faction,string[100],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));
new hour,minute,second, year, month, day;
gettime(hour,minute,second);
getdate(year, month, day);
//if(hour == 19 || hour == 23) {}
//else return SCM(playerid, COLOR_WARNING, "War-uri se pot da doar in intervalul de timp 19:00 - 22:00!");
if(turf == 0) return SCM(playerid, COLOR_YELLOW2, "Eroare: You are not on a territory.");
faction = PlayerInfo[playerid][pMember];
if(TurfInfo[turf][zOwned] == faction) return SCM(playerid, COLOR_YELLOW2, "Eroare: You can't attack your own turf.");
if(WarInfo[turf][wAttacker] != 0) return SCM(playerid, COLOR_YELLOW2, "Eroare: Turf is already attacked.");
if(InWar[faction] == 1) return SCM(playerid, COLOR_YELLOW2, "Eroare: You have an active war.");
if(InWar[TurfInfo[turf][zOwned]] == 1) return SCM(playerid, COLOR_YELLOW2, "Eroare: This mafia have active war.");
TurfInfo[turf][zTime] = 24;
new str[128];
format(str,128,"UPDATE `turfs` SET `Time`='24' WHERE `ID`='%d'",turf);
mysql_query(SQL,str);
WarInfo[turf][wTime] = 900;
WarInfo[turf][wAttacker] = faction;
WarInfo[turf][wFaction] = TurfInfo[turf][zOwned];
format(string,sizeof(string),"Your mafia (%s) attacked turf %d owned by %s",sendername,turf,NumeFactiune(TurfInfo[turf][zOwned]));
SendFamilyMessage(faction,TEAM_AZTECAS_COLOR,string);
format(string,sizeof(string),"Turf %d, Time remaining: %s",turf,CalculeazaTimp(WarInfo[turf][wTime]));
SendFamilyMessage(faction,TEAM_AZTECAS_COLOR,string);
format(string,sizeof(string),"%s (%s) attacked your turf %d",NumeFactiune(WarInfo[turf][wAttacker]),sendername,turf);
SendFamilyMessage(TurfInfo[turf][zOwned],TEAM_AZTECAS_COLOR,string);
format(string,sizeof(string),"Turf %d, Time remaining: %s",turf,CalculeazaTimp(WarInfo[turf][wTime]));
SendFamilyMessage(TurfInfo[turf][zOwned],TEAM_AZTECAS_COLOR,string);
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;
return 1;
}
Код:
public IsPlayerInTurf(playerid, turfid)
{
if(IsPlayerConnected(playerid))
{
if(turfid == -1)
{
return 0;
}
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid,x,y,z);
if(x >= TurfInfo[turfid][zMinX] && x < TurfInfo[turfid][zMaxX] && y >= TurfInfo[turfid][zMinY] && y < TurfInfo[turfid][zMaxY])
{
return 1;
}
}
return 0;
}