[HELP]NPCs aren't in my pos
#1

Hi, I made a timer witch each 4 sec it spawns a zombie (within a callback) :

pawn Код:
//Sorry about the identation when I copy a code here ...
public OnPlayerSpawn(playerid)                    
{
        new target;
    if(IsPlayerNPC(playerid))// if the player is NPC do nothing
        {
       
    }
    else
        {
        ZBT[playerid] = SetTimerEx("ZombieBot", 4000, true, "ii", playerid, target);
        }
 
    return 1;
}
pawn Код:
forward ZombieBot(playerid, target);
public ZombieBot(playerid, target)
{
        CreateRNPC("ZOMBIE");
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x,y,z);
        SetRNPCPos(target,x+6.0,y,z);
        SendClientMessage(playerid,COLOR_WHITE,"It is in your pos !");
    return 1;
}
I'm using RNPC include/plugin

The problem is : the npc is created but can't see npc in my pos...
Reply
#2

I think you have to

Код:
new npc = CreateRNPC("ZOMBIE");
and then use npc as target
Reply
#3

Thanks ! but it doesn't work , I don't know why...
Reply
#4

so as I understand you cannot use any functions of the in callbacks.... only cmds ?
I think there is a problem in SetRNPCPos(target,x+6.0,y,z);

it's like the server doesn't know what target means...
Reply
#5

target will be always 0. Like iJumbo said, you need to store the ID CreateRNPC returned and use it.
Reply
#6

I switched to
pawn Код:
forward ZombieBot(playerid, target);
public ZombieBot(playerid, target)
{
        new npc = CreateRNPC("ZOMBIE"); // modified this
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x,y,z);
        SetRNPCPos(npc,x+6.0,y,z); // modified target to npc don't thing if it has sence...
        SendClientMessage(playerid,COLOR_WHITE,"It is in your pos !");
    return 1;
}
still have the same problem
Reply
#7

NPC's take lot of effort depending on how complex they are you can not solely rely on the forums for help every time you have a problem. Working with NPC's takes strong problem solving skills, a lot of time and a lot of trail and error.
Reply
#8

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
NPC's take lot of effort depending on how complex they are you can not solely rely on the forums for help every time you have a problem. Working with NPC's takes strong problem solving skills, a lot of time and a lot of trail and error.
Quote:
Originally Posted by Saw®
Посмотреть сообщение
I switched to
pawn Код:
forward ZombieBot(playerid, target);
public ZombieBot(playerid, target)
{
        new npc = CreateRNPC("ZOMBIE"); // modified this
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x,y,z);
        SetRNPCPos(npc,x+6.0,y,z); // modified target to npc don't thing if it has sence...
        SendClientMessage(playerid,COLOR_WHITE,"It is in your pos !");
    return 1;
}
still have the same problem
I understand it's very hard , I only want people to help me fixing the error I have nothing related to have script request or... thank u anyway
Reply
#9

Well think about it, your trying to set the NPC position before it's even connected it takes a couple of seconds for that to happen but your trying to set the position right away.
Reply
#10

No I set it after NPC's connection

I'm actually doing this :

1-The player spawns
2-start the ZombieBot timer (Waiting 4 sec).
3-spawing a bot in the player's position .

that's all
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)