os npcs não estão sendo exibidos dentro do jogo.
o que acontece, o código é compilado certinho e nos los fala que Todos os zumbis foram gerados com sucesso, mais quando entro dentro do jogo eu não vejo um npc no servidor, o código de criação está a baixo. (ah e eu estou usando a verção mais atualizada da include e do plugin).
new Float:ZombieSpawns[][] =
{
{1089.5581,1771.1646,19.3677},
{2672.498535,-1943.021728,12.539999},
{2203.854003,868.086914,6.329998},
{-1320.320190,-559.027343,13.140000},
{1570.297851,1266.574707,9.810000},
};
hook OnGameModeInit()
{
CA_Init();
MapAndreas_Init(MAP_ANDREAS_MODE_FULL);
new str[50];
for(new i = 0; i < sizeof(ZombieSpawns); i++)
{
format(str, sizeof(str), "Zumbi[%d]", i);
new npcid = FCNPC_Create(str);
ZombieLabel[npcid] = Create3DTextLabel("{B22222}Vida: 100", -1, 30.0, 40.0, 50.0, 50.0, -1, 0);
Attach3DTextLabelToPlayer(ZombieLabel[npcid], npcid, 0.0, 0.0, 0.4);
FCNPC_Spawn(npcid, 162, ZombieSpawns[i][0], ZombieSpawns[i][1], ZombieSpawns[i][2] + 1.0);
FCNPC_SetWeapon(npcid, 1);
FCNPC_SetHealth(npcid, 100);
FCNPC_SetInvulnerable(npcid, false);
SetZombieAttachedObjects(npcid);
ZombieTimer[npcid] = repeat ZombieMove(npcid);
SetPlayerColor(npcid, 0xFF0000FF);
IsAZombie[npcid] = 1;
}
printf("Todos os zumbis foram gerados com sucesso.");
return 1;
}
hook FCNPC_OnCreate(npcid)
{
new rnd = random(sizeof(ZombieSpawns));
ZombieLabel[npcid] = Create3DTextLabel("{B22222}[Zumbi]\n{FFFFFF}Vida: 100", -1, 30.0, 40.0, 50.0, 60.0, -1, 0);
Attach3DTextLabelToPlayer(ZombieLabel[npcid], npcid, 0.0, 0.0, 0.4);
FCNPC_Spawn(npcid,162, ZombieSpawns[rnd][0],ZombieSpawns[rnd][1],ZombieSpawns[rnd][2]+1.0);
FCNPC_SetWeapon(npcid, 1);
FCNPC_SetHealth(npcid, 100);
FCNPC_SetInvulnerable(npcid, false);
SetZombieAttachedObjects(npcid);
ZombieTimer[npcid] = repeat ZombieMove(npcid);
SetPlayerColor(npcid,0xFF0000FF);
IsAZombie[npcid] = 1;
return 1;
}
What's in server_log.txt?
Also check maxnpc value in server.cfg.
O que há em
server_log.txt? Verifique tambémmaxnpco valor emserver.cfg.
bem no server.cfg, o maxnpc está assm olha, maxnpc 800, mais que o suficiente, o no server_log.txt tem isso [npc:join] Zumbi[685] has joined the server (314:127.0.0.1) [npc:join] Zumbi[686] has joined the server (313:127.0.0.1) Todos os zumbis foram gerados com sucesso.
Try to check without ZombieTimer[npcid] = repeat ZombieMove(npcid);
tirei mais mesmo assim não funcona cara, o código não está errado né, então eu não consigo entender o que pode ter acontecido
eu testei mais deu na mesma, o código está errado? eu creio que não. mas possa ser que está alguma coisa errado mais eu não consigo ver. esse é o código completo.
#include <YSI-Includes\YSI_Coding\y_hooks>
#include "../modules/systems/zombies/zombies_data.inc"
PlayAnim(playerid, animlib[], animname[], Float:fDelta, loop, lockx, locky, freeze, time, forcesync)
{
ApplyAnimation(playerid, animlib, animname, fDelta, loop, lockx, locky, freeze, time, forcesync);
}
#define MAX_ZOMBIES 800
new Float:PosBot[3][MAX_ZOMBIES];
new IsAZombie[MAX_PLAYERS], Text3D:ZombieLabel[MAX_PLAYERS], Timer:ZombieTimer[MAX_PLAYERS], ZombieIsAttack[MAX_PLAYERS];
hook OnGameModeInit()
{
CA_Init();
MapAndreas_Init(MAP_ANDREAS_MODE_FULL);
new str[50];
for(new i = 0; i < sizeof(ZombieSpawns); i++)
{
format(str, sizeof(str), "Zumbi[%d]", i);
new npcid = FCNPC_Create(str);
ZombieLabel[npcid] = Create3DTextLabel("{B22222}Vida: 100", -1, 30.0, 40.0, 50.0, 50.0, -1, 0);
Attach3DTextLabelToPlayer(ZombieLabel[npcid], npcid, 0.0, 0.0, 0.4);
FCNPC_Spawn(npcid, 162, ZombieSpawns[i][0], ZombieSpawns[i][1], ZombieSpawns[i][2] + 1.0);
FCNPC_SetWeapon(npcid, 1);
FCNPC_SetHealth(npcid, 100);
FCNPC_SetInvulnerable(npcid, false);
SetZombieAttachedObjects(npcid);
//ZombieTimer[npcid] = repeat ZombieMove(npcid);
SetPlayerColor(npcid, 0xFF0000FF);
IsAZombie[npcid] = 1;
}
printf("Todos os zumbis foram gerados com sucesso.");
return 1;
}
hook FCNPC_OnCreate(npcid)
{
new rnd = random(sizeof(ZombieSpawns));
ZombieLabel[npcid] = Create3DTextLabel("{B22222}[Zumbi]\n{FFFFFF}Vida: 100", -1, 30.0, 40.0, 50.0, 60.0, -1, 0);
Attach3DTextLabelToPlayer(ZombieLabel[npcid], npcid, 0.0, 0.0, 0.4);
FCNPC_Spawn(npcid,162, ZombieSpawns[rnd][0],ZombieSpawns[rnd][1],ZombieSpawns[rnd][2]+1.0);
FCNPC_SetWeapon(npcid, 1);
FCNPC_SetHealth(npcid, 100);
FCNPC_SetInvulnerable(npcid, false);
SetZombieAttachedObjects(npcid);
//ZombieTimer[npcid] = repeat ZombieMove(npcid);
SetPlayerColor(npcid,0xFF0000FF);
IsAZombie[npcid] = 1;
return 1;
}
hook FCNPC_OnDeath(npcid, killerid, weaponid)
{
ZombieIsAttack[npcid] = 0;
PlayAnim(npcid, "PED", "BIKE_fall_off", 4.1, 0, 1, 1, 1, 0, 1);
CallLocalFunction("OnPlayerKillZombie","ii",killerid,npcid);
new Float:xa, Float:ya, Float:za;
FCNPC_GetPosition(npcid, xa, ya, za);
CreateItem(0, random(sizeof(ItemStats)), 1, xa, ya, za);
return 1;
}
hook FCNPC_OnTakeDamage(npcid, damagerid, weaponid, bodypart, Float:health_loss)
{
new str[80];
format(str, sizeof str, "{B22222}Vida: %.2f",FCNPC_GetHealth(npcid));
Update3DTextLabelText(ZombieLabel[npcid], -1, str);
return 1;
}
FCNPC_OnUpdate(npcid)
{
FCNPC_GetPosition(npcid, PosBot[0][npcid], PosBot[1][npcid], PosBot[2][npcid]);
MapAndreas_FindZ_For2DCoord(PosBot[0][npcid], PosBot[1][npcid], PosBot[2][npcid]);
FCNPC_SetPosition(npcid, PosBot[0][npcid], PosBot[1][npcid], PosBot[2][npcid]+1.0);
return 1;
}
timer ZombieMove[500](zombieid)
{
new Float:xa,Float:ya,Float:za;
if(FCNPC_IsDead(zombieid)) return 1;
foreach(new playerid : Player)
{
GetPlayerPos(playerid,xa,ya,za);
if(IsPlayerInRangeOfPoint(zombieid,1.0,xa,ya,za))// here playerid not zombieid
{
ZombieIsAttack[zombieid] = 2;
FCNPC_MeleeAttack(zombieid,100);
break;
}
else if(IsPlayerInRangeOfPoint(zombieid,10.0,xa,ya,za))
{
if(ZombieIsAttack[zombieid] == 2)
{
FCNPC_Stop(zombieid);
FCNPC_StopAttack(zombieid);
}
ZombieIsAttack[zombieid] = 1;
new Float:speed;
MRandFloatRange(-0.12123, 0.12123, speed);
FCNPC_GoTo(zombieid,xa,ya,za, FCNPC_MOVE_TYPE_RUN, 0.4, FCNPC_MOVE_MODE_MAPANDREAS, FCNPC_MOVE_PATHFINDING_RAYCAST);
break;
}
else if(IsPlayerInRangeOfPoint(zombieid,25.0,xa,ya,za))
{
if(ZombieIsAttack[zombieid] == 2)
{
FCNPC_Stop(zombieid);
FCNPC_StopAttack(zombieid);
}
ZombieIsAttack[zombieid] = 1;
new Float:speed;
MRandFloatRange(-0.12123, 0.12123, speed);
FCNPC_GoTo(zombieid,xa,ya,za, FCNPC_MOVE_TYPE_RUN, 0.4, FCNPC_MOVE_MODE_MAPANDREAS, FCNPC_MOVE_PATHFINDING_RAYCAST);
break;
}
else
{
ZombieIsAttack[zombieid] = 0;
FCNPC_Stop(zombieid);
FCNPC_StopAttack(zombieid);
FCNPC_ClearAnimations(zombieid);
}
}
return 1;
}
stock FCNPC_GoToPlayerEx(npcid, playerid, Float:dist, Float:rangle, movetype = FCNPC_MOVE_TYPE_RUN)
{
new Float:xa, Float:ya, Float:za, Float:fa;
GetPlayerPos(playerid, xa, ya, za);
GetPlayerFacingAngle(playerid, fa);
rangle += fa;
xa = (xa + dist * floatsin(-rangle,degrees));
ya = (ya + dist * floatcos(-rangle,degrees));
FCNPC_GoTo(npcid,xa,ya,za,movetype,0.4, true);
FCNPC_GoTo(zombieid,xa,ya,za, FCNPC_MOVE_TYPE_RUN, 0.4, FCNPC_MOVE_MODE_COLANDREAS, FCNPC_MOVE_PATHFINDING_Z);
return 1;
}
CallBack::OnPlayerKillZombie(playerid,zombieid)
{
FCNPC_Respawn(zombieid);
return 1;
}
hook FCNPC_OnRespawn(npcid)
{
new rnd = random(sizeof(ZombieSpawns));
FCNPC_SetWeapon(npcid,1);
FCNPC_ApplyAnimation(npcid, "PED", "WALK_DRUNK", 4.1, 1, 1, 1, 0, 0);
FCNPC_SetAmmo(npcid,1);
FCNPC_SetPosition(npcid,ZombieSpawns[rnd][0],ZombieSpawns[rnd][1],ZombieSpawns[rnd][2]);
return 1;
}``