Advertisement
Guest User

Untitled

a guest
Apr 9th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.39 KB | None | 0 0
  1. #include <a_npc>
  2.  
  3. new gStoppedForTraffic = 0;
  4. new gPlaybackActive = 0;
  5.  
  6. public ScanTimer();
  7.  
  8. #define AHEAD_OF_CAR_DISTANCE    11.0
  9. #define SCAN_RADIUS              11.0
  10.  
  11. //------------------------------------------
  12.  
  13. main(){}
  14.  
  15. //------------------------------------------
  16.  
  17. stock GetXYInfrontOfMe(Float:distance, &Float:x, &Float:y)
  18. {
  19.     new Float:z, Float:angle;
  20.     GetMyPos(x,y,z);
  21.     GetMyFacingAngle(angle);
  22.     x += (distance * floatsin(-angle, degrees));
  23.     y += (distance * floatcos(-angle, degrees));
  24. }
  25.  
  26. //------------------------------------------
  27.  
  28. public OnNPCModeInit()
  29. {
  30.     SetTimer("ScanTimer",200,1);
  31. }
  32.  
  33. //------------------------------------------
  34.  
  35. LookForAReasonToPause()
  36. {
  37.     new Float:X,Float:Y,Float:Z;
  38.     new x=0;
  39.    
  40.     GetMyPos(X,Y,Z);
  41.     GetXYInfrontOfMe(AHEAD_OF_CAR_DISTANCE,X,Y);
  42.    
  43.     while(x!=MAX_PLAYERS) {
  44.         if(IsPlayerConnected(x) && IsPlayerStreamedIn(x)) {
  45.             if( GetPlayerState(x) == PLAYER_STATE_DRIVER ||
  46.                 GetPlayerState(x) == PLAYER_STATE_ONFOOT )
  47.             {
  48.                 if(IsPlayerInRangeOfPoint(x,SCAN_RADIUS,X,Y,Z)) {
  49.                     return 1;
  50.                 }
  51.             }
  52.         }
  53.         x++;
  54.     }
  55.    
  56.     //new msg[256];
  57.     //new Float:angle;
  58.     //GetMyFacingAngle(angle);
  59.     //format(msg,256,"My yaw/heading = %f",angle);
  60.     //SendChat(msg);
  61.    
  62.     return 0;
  63. }
  64.  
  65.  
  66. //------------------------------------------
  67.  
  68. public ScanTimer()
  69. {
  70.     //new ticker = GetTickCount() - g_LastTick;
  71.     //printf("npctest: timer (%d)ms", ticker);
  72.     //g_LastTick = GetTickCount();
  73.    
  74.     new ReasonToPause = LookForAReasonToPause();
  75.    
  76.     if(ReasonToPause && !gStoppedForTraffic)
  77.     {
  78.         //SendChat("I'm pausing");
  79.         PauseRecordingPlayback();
  80.         gStoppedForTraffic = 1;
  81.     }
  82.     else if(!ReasonToPause && gStoppedForTraffic)
  83.     {
  84.         //SendChat("I'm resuming");
  85.         ResumeRecordingPlayback();
  86.         gStoppedForTraffic = 0;
  87.     }
  88. }
  89.  
  90.  
  91. //------------------------------------------
  92.  
  93. StartPlayback()
  94. {
  95.     StartRecordingPlayback(PLAYER_RECORDING_TYPE_DRIVER,"taxi_test_1282");
  96.     gStoppedForTraffic = 0;
  97.     gPlaybackActive = 1;
  98. }
  99.    
  100.  
  101. //------------------------------------------
  102.  
  103. public OnRecordingPlaybackEnd()
  104. {
  105.     StartPlayback();
  106. }
  107.  
  108. //------------------------------------------
  109.  
  110. public OnNPCEnterVehicle(vehicleid, seatid)
  111. {
  112.     StartPlayback();
  113. }
  114.  
  115. //------------------------------------------
  116.  
  117. public OnNPCExitVehicle()
  118. {
  119.     StopRecordingPlayback();
  120. }
  121.  
  122. //------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement