Advertisement
sancio

[PAWN] Numeriu gavimas

Sep 21st, 2016
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.51 KB | None | 0 0
  1. /*
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.         @ Masinu registravimo sistema
  10.         @ Sukurta Aleksandr 'SanCio' P.
  11.         @ 2014 metais
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19. */
  20.  
  21. #define         NUMBER_PRICE            500  // Numeriu kaina
  22. #define         REG_PRICE               150 // Registravimo kaina
  23.  
  24. new numberLetters [] [] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "V", "X", "Y", "Z" }; // nuo A iki Z numeriu raides
  25. new numberInts [] [] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; // nuo 0 iki 9 numeriu skaiciai
  26.  
  27. // Registravimo komanda
  28. CMD:registruoti (playerid) {
  29.     if ( GetPlayerState (playerid) == PLAYER_STATE_DRIVER )  // Tikrinam ar zaidejas sedi transporte, jeigu TAIP parodom DIALOG
  30.         ShowPlayerDialog (playerid, 52, DIALOG_STYLE_MSGBOX, "Numeriu gavimas" , "Ar norite gauti numerius savo masinai? ", "Taip", "Ne" ) ; // parodom DIALOG langa
  31.     else // jeigu NE issiunciam zinute, kad jis neesa tr. priemoneje
  32.         SendClientMessage (playerid, -1, "Jus neesate masinoje!"); // Issiunciam zinute
  33. }
  34.  
  35. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  36. {
  37.     if (dialogid == 52) {
  38.         if (response) {
  39.            
  40.             new vID             =       GetPlayerVehicleID  (playerid), // Isgaunam zaidejo transporto ID, kuriame jis sedi
  41.                 numbers                 [8], // STRING tipo kintamasis, i kuri irasysim suformatuotus numerius
  42.                 Float:pPos              [3]; // Kintamieji i kuriuos bus irasyti zaidejo pozicija
  43.  
  44.             GetPlayerPos (playerid, pPos[0], pPos[1], pPos[2]); // Isgaunam zaidejo pozicija
  45.             // Formatuojam musu busimus numerius
  46.             format (numbers, sizeof(numbers),
  47.                 "%c%c%c %c%c%c",
  48.                 numberLetters[random(sizeof(numberLetters))], numberLetters[random(sizeof(numberLetters))], numberLetters[random(sizeof(numberLetters))],
  49.                 numberInts[random(sizeof(numberInts))], numberInts[random(sizeof(numberInts))], numberInts[random(sizeof(numberInts))]
  50.             );
  51.  
  52.             printf ("Numeriai: %s", numbers); // Isprintinam i console gautus numerius (debug'as)
  53.             SetVehicleNumberPlate           (vID, numbers);     // Nusistatom numerius
  54.             SetVehicleToRespawn             (vID); // Respawninam masina
  55.             SetVehiclePos                   (vID, pPos[0], pPos[1], pPos[2]) ; // Grazinam masina pas zaideja
  56.             PutPlayerInVehicle              (playerid, vID, 0);  // Isodinam zaideja atgal i masina
  57.             SendClientMessage               (playerid, -1, "Isigyjai numerius"); // Issiunciam zaidejui zinute, kad jis isigyjo numerius
  58.             GivePlayerMoney                 (playerid, -NUMBER_PRICE); // minusuojam pinigus uz numerius
  59.             GivePlayerMoney                 (playerid, -REG_PRICE); // minusuojam pinigus uz registravima
  60.         }
  61.     }
  62.     return 1;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement