Impossible to attach objects to npc's?
#1

I'm trying to attach objects to an NPC but it doesn't work.
It does set the skin and all but the objects are just in their spawn place :/

pawn Код:
if(!strcmp(npcname, "Johnny_Blaze", true))
    {
      PutPlayerInVehicle(playerid, Ghostbike, 0);
      SetPlayerColor(playerid, COLOR_WHITE);
      Attach3DTextLabelToPlayer(GhostLabel, playerid, 0.0, 0.0, 0.4);
      SetPlayerSkin(playerid, 181);
      AttachObjectToPlayer(Ghostflame, playerid, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0);
      AttachObjectToPlayer(Ghostsmoke, playerid, 0.0, 0.0, -7.0, 0.0, 0.0, 0.0);
    }
NOTE: if I attach the objects to myself under onplayerspawn, it DOES work. So is it impossible to attach objects to NPC's?
Reply
#2

So, nobody knows this?
Reply
#3

instead of 0 0 0 everywhere maybe use floats?

new Float, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);

AttachObject(......... , x, y, z+ or -)
Reply
#4

No the 0 0 0 are the offset.
Reply
#5

i cant look it up on the wiki at work so forgive me for that, ill take a look when i get home just in case i can be of any more assistance
Reply
#6

have you tried 0 0 0 on all ??

i note your trying to make it appear underneath the npc
Reply
#7

Yeah but the objects just appear on the place I create them. :/
Reply
#8

oh!!! i think i understand now

your creating the object first (obviously) then attaching it. but the place your creating it might not be anywhere near the player. so its attached it where it is currently.

you need to move the object to the player first.
Reply
#9

I have tried to attach the objects to myself in exactly the same way as I did to the npc, and it worked.
So I have a new question:

Is it impossible to attach objects to npc's?
Reply
#10

is it possible to use a workaround for this.

example:

Код:
GetNPCPos(npc, npcx, npcy, npcz); //this is not a command that i know of at the mo
SetTimer("ObjectMove", 100, 1);

forward ObjectMove(npc, objectid);
public ObjectMove(npc, objectid){
moveobject(npc, objectid, npcx, npcy, npcz (+ or minus here));
}
Please note i have not used correct functions as i cannot look them up at work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)