OnNPCSpawn
#1

When i add the public OnNPCSpawn() it says i need to forward it first.
Reply
#2

Just forward it at beginning of the code and if you want to check when npc spawns just use isplayernpc on onplayerspawn
Reply
#3

Perhaps you didn't include the a_npc include or something?
Reply
#4

I included it.
Reply
#5

I remember I have read that a_npc does not work in the gamemode/filterscripts. This functions should be on the npcmodes folder/files
Reply
#6

so how do i make a npc script?
script it but then place it in scriptfiles folder?
Reply
#7

No, you have to open with pawno.exe the file from the
pawn Код:
..npcmodes /my_file_here.pwn
An example of the at400_ls by Kye, it uses the include there.
pawn Код:
//
// A Driver NPC that goes around a path continuously
// Kye 2009
//

#include <a_npc>

#define NUM_PLAYBACK_FILES 3
new gPlaybackFileCycle=0;

//------------------------------------------

main(){}

//------------------------------------------

NextPlayback()
{
    // Reset the cycle count if we reach the max
    if(gPlaybackFileCycle==NUM_PLAYBACK_FILES) gPlaybackFileCycle = 0;

    if(gPlaybackFileCycle==0) {
        StartRecordingPlayback(PLAYER_RECORDING_TYPE_DRIVER,"at400_ls_to_lv_x1");
    }
    else if(gPlaybackFileCycle==1) {
        StartRecordingPlayback(PLAYER_RECORDING_TYPE_DRIVER,"at400_lv_to_sf_x1");
    }
    else if(gPlaybackFileCycle==2) {
        StartRecordingPlayback(PLAYER_RECORDING_TYPE_DRIVER,"at400_sf_to_ls_x1");
    }

    gPlaybackFileCycle++;
}
   

//------------------------------------------

public OnRecordingPlaybackEnd()
{
    NextPlayback();
}

//------------------------------------------

public OnNPCEnterVehicle(vehicleid, seatid)
{
    NextPlayback();
}

//------------------------------------------

public OnNPCExitVehicle()
{
    StopRecordingPlayback();
    gPlaybackFileCycle = 0;
}

//------------------------------------------
Reply
#8

You cannot use <a_npc> and <a_samp> in the same script. You would have to create a separate script (placed in npcmodes as said above) if you want to use <a_npc>.
Reply
#9

Yep, a_npc is the replacement of a_samp for npc scripts. You cant use it in normal scripts, and the other way round.
So there is no OnNPCSpawn in normal gamemode scripts. Use OnPlayerSpawn for that.
OnNPCSpawn is just used in npc scripts. Check the tutorial section for more infos.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)