17.01.2012, 22:21
I'm trying to make a custom function for determining if a player entered a gang zone (or in this case, bot zone). This is my code:
These are the errors:
I'm sure it has something to do with BotZones being a float and the loop doesn't want to process it because of that- but why not? And what's the other option for doing this?
Oh and I know I only have a single value in BotZones, but I'll be adding a few more later.
EDIT: This was my mistake. I solved it by replacing "BotZones" in the loop with "sizeof(BotZones)" because I'm an idiot!
pawn Код:
new Float:BotZones[][] =
{
{-1654.446289,-161.187805,-1334.446289,-561.187805}
};
stock IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if (x > minx && x < maxx && y > miny && y < maxy) return 1;
else return 0;
}
timer OnPlayerEnterBotZone[10000](playerid)
{
for(new z = 0; z < BotZones; z++) // line 394
{
if(IsPlayerInArea(playerid, BotZones[z][0], BotZones[z][1], BotZones[z][2], BotZones[z][3]))
{
if(!GetPVarType(playerid, "InBotZone"))
{
SetPVarInt(playerid, "InBotZone", 1);
// TextDrawSetString(SFAirportWarnTD[playerid], "~w~Please note that there are ~r~bots ~w~driving around this area.~n~~n~Leave the ~r~bots ~w~alone, or you will be ~r~admin-jailed~w~!");
}
}
}
}
timer OnPlayerExitBotZone[10000](playerid)
{
for(new z = 0; z < BotZones; z++) // line 409
{
if(!IsPlayerInArea(playerid, BotZones[z][0], BotZones[z][1], BotZones[z][2], BotZones[z][3]))
{
if(GetPVarType(playerid, "InBotZone"))
{
DeletePVar(playerid, "InBotZone");
//TextDrawShowForPlayer(playerid, SFAirportWarnTD[playerid]);
}
}
}
}
Код:
(394) : error 033: array must be indexed (variable "BotZones") (409) : error 033: array must be indexed (variable "BotZones")
Oh and I know I only have a single value in BotZones, but I'll be adding a few more later.
EDIT: This was my mistake. I solved it by replacing "BotZones" in the loop with "sizeof(BotZones)" because I'm an idiot!