[NPC] ! HELP !
#1

Hi, I have a problem with the NPC, I have a script that is when the player approached the auto-bot that hindered (entry paused). Everything works but if the player next to hamper the 2 cars, they hang, and will not go, even waste, even sit in it.

what is the problem?

Quote:

#include <a_npc>

new gStoppedForTraffic = 0;
new gPlaybackActive = 0;

public ScanTimer();

#define AHEAD_OF_CAR_DISTANCE 18.0 // 11.00
#define SCAN_RADIUS 18.0 //11.00

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

main(){}

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

stock GetXYInfrontOfMe(Float:distance, &Float, &Float:y)
{
new Float:z, Float:angle;
GetMyPos(x,y,z);
GetMyFacingAngle(angle);
x += (distance * floatsin(-angle+180, degrees)); //
y += (distance * floatcos(-angle+180, degrees)); //
}

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

public OnNPCModeInit()
{
SetTimer("ScanTimer",200,1);
}

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

LookForAReasonToPause()
{
new Float:X,Float:Y,Float:Z;
new x=0;

GetMyPos(X,Y,Z);
GetXYInfrontOfMe(AHEAD_OF_CAR_DISTANCE,X,Y);

while(x!=MAX_PLAYERS) {
if(IsPlayerConnected(x) && IsPlayerStreamedIn(x)) {
if( GetPlayerState(x) == PLAYER_STATE_DRIVER ||
GetPlayerState(x) == PLAYER_STATE_ONFOOT )
{
if(IsPlayerInRangeOfPoint(x,SCAN_RADIUS,X,Y,Z)) {
return 1;
}
}
}
x++;
}

//new msg[256];
//new Float:angle;
//GetMyFacingAngle(angle);
//format(msg,256,"My yaw/heading = %f",angle);
//SendChat(msg);

return 0;
}

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

public ScanTimer()
{
//new ticker = GetTickCount() - g_LastTick;
//printf("npctest: timer (%d)ms", ticker);
//g_LastTick = GetTickCount();

new ReasonToPause = LookForAReasonToPause();

if(ReasonToPause && !gStoppedForTraffic)
{
//SendChat("I'm pausing");
PauseRecordingPlayback();
gStoppedForTraffic = 1;
}
else if(!ReasonToPause && gStoppedForTraffic)
{
//SendChat("I'm resuming");
ResumeRecordingPlayback();
gStoppedForTraffic = 0;
}
}

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

StartPlayback()
{
StartRecordingPlayback(PLAYER_RECORDING_TYPE_DRIVE R,"BOT24");
gStoppedForTraffic = 0;
gPlaybackActive = 1;
}


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

public OnRecordingPlaybackEnd()
{
StartPlayback();
}

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

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

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

public OnNPCExitVehicle()
{
StopRecordingPlayback();
}

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

Reply
#2

Try using the NPC_FS_By-Quincy Updated filterscript. It can be found here on the forums. I also have a faq with pics that shows how to record and code bots using this script. It is one of the easiest I have found. Email me at stryder32@hotmail.com for the NPC bot FAQ.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)