FCNPC, NPC spawns at 0,0,0.
#1

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.
Reply
#2

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
Reply
#3

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.
Reply
#4

Can you show ZombieSkin array?
Reply
#5

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.
Reply
#6

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"?
Reply
#7

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).
Reply
#8

Isn't that should be:

PHP код:
    for(new izombieidsizeof(Zombies); i++){
        
format(ZombieNombre10"Zombie_%i"i);
        
zombieid FCNPC_Create(ZombieNombre);
        
FCNPC_ToggleMapAndreasUsage(zombieidtrue);
        
FCNPC_Spawn(zombieidZombieSkin(Zombies[i][zTipo]), Zombies[i][zX],Zombies[i][zY],Zombies[i][zZ]);
    } 
Reply
#9

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
Isn't that should be:

PHP код:
    for(new izombieidsizeof(Zombies); i++){
        
format(ZombieNombre10"Zombie_%i"i);
        
zombieid FCNPC_Create(ZombieNombre);
        
FCNPC_ToggleMapAndreasUsage(zombieidtrue);
        
FCNPC_Spawn(zombieidZombieSkin(Zombies[i][zTipo]), Zombies[i][zX],Zombies[i][zY],Zombies[i][zZ]);
    } 
Worked, i see my error, thanks!

+REP.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)