SA-MP Forums Archive
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: NPC-s (/showthread.php?tid=262288)



NPC-s - Markx - 17.06.2011

How can i make a NPC which would just stand there and do 1 anim all the time?


Re: NPC-s - Stigg - 17.06.2011

https://sampforum.blast.hk/showthread.php?tid=95034

https://sampwiki.blast.hk/wiki/ApplyAnimation


Re: NPC-s - Markx - 17.06.2011

Quote:
Originally Posted by Stigg
Посмотреть сообщение
Did that but, the NPC crashes...


Re: NPC-s - Stigg - 17.06.2011

Can we see the npc code ?


Re: NPC-s - Markx - 17.06.2011

pawn Код:
//GameModelNit or something lol
    ConnectNPC("Training","TrainingGuy");
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(IsPlayerNPC(playerid))
    {
        new npcname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, npcname, sizeof(npcname));
        if(!strcmp(npcname, "Training", true))
        {
            SetPlayerPos(playerid, 302.4050,2067.1462,17.6406);
            SetPlayerFacingAngle(playerid, 109.0411);
            ApplyAnimation(playerid,"COP_AMBIENT","Coplook_loop",4.1,0,0,0,1,0);
        }
        return 1;
    }
    SetPlayerPos(playerid, 315.55523682,2059.98608398, 27); //just for example.
    return true;
}



Re: NPC-s - Stigg - 17.06.2011

Your code looks good.
Have you placed the npc script in the npcmodes folder and the recorded file in the recordings folder ?
Can we see the npc mini script too ?


Re: NPC-s - Markx - 17.06.2011

Quote:
Originally Posted by Stigg
Посмотреть сообщение
Your code looks good.
Have you placed the npc script in the npcmodes folder and the recorded file in the recordings folder ?
Can we see the npc mini script too ?
Yeah i did, here

pawn Код:
#define RECORDING "TrainingGuy" //This is the filename of your recording without the extension.
#define RECORDING_TYPE 2 //1 for in vehicle and 2 for on foot.

#include <a_npc>
main(){}
public OnRecordingPlaybackEnd() StartRecordingPlayback(RECORDING_TYPE, RECORDING);

#if RECORDING_TYPE == 1
  public OnNPCEnterVehicle(vehicleid, seatid) StartRecordingPlayback(RECORDING_TYPE, RECORDING);
  public OnNPCExitVehicle() StopRecordingPlayback();
#else
  public OnNPCSpawn() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
#endif



Re: NPC-s - Stigg - 17.06.2011

Cant see anything wrong there either. Have you tried spawning the ncp without the aninmation ?


Re: NPC-s - Markx - 17.06.2011

Quote:
Originally Posted by Stigg
Посмотреть сообщение
Cant see anything wrong there either. Have you tried spawning the ncp without the aninmation ?
I go record it again and make everything new, and then gonna tell you if its fixed or not, thanks for your help and time


Re: NPC-s - Markx - 17.06.2011

*sorry for duble post*

okay, everything works but, the facing angle isnt correct, so i tryd to set it but no effect, also the anim isnt working...everything gets printed but still...

pawn Код:
public OnPlayerSpawn(playerid)
{
    if(IsPlayerNPC(playerid))
    {
        new npcname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, npcname, sizeof(npcname));
        if(!strcmp(npcname, "Dave", true))
        {
            SetPlayerSkin(playerid, 179);
            print("Skin done");
            SetPlayerFacingAngle(playerid, 269.7591);
            print("Facing angle done");
            ApplyAnimation(playerid,"COP_AMBIENT","Coplook_loop",4.1,0,0,0,1,0);
            print("Anim done");
            Dave[playerid] = Create3DTextLabel("Dave", 0x00FF0000, 30.0, 40.0, 50.0, 40.0, 0);
            Attach3DTextLabelToPlayer(Dave[playerid], playerid, 0.0, 0.0, 0.2);
            print("3D text done");
            return true;
        }
        return 1;
    }
    SetPlayerPos(playerid, 315.55523682,2059.98608398, 27);
    return true;
}