29.04.2010, 11:02
Hi I have a big bug in my gamemode.
Locationscript randomly stops updating for a few minutes, then it works again, then it stops. pls take a look into it. Thx
Locationscript randomly stops updating for a few minutes, then it works again, then it stops. pls take a look into it. Thx
Код:
#include <zones>
new player_zone[MAXPLAYERS];
forward update_zones();
public OnGameModeInit()
{
SetTimer("update_zones",2000,true);
}
public update_zones()
{
for(new i=0; i<MAXPLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInZone(i,player_zone[i]))
{
}
else
{
new player_zone_before;
player_zone_before = player_zone[i];
player_zone[i] = -1;
for(new j=0; j<sizeof(zones);j++)
{
if(IsPlayerInZone(i,j) && player_zone[i] == -1)
{
player_zone[i] = j;
}
}
if(player_zone[i] == -1) player_zone[i] = player_zone_before;
}
}
}
}
IsPlayerInZone(playerid, zoneid)
{
if(zoneid == -1) return 0;
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid,x,y,z);
if(x >= zones[zoneid][zone_minx] && x < zones[zoneid][zone_maxx]
&& y >= zones[zoneid][zone_miny] && y < zones[zoneid][zone_maxy]
&& z >= zones[zoneid][zone_minz] && z < zones[zoneid][zone_maxz]
&& z < 900.0) return 1;
return 0;
}

