enum Zombie
{
zTipo,
Float:zX,
Float:zY,
Float:zZ
}
static const Zombies[MAX_ZOMBIES][Zombie] =
{ // {X, Y, Z, TIPO} 3 tipos : Normal, rapido, zombie con mutacion MAISK-2.
{1, 2490.4277,-1670.0314,13.3359}
};
//"funcion" is a simple redefine of forward and public.
funcion CargarZombies(){ //Called in OnGameModeInit, after initialising MapAndreas.
new ZombieNombre[10];
for(new i; i < sizeof(Zombies); i++){
format(ZombieNombre, 10, "Zombie_%i", i);
FCNPC_ToggleMapAndreasUsage(i, true);
FCNPC_Create(ZombieNombre);
FCNPC_Spawn(i, ZombieSkin(Zombies[i][zTipo]), Zombies[i][zX],Zombies[i][zY],Zombies[i][zZ]);
}
return 1;
}
public FCNPC_OnSpawn(npcid){
print("Zombie spawn");
return 1;
}
public FCNPC_OnCreate(npcid){
new Float:vida;
if(Zombies[npcid][zTipo] != 3) vida = 170;
else vida = 300;
FCNPC_SetPosition(npcid, Zombies[npcid][zX],Zombies[npcid][zY],Zombies[npcid][zZ]);
FCNPC_SetHealth(npcid, vida);
SetTimerEx("ZombieVerificar", 500, true, "i", npcid);
print("Zombie oncreate");
return 1;
}
FCNPC_SetPosition(npcid, 10,50,54); // Test coords, for some reason, the NPC spawns in this coords, but not when iґm using the array.
|
When is it not working?
Which coords are used at the bottom example? When is it 0,0,0 ? Add more information, we don't own nor know the script, so a little more information would be beneficial ![]() |
funcion ZombieSkin(tipo){
new skin;
switch(tipo){
case 1: skin = 1;
case 2: skin = 2;
case 3: skin = 3; // cambiar luego.
}
return skin;
}
|
My bad.
Did you show the whole array called "Zombies" ? If yes, are you sure that you don't have any error like "array index out of bounds"? |
for(new i, zombieid; i < sizeof(Zombies); i++){
format(ZombieNombre, 10, "Zombie_%i", i);
zombieid = FCNPC_Create(ZombieNombre);
FCNPC_ToggleMapAndreasUsage(zombieid, true);
FCNPC_Spawn(zombieid, ZombieSkin(Zombies[i][zTipo]), Zombies[i][zX],Zombies[i][zY],Zombies[i][zZ]);
}
|
Isn't that should be:
PHP код:
|