FCNPC, NPC spawns at 0,0,0. -
FedeA - 20.07.2018
Hello, iґm doing a simple Zombie NPC with FCNPC, but for some reason, the zombie is spawning at 0,0,0, not the coords that i want. Here is my code:
Код:
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;
}
I donґt know why this happens. If i put manual coords in FCNPC_OnCreate, it magical works.
Код:
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.
Re: FCNPC, NPC spawns at 0,0,0. -
denNorske - 20.07.2018
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
Re: FCNPC, NPC spawns at 0,0,0. -
FedeA - 20.07.2018
Quote:
Originally Posted by denNorske
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 
|
The post is clear, the NPC spawns at 0,0,0. The spawns coords should be 2490.4277,-1670.0314,13.3359
Using FCNPC_SetPosition doesnґt work, the NPC donґt moves from 0,0,0.
Re: FCNPC, NPC spawns at 0,0,0. -
Dayrion - 20.07.2018
Can you show ZombieSkin array?
Re: FCNPC, NPC spawns at 0,0,0. -
FedeA - 20.07.2018
Quote:
Originally Posted by Dayrion
Can you show ZombieSkin array?
|
Код:
funcion ZombieSkin(tipo){
new skin;
switch(tipo){
case 1: skin = 1;
case 2: skin = 2;
case 3: skin = 3; // cambiar luego.
}
return skin;
}
It only returns the skin of the NPC, a simple case.
Re: FCNPC, NPC spawns at 0,0,0. -
Dayrion - 20.07.2018
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"?
Re: FCNPC, NPC spawns at 0,0,0. -
FedeA - 20.07.2018
Quote:
Originally Posted by Dayrion
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"?
|
I use crashdetect, the compiler dont show any error (compiling with -d3), and the samp-server donґt show any error. The complete array is shown in the code that i posted, the unique thing that i didnґt post is MAX_ZOMBIES, but i donґt see it neccesary. (Its 1).
Re: FCNPC, NPC spawns at 0,0,0. -
Dayrion - 20.07.2018
Isn't that should be:
PHP код:
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]);
}
Re: FCNPC, NPC spawns at 0,0,0. -
FedeA - 20.07.2018
Quote:
Originally Posted by Dayrion
Isn't that should be:
PHP код:
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]);
}
|
Worked, i see my error, thanks!
+REP.