NPC problem -
Casamiro - 06.07.2012
Hi, I have a problem with my NPC. I put in a few NPC, and they are flashing. Video link: [ame]http://www.youtube.com/watch?v=RwCkxtAxlgc[/ame]
When I'm have recorded the NPC, I put the .rec file to npcmodes/recordings. In the npcmodes folder I've created a .pwn file, contains:
Код:
#define RECORDING "NPC_Boltos" // .rec file name
#define RECORDING_TYPE 2 // 1 if NPC is in vehicle, 2 if NPC is onfoot
#include <a_npc>
public OnRecordingPlaybackEnd ( )
{
StartRecordingPlayback ( RECORDING_TYPE, RECORDING );
return 0;
}
#if RECORDING_TYPE == 1 // Vehicle
public OnNPCEnterVehicle ( vehicleid, seatid )
{
StartRecordingPlayback ( RECORDING_TYPE, RECORDING );
return 0;
}
public OnNPCExitVehicle ( )
{
StopRecordingPlayback ( );
return 0;
}
#else // Onfoot
public OnNPCSpawn ( )
{
StartRecordingPlayback ( RECORDING_TYPE, RECORDING );
return 0;
}
#endif
And connected the NPC in OnGameModeInit():
Код:
ConnectNPC ("NPC_Boltos","NPC_Boltos");
When the NPC spawn, I put a 3DText over the NPC's head, and give a skin, and interior.
Код:
if(!strcmp(npcname,"NPC_Boltos",true))
{
SetPlayerInterior(playerid, 6);
CreateDynamic3DTextLabel("[NPC] Eladу", 0x00BFFFFF, 0, 0, 0.5, 20.0, playerid, INVALID_VEHICLE_ID, 0);
SetPlayerSkin(playerid, 210);
}
The recording is about 15 seconds. Sorry for my bad English.
Re: NPC problem -
Avi57 - 06.07.2012
Visit Here :
https://sampforum.blast.hk/showthread.php?tid=95034
Hope you Get it !
Re: NPC problem -
Casamiro - 06.07.2012
I did the NPCs with this tutorial, but not good.
Re: NPC problem -
[KHK]Khalid - 06.07.2012
Hmm try taking the returns out in your npc pwn file.
Re: NPC problem -
Casamiro - 06.07.2012
HellSphinX, dont works.
Re: NPC problem -
[KHK]Khalid - 06.07.2012
Hmm as I see in the video there's something hinders it when (re)spawning so can you show the whole OnPlayerSpawn also if you have any others?
Re: NPC problem -
Vince - 06.07.2012
If this is a stationary NPC, then why bother with recordings at all? Just use SetPlayerPos in the gamemode or SetMyPos in the NPC script. I recommend the former, as the NPC callbacks don't always seem to work.
Re: NPC problem -
Casamiro - 06.07.2012
NPC part of OnPlayerSpawn:
Код:
if(IsPlayerNPC(playerid))
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid,npcname,sizeof(npcname));
if(!strcmp(npcname,"NPC_Boltos",true))
{
SetPlayerInterior(playerid, 6);
SetPlayerPos(playerid, -22.5769,-57.3684,1003.5469);
CreateDynamic3DTextLabel("[NPC] Eladу", 0x00BFFFFF, 0, 0, 0.5, 20.0, playerid, INVALID_VEHICLE_ID, 0);
SetPlayerSkin(playerid, 210);
}
if(!strcmp(npcname,"NPC_Benzinkutbolt",true))
{
SetPlayerInterior(playerid, 4);
SetPlayerPos(playerid, -29.6408,-30.6207,1003.5573);
CreateDynamic3DTextLabel("[NPC] Eladу", 0x00BFFFFF, 0, 0, 0.5, 20.0, playerid, INVALID_VEHICLE_ID, 0);
SetPlayerSkin(playerid, 183);
}
return 1;
}
I have return 1; for the NPCs
Edit.:
Vince: I tried, new .pwn file:
Код:
#define RECORDING "NPC_Boltos" // Ez az NPC-d neve, melyet felvettйl
#define RECORDING_TYPE 2 // Az NPC kцzlekedйse, 1 ha jбrműt vezet, 2 ha gyalogol
#include <a_npc> // Az NPC fьggvйnykцnyvtбr beбgyazбsa
public OnRecordingPlaybackEnd ( )
{
StartRecordingPlayback ( RECORDING_TYPE, RECORDING );
return 0;
}
#if RECORDING_TYPE == 1 // Ha az NPC tнpusa jбrműves vezető
public OnNPCEnterVehicle ( vehicleid, seatid )
{
StartRecordingPlayback ( RECORDING_TYPE, RECORDING );
return 0;
}
public OnNPCExitVehicle ( )
{
StopRecordingPlayback ( );
return 0;
}
#else // Viszont ha gyalogos
public OnNPCSpawn ( )
{
StartRecordingPlayback ( RECORDING_TYPE, RECORDING );
SetMyPos(-22.5769,-57.3684,1003.5469);
return 0;
}
#endif
But dont works.
Re: NPC problem -
Casamiro - 06.07.2012
Fixed.