#include <a_npc>
new MegAllt;
forward ScanTimer();
#define AHEAD_OF_CAR_DISTANCE 11
#define SCAN_RADIUS 11
public OnNPCModeInit()
{
SetTimer(\"ScanTimer\",100,1);
}
public OnNPCEnterVehicle(vehicleid,seatid)
{
StartPlayback();
return 0;
}
public OnNPCExitVehicle()
{
StopRecordingPlayback();
return 0;
}
public OnNPCSpawn()
{
StartPlayback();
return 0;
}
public OnRecordingPlaybackEnd()
{
StartPlayback();
return 0;
}
public ScanTimer()
{
new ReasonToPause = LookForAReasonToPause();
if(ReasonToPause && MegAllt == 0)
{
PauseRecordingPlayback();
MegAllt = 1;
}
else if(!ReasonToPause && MegAllt == 1)
{
ResumeRecordingPlayback();
MegAllt = 0;
}
}
stock LookForAReasonToPause()
{
new Float:X,Float:Y,Float:Z;
GetMyPos(X,Y,Z);
GetXYInfrontOfMe(AHEAD_OF_CAR_DISTANCE,X,Y);
for(new x = 0; x < MAX_PLAYERS; x++)
{
if(IsPlayerConnected(x))
{
if(GetPlayerState(x) == PLAYER_STATE_DRIVER || GetPlayerState(x) == PLAYER_STATE_ONFOOT)
{
if(IsPlayerInRangeOfPoint(x,SCAN_RADIUS,X,Y,Z))
{
return 1;
}
}
}
}
return 0;
}
stock GetXYInfrontOfMe(Float:distance, &Float:x, &Float:y)
{
new Float:z, Float:angle;
GetMyPos(x,y,z);
GetMyFacingAngle(angle);
x += (distance * floatsin(-angle, degrees));
y += (distance * floatcos(-angle, degrees));
}
stock StartPlayback()
{
StartRecordingPlayback(PLAYER_RECORDING_TYPE_DRIVER,\"BusNPC\");
MegAllt = 0;
}
Ez a kód van, kipróbáltam, azonban ha melette állok meg akkor is megáll, és ha elötte vagyok pl. kocsival akkor még el üt és csak utána ál meg.
Esetleg valami ötlet?