Advertisement
Guest User

Untitled

a guest
Jun 29th, 2012
970
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.44 KB | None | 0 0
  1. #include <a_npc>
  2. main() {}
  3. new bool:updateStatus = false, MAX_PLAYERS_ = MAX_PLAYERS, bool:usedCommand = false, bool:stopped = false;
  4. public OnRecordingPlaybackEnd() StartRecordingPlayback(1,"bus");
  5. public OnNPCEnterVehicle(vehicleid, seatid)
  6. {
  7.     StartRecordingPlayback(1,"bus");
  8.     stopped = false;
  9. }
  10. public OnNPCExitVehicle() StopRecordingPlayback();
  11. public OnClientMessage(color, text[]) if(usedCommand && IsNumeric(text) && strlen(text) > 0 && strlen(text) <= 3) MAX_PLAYERS_ = strval(text), usedCommand = false;
  12. public OnNPCModeInit() SetTimer("BusUpdate",1500,1);
  13. forward BusUpdate();
  14. public BusUpdate()
  15. {
  16.     if((updateStatus = !updateStatus))
  17.     {
  18.         SendCommand("/maxplayers");
  19.         usedCommand = true;
  20.     }
  21.     else
  22.     {
  23.         new bool:hasReason = SearchForSomeoneInFrontOfMe();
  24.         if(hasReason && !stopped)
  25.         {
  26.             PauseRecordingPlayback();
  27.             stopped = true;
  28.         }
  29.         else if(!hasReason && stopped)
  30.         {
  31.             ResumeRecordingPlayback();
  32.             stopped = false;
  33.         }
  34.     }
  35.     return 1;
  36. }
  37. stock GetXYInFrontOfMe(Float:distance, &Float:x, &Float:y)
  38. {   // by Kye
  39.     new Float:z, Float:angle;
  40.     GetMyPos(x,y,z);
  41.     GetMyFacingAngle(angle);
  42.     x += (distance * floatsin(-angle, degrees));
  43.     y += (distance * floatcos(-angle, degrees));
  44. }
  45. stock IsNumeric(const string[])
  46. {
  47.     for(new i = string[0] == '-' ? 1 : 0, j = strlen(string); i < j; i++) if(string[i] < '0' || string[i] > '9') return 0;
  48.     return 1;
  49. }
  50. forward bool:SearchForSomeoneInFrontOfMe();
  51. stock bool:SearchForSomeoneInFrontOfMe()
  52. {
  53.     new Float:p[3], player[MAX_PLAYERS], players = 0;
  54.     GetMyPos(p[0],p[1],p[2]);
  55.     GetXYInFrontOfMe(17.5,p[0],p[1]);
  56.     for(new i = 0; i < MAX_PLAYERS_; i++) if(IsPlayerConnected(i) && IsPlayerStreamedIn(i)) if((GetPlayerState(i) == PLAYER_STATE_DRIVER || GetPlayerState(i) == PLAYER_STATE_ONFOOT) && IsPlayerInRangeOfPoint(i,11.0,p[0],p[1],p[2])) player[players++] = i;
  57.     if(players > 0 && !stopped)
  58.     {
  59.         new string[128];
  60.         if(players == 1)
  61.         {
  62.             GetPlayerName(player[0],string,MAX_PLAYER_NAME);
  63.             else switch(random(2))
  64.             {
  65.                 case 0: format(string,sizeof(string),"%s MOVE!",string);
  66.                 case 1: format(string,sizeof(string),"%s, I need to drive there!",string);
  67.             }
  68.         }
  69.         else if(players > 1)
  70.         {
  71.             switch(random(2))
  72.             {
  73.                 case 0: format(string,sizeof(string),"Get out of my way.");
  74.                 case 1: format(string,sizeof(string),"%d of you, get away!",players);
  75.             }
  76.         }
  77.         format(string,sizeof(string),"/italk2all %s",string);
  78.         SendCommand(string);
  79.     }
  80.     return players > 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement