SA-MP Forums Archive
Impossible to attach objects to npc's? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Impossible to attach objects to npc's? (/showthread.php?tid=136014)



Impossible to attach objects to npc's? - Rzzr - 22.03.2010

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?


Re: Why doesn't this work? - Rzzr - 23.03.2010

So, nobody knows this?


Re: Why doesn't this work? - adsy - 23.03.2010

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 -)


Re: Why doesn't this work? - Rzzr - 23.03.2010

No the 0 0 0 are the offset.


Re: Why doesn't this work? - adsy - 23.03.2010

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


Re: Why doesn't this work? - adsy - 23.03.2010

have you tried 0 0 0 on all ??

i note your trying to make it appear underneath the npc


Re: Why doesn't this work? - Rzzr - 24.03.2010

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


Re: Why doesn't this work? - adsy - 24.03.2010

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.


Re: Why doesn't this work? - Rzzr - 25.03.2010

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?


Re: Impossible to attach objects to npc's? - adsy - 26.03.2010

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.