public IsPlayerInTurf(playerid, turfid)
{
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;
}
enum zInfo
{
zID,
zOwned,
zTime,
Float:zMinX,
Float:zMinY,
Float:zMaxX,
Float:zMaxY,
};
new TurfInfo[42][zInfo];
new Turfs[42];
public LoadTurfs()
{
new Cache: result1 = mysql_query (handle, "SELECT * FROM `turfs` ORDER BY `turfs`.`ID` ASC");
new index;
for ( new i, j = cache_get_row_count ( ); i != j; ++i )
{
index++;
cache_get_field_content(i,"ID", result); TurfInfo[index][zID] = strval(result);
cache_get_field_content(i,"Owned", result); TurfInfo[index][zOwned] = strval(result);
cache_get_field_content(i,"Time", result); TurfInfo[index][zTime] = strval(result);
cache_get_field_content(i,"MinX", result); TurfInfo[index][zMinX] = floatstr(result);
cache_get_field_content(i,"MinY", result); TurfInfo[index][zMinY] = floatstr(result);
cache_get_field_content(i,"MaxX", result); TurfInfo[index][zMaxX] = floatstr(result);
cache_get_field_content(i,"MaxY", result); TurfInfo[index][zMaxY] = floatstr(result);
}
cache_delete ( result1 );
printf("[script] %d turfs loaded.", index);
return 1;
}
CMD:attack(playerid, params[])
{
new rhour, rminute, rsecond;
gettime(rhour, rminute, rsecond);
if(PlayerData[playerid][pAtaca] == 0)
{
PlayerData[playerid][pAtaca] = 30;
if(PlayerData[playerid][pGroup] == 7 || PlayerData[playerid][pGroup] == 10 || PlayerData[playerid][pGroup] == 2 || PlayerData[playerid][pGroup] == 15)
{
new samp[256];
new deelay = groupVariables[PlayerData[playerid][pGroup]][gDeelay];
format(samp, sizeof(samp), "Wait %s minutes.", CalculeazaTimp(deelay));
if(PlayerData[playerid][pGroupRank] >= 5)
{
new hour,minute,second;
gettime(hour,minute,second);
new sendername[MAX_PLAYER_NAME];
new string[144];
for(new i = 0; i < sizeof(TurfInfo); i++)
{
if(IsPlayerInTurf(playerid, i))
{
turf = i;
break;
}
}
new count = 0;
foreach(Player, total)
{
if(PlayerData[total][pGroup] == TurfInfo[turf][zOwned])
{
count++;
}
}
new countr = 0;
foreach(Player, total)
{
if(PlayerData[total][pGroup] == PlayerData[total][pGroup])
{
countr++;
}
}
if(WarInfo[turf][wAttacker] != 0) return SCM(playerid, COLOR_WHITE, "This turf is already attacked!");
if(turf == 0) return SCM(playerid, COLOR_WHITE, "You aren't in a turf!");
if(TurfInfo[turf][zOwned] == PlayerData[playerid][pGroup]) return SCM(playerid, COLOR_WHITE, "You can't attack your turf");
if(groupVariables[TurfInfo[turf][zOwned]][gInWar] == 1) return SCM(playerid, COLOR_WHITE, "This faction is already in a war!");
if(groupVariables[PlayerData[playerid][pGroup]][gInWar] == 1) return SCM(playerid, COLOR_WHITE, "Your faction is already in a war!");
GetPlayerName(playerid, sendername, sizeof(sendername));
WarInfo[turf][wAttacker] = PlayerData[playerid][pGroup];
WarInfo[turf][wFaction] = TurfInfo[turf][zOwned];
WarInfo[turf][wTime] = 900;
format(string, sizeof(string),"%s from your group attacked turf %d (%s).",sendername, turf, groupVariables[TurfInfo[turf][zOwned]][gGroupName]);
SendToGroup(PlayerData[playerid][pGroup], COLOR_LIGHTGREEN, string);
format(string, sizeof(string),"%s from %s attacked turf %i owned by you.",sendername, groupVariables[PlayerData[playerid][pGroup]][gGroupName],turf);
SendToGroup(TurfInfo[turf][zOwned], COLOR_LIGHTGREEN, string);
groupVariables[WarInfo[turf][wFaction]][gScore] = 0;
groupVariables[WarInfo[turf][wAttacker]][gScore] = 1;
groupVariables[WarInfo[turf][wFaction]][gInWar] = 1;
groupVariables[WarInfo[turf][wAttacker]][gInWar] = 1;
TurfInfo[turf][zTime] = 0;
format(result, sizeof(result), "UPDATE turfs SET Time = '%d' WHERE ID = %d", TurfInfo[turf][zTime], turf);
mysql_tquery(handle, result);
foreach(Player, i)
{
if(PlayerData[i][pGroup] == WarInfo[turf][wAttacker] || PlayerData[i][pGroup] == WarInfo[turf][wFaction])
{
new time = WarInfo[turf][wTime];
format(string, sizeof(string), "War time: ~r~%s", CalculeazaTimp(time));
TextDrawSetString(Paintball, string);
TextDrawShowForPlayer(i, Paintball);
PlayerData[i][pWarScore] = 0;
PlayerData[i][pWarDeaths] = 0;
GangZoneFlashForPlayer(i, Turfs[turf], COLOR_RED);
}
}
}
else return SCM(playerid, COLOR_REDFT,"Low rank!");
}
else return SCM(playerid, COLOR_REDFT,"You are not a mafia member!");
}
else SCM(playerid, COLOR_WHITE,"Wait 30 seconds...");
return 1;
}
4:43:14] [debug] Run time error 4: "Array index out of bounds" [14:43:14] [debug] Accessing element at index 42 past array upper bound 41 [14:43:14] [debug] AMX backtrace: [14:43:14] [debug] #0 001136b4 in public IsPlayerInTurf (playerid=11, turfid=42) at D:\server\gmi.pwn:19698 [14:43:14] [debug] #1 0016d5b4 in public AB_OnPlayerDeath (playerid=11, killerid=13, reason=24) at D:\server\gmi.pwn:26106 [14:43:14] [debug] #2 0001fbf0 in public OnPlayerDeath (playerid=11, killerid=13, reason=24) at D:\proiecte\server\gmi.pwn
|
[14:43:14] [debug] #0 001136b4 in public IsPlayerInTurf (playerid=11, turfid=42) at D:\server\gmi.pwn:19698 |