Advertisement
Vuk7

Rent Vehicles System by Vuk

Aug 9th, 2016
736
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.25 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3.  
  4. #define RENT_CIJENA 100
  5. #define DIALOG_RENT 1
  6. #define SCM SendClientMessage
  7.  
  8. new VoziloZaRent[MAX_VEHICLES];
  9. new VoziloRentano[MAX_VEHICLES];
  10. new RentaVozilo[MAX_PLAYERS];
  11. new IdRentVozila[MAX_PLAYERS];
  12.  
  13. main()
  14. {
  15.     print("\n----------------------------------");
  16.     print("Rent system ");
  17.     print("     by Vuk ");
  18.     print("----------------------------------\n");
  19. }
  20.  
  21. public OnGameModeInit()
  22. {
  23.     SetGameModeText("Rent System");
  24.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  25.     CreateRentVehicle(522,2032.8513,1330.6235,10.5474,7.4996,0,0); // rent 1
  26.     CreateRentVehicle(411,2036.9824,1330.8070,10.4706,3.1578,0,0); // rent 2
  27.     CreateRentVehicle(411,2041.3179,1331.1278,10.3990,5.8312,0,0); // rent 3
  28.  
  29.     return 1;
  30. }
  31.  
  32. public OnGameModeExit()
  33. {
  34.     return 1;
  35. }
  36.  
  37. public OnPlayerRequestClass(playerid, classid)
  38. {
  39.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  40.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  41.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  42.     return 1;
  43. }
  44.  
  45. public OnPlayerConnect(playerid)
  46. {
  47.     RentaVozilo[playerid] = 0;
  48.     IdRentVozila[playerid] = -1;
  49.     return 1;
  50. }
  51.  
  52. public OnPlayerDisconnect(playerid, reason)
  53. {
  54.     if(RentaVozilo[playerid] == 1)
  55.     {
  56.         SetVehicleToRespawn(IdRentVozila[playerid]);
  57.         VoziloRentano[IdRentVozila[playerid]] = 0;
  58.         RentaVozilo[playerid] = 0;
  59.         IdRentVozila[playerid] = -1;
  60.     }
  61.     return 1;
  62. }
  63.  
  64. ////////////////////////////////////////////////////////////////////////////////
  65. ////////////////////////*****KOMANDE*****///////////////////////////////////////
  66. ////////////////////////////////////////////////////////////////////////////////
  67. CMD:v(playerid,params[])
  68. {
  69.     new Float:x,Float:y,Float:z;
  70.     GetPlayerPos(playerid,x,y,z);
  71.     CreateVehicle(411,x,y,z,0,0,0,100);
  72.     return 1;
  73. }
  74. CMD:unrentaj(playerid,params[])
  75. {
  76.     if(RentaVozilo[playerid] == 1)
  77.     {
  78.         if(IsPlayerInAnyVehicle(playerid))
  79.         {
  80.             if(GetPlayerVehicleID(playerid) == IdRentVozila[playerid])
  81.             {
  82.                 RemovePlayerFromVehicle(playerid);
  83.             }
  84.         }
  85.         SetVehicleToRespawn(IdRentVozila[playerid]);
  86.         VoziloRentano[IdRentVozila[playerid]] = 0;
  87.         RentaVozilo[playerid] = 0;
  88.         IdRentVozila[playerid] = -1;
  89.     }
  90.     else
  91.     {
  92.         SCM(playerid,-1,"Ne rentas vozilo!");
  93.     }
  94.     return 1;
  95. }
  96. CMD:test(playerid,params[])
  97. {
  98.     GivePlayerMoney(playerid,100000);
  99.     return 1;
  100. }
  101. ////////////////////////////////////////////////////////////////////////////////
  102. ////////////////////////////////////////////////////////////////////////////////
  103. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  104. {
  105.     return 1;
  106. }
  107.  
  108. public OnPlayerExitVehicle(playerid, vehicleid)
  109. {
  110.     return 1;
  111. }
  112.  
  113. public OnPlayerStateChange(playerid, newstate, oldstate)
  114. {
  115.     if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
  116.     {
  117.         new vehid = GetPlayerVehicleID(playerid);
  118.         if(VoziloZaRent[vehid] == 1)
  119.         {
  120.             if(VoziloRentano[vehid] == 1 && IdRentVozila[playerid] != vehid)
  121.             {
  122.                 RemovePlayerFromVehicle(playerid);
  123.             }
  124.             else if(VoziloRentano[vehid] == 0)
  125.             {
  126.                 TogglePlayerControllable(playerid,0);
  127.                 new str[100];
  128.                 format(str,sizeof(str),"Ovo je vozilo za rent.\n Cijena renta: $%d.",RENT_CIJENA);
  129.                 ShowPlayerDialog(playerid,DIALOG_RENT,DIALOG_STYLE_MSGBOX,"Rent:",str,"Rentaj","Odustani");
  130.             }
  131.         }
  132.     }
  133.     return 1;
  134. }
  135.  
  136. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  137. {
  138.     return 1;
  139. }
  140.  
  141.  
  142. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  143. {
  144.     if(dialogid == DIALOG_RENT)
  145.     {
  146.         if(!response)
  147.         {
  148.             TogglePlayerControllable(playerid,1);
  149.             RemovePlayerFromVehicle(playerid);
  150.             return 1;
  151.         }
  152.         if(response)
  153.         {
  154.             new vehid = GetPlayerVehicleID(playerid);
  155.             if(VoziloZaRent[vehid] == 1)
  156.             {
  157.                 if(RentaVozilo[playerid] == 0)
  158.                 {
  159.                     if(VoziloRentano[vehid] == 0)
  160.                     {
  161.                         if(GetPlayerMoney(playerid) >= RENT_CIJENA)
  162.                         {
  163.                             VoziloRentano[vehid] = 1;
  164.                             RentaVozilo[playerid] = 1;
  165.                             IdRentVozila[playerid] = vehid;
  166.                             TogglePlayerControllable(playerid,1);
  167.                             GivePlayerMoney(playerid,-RENT_CIJENA);
  168.                         }
  169.                         else
  170.                         {
  171.                             SCM(playerid,-1,"Nemas dovoljno novaca!");
  172.                             TogglePlayerControllable(playerid,1);
  173.                             RemovePlayerFromVehicle(playerid);
  174.                         }
  175.                     }
  176.                     else
  177.                     {
  178.                         SCM(playerid,-1,"Ovo vozilo je vec rentano!");
  179.                         TogglePlayerControllable(playerid,1);
  180.                         RemovePlayerFromVehicle(playerid);
  181.                     }
  182.                 }
  183.                 else
  184.                 {
  185.                     SCM(playerid,-1,"Vec rentas vozilo!");
  186.                     TogglePlayerControllable(playerid,1);
  187.                     RemovePlayerFromVehicle(playerid);
  188.                 }
  189.             }
  190.             else
  191.             {
  192.                 SCM(playerid,-1,"Ovo nije rent vozilo!");
  193.                 TogglePlayerControllable(playerid,1);
  194.                 RemovePlayerFromVehicle(playerid);
  195.             }
  196.         }
  197.         return 1;
  198.     }
  199.     return 1;
  200. }
  201.  
  202. stock CreateRentVehicle(vehmod,Float:x,Float:y,Float:z,Float:rot,col1,col2)
  203. {
  204.     new vehid;
  205.     vehid = CreateVehicle(vehmod,Float:x,Float:y,Float:z,Float:rot,col1,col2,100);
  206.     VoziloZaRent[vehid] = 1;
  207.     VoziloRentano[vehid] = 0;
  208.     SetVehicleNumberPlate(vehid,"RENT VOZILO");
  209.     return vehid;
  210. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement