Advertisement
Deaderik

Bot taxi worker in game

Feb 5th, 2024
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.65 KB | Gaming | 0 0
  1. #include <a_samp>
  2. #include <a_players>
  3.  
  4. new Float:botX, Float:botY, Float:botZ;
  5. new destinationX, destinationY, destinationZ;
  6. new Float:fare = 10.0;
  7. new playerToPickup = INVALID_PLAYER_ID;
  8. new playerConfirmation = INVALID_PLAYER_ID;
  9.  
  10. public OnGameModeInit()
  11. {
  12.     // Nastavení startovní pozice bota
  13.     botX = 1000.0;
  14.     botY = 1000.0;
  15.     botZ = 5.0;
  16.  
  17.     // Nastavení intervalu pro akce bota každých 10 sekund
  18.     SetTimer("BotActions", 10000, true);
  19.     return 1;
  20. }
  21.  
  22. public BotActions()
  23. {
  24.     // Přivolání taxikáře, nastavení cílového waypointu a čekání na hráče
  25.     CallTaxi();
  26.  
  27.     // Simulace čekání na hráče
  28.     WaitForPlayer();
  29.  
  30.     // Simulace cesty k cíli
  31.     TravelToDestination();
  32.  
  33.     // Simulace zaplacení za jízdu
  34.     PayFare();
  35.  
  36.     return 1;
  37. }
  38.  
  39. public CallTaxi()
  40. {
  41.     printf("Bot: Volá taxikáře na číslo 11774. Napíši '/volamtaxi', pokud chceš jet.");
  42.     // Simulovat zprávu nebo interakci s taxikářem
  43.     return 1;
  44. }
  45.  
  46. public WaitForPlayer()
  47. {
  48.     if (playerConfirmation == INVALID_PLAYER_ID)
  49.     {
  50.         printf("Bot: Čeká na potvrzení od hráče. Napiš '/potvrdit', pokud chceš jet.");
  51.     }
  52.     else
  53.     {
  54.         printf("Bot: Hráč potvrdil jízdu. Připrav se na odjezd.");
  55.     }
  56.  
  57.     return 1;
  58. }
  59.  
  60. public TravelToDestination()
  61. {
  62.     if (playerConfirmation != INVALID_PLAYER_ID)
  63.     {
  64.         destinationX = 1500.0;
  65.         destinationY = 1500.0;
  66.         destinationZ = 5.0;
  67.  
  68.         SetPlayerPos(playerToPickup, destinationX, destinationY, destinationZ);
  69.         printf("Bot: Dorazil jsi na cíl. Děkujeme za jízdu!");
  70.     }
  71.  
  72.     return 1;
  73. }
  74.  
  75. public PayFare()
  76. {
  77.     if (playerConfirmation != INVALID_PLAYER_ID)
  78.     {
  79.         if (IsPlayerConnected(playerToPickup))
  80.         {
  81.             GivePlayerMoney(playerToPickup, fare);
  82.             printf("Bot: Hráč ID %d zaplatil taxikáři %.2f peněz.", playerToPickup, fare);
  83.         }
  84.     }
  85.  
  86.     // Resetovat hodnoty pro další jízdu
  87.     playerToPickup = INVALID_PLAYER_ID;
  88.     playerConfirmation = INVALID_PLAYER_ID;
  89.  
  90.     return 1;
  91. }
  92.  
  93. public OnPlayerCommandText(playerid, cmdtext[])
  94. {
  95.     if (strcmp(cmdtext, "/volamtaxi", true) == 0)
  96.     {
  97.         playerToPickup = playerid;
  98.         printf("Hráč ID %d volá taxikáře.", playerid);
  99.         return 1;
  100.     }
  101.     else if (strcmp(cmdtext, "/potvrdit", true) == 0 && playerToPickup == playerid)
  102.     {
  103.         playerConfirmation = playerid;
  104.         SendClientMessage(playerConfirmation, -1, "Taxikář potvrdil tvoji žádost o jízdu.");
  105.         printf("Hráč ID %d potvrdil jízdu.", playerid);
  106.         return 1;
  107.     }
  108.  
  109.     return 0;
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement