timer ZombieRespawnTimer[5000]()
{
new bool:true_found, id, Float:x,Float:y,Float:z, count_zombies, NPCSS[MAX_PLAYERS];
count_zombies=0;
for(new i=0; i<MAX_PLAYERS; i++)
{
GetPlayerPos(i,x,y,z);
for(new k=0; k<MAX_PLAYERS; k++)
{
if(IsPlayerNPC(k))
{
if(IsPlayerInRangeOfPoint(k, 50, x, y, z))
{
true_found=true;
id = k;
}
}
}
if(true_found)
{
count_zombies++;
NPCSS[count_zombies] = id;
}
}
if(count_zombies > 20)
{
printf("Found %d more zombies in a area, respawning...",count_zombies-20);
for(new i=0; i<count_zombies-20; i++)
{
FCNPC_Respawn(NPCSS[i]);
}
}
}
timer ZombieRespawnTimer[5000]()
{
new Float:x,Float:y,Float:z, count_zombies, NPCSS[MAX_PLAYERS][MAX_PLAYERS], NPCSSID[MAX_PLAYERS][MAX_PLAYERS];
count_zombies=0;
for(new i=0; i<MAX_PLAYERS; i++)
{
GetPlayerPos(i,x,y,z);
for(new k=0; k<MAX_PLAYERS; k++)
{
if(IsPlayerNPC(k))
{
if(IsPlayerInRangeOfPoint(k, 50, x, y, z))
{
NPCSS[i][k] ++;
NPCSSID[i][k] = k;
}
}
}
}
for(new i=0; i<MAX_PLAYERS; i++)
{
for(new k=0; k<MAX_PLAYERS; k++)
{
if(NPCSS[i][k] > 20)
{
printf("Found %d more zombies in a area, respawning...",NPCSS[i][k]-20);
FCNPC_Respawn(NPCSSID[i][k]);
}
}
}
}
foreach (new i : FCNPC)
new StreamedNPC[MAX_PLAYERS];
public OnPlayerStreamIn(playerid, forplayerid){
if(IsPlayerNPC(playerid) && IsPlayerNPC(forplayerid)){ //npc for npc
StreamedNPC[forplayerid]++;
if(StreamedNPC[forplayerid] >= 20){ //reached max npc in 300.0 range
}
}
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid){
if(IsPlayerNPC(playerid) && IsPlayerNPC(forplayerid)){ //npc for npc
StreamedNPC[forplayerid]--;
}
return 1;
}
without timers/loops but for 300.0 range
PHP код:
|