Advertisement
Guest User

CAN Dynamic Veh. Renting

a guest
Jul 28th, 2014
1,321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 20.00 KB | None | 0 0
  1.  
  2.  
  3. //            Cannary2048 // Kevin
  4.  
  5.  
  6. #define FILTERSCRIPT
  7. #include <a_samp>
  8. #include <zcmd>
  9. #include <Dini>
  10. new Float: rX, Float: rY, Float: rZ, Float: rA;
  11. new Float: vX, Float: vY, Float: vZ, Float: vA;
  12. new unrenttimer[MAX_PLAYERS];
  13. //        ** ID **
  14. #define Vehicle_0_ID        411 // Infernus
  15. #define Vehicle_1_ID        500 // Mesa
  16.  
  17. //    ** NAME CONFIG **
  18. #define Vehicle_0_Name      "Infernus" // Vehicle Name
  19. #define Vehicle_1_Name      "Mesa" //
  20.  
  21. //    ** PRICE CONFIG **
  22. #define Vehicle_0_Price     1000   // Vehicle one Price
  23. #define Vehicle_1_Price     20   // Vehicle two Price
  24.  
  25. //   ** FINES CONFIG **
  26. #define Vehicle_0_Fine      5000 // Fine after you explode/drown the rented veh
  27. #define Vehicle_1_Fine      1000
  28.  
  29. #define DIALOG_RENTAL 3000
  30. #define DIALOG_UNRENT 3001
  31. #define DIALOG_RENTAL2 3002
  32. #define DIALOG_RENTAL3 3003
  33. #define DIALOG_RENTALCREATE 3004
  34. #define DIALOG_RENTALCREATE2 3005
  35.  
  36. #define MAX_RENTALS 200
  37. #define COLOR_LIGHTGREEN 0xCCFFCCFF
  38. #define COLOR_RED   0xFF0000FF
  39. new kontolCreated[2]; // This will check if the renting booth is created
  40.  
  41. enum pInfo
  42. {
  43.     Float:vPosX,            // Current Vehicle Coord
  44.     Float:vPosY,
  45.     Float:vPosZ,
  46.     Float:iAngle,
  47.     Float:vHP,
  48.     TimeLeft,
  49.     vColor1,
  50.     vColor2,
  51.     Rented,
  52.     vType,                  // Vehicle ID/Type
  53.     Vehicle,
  54.     Panels,
  55.     Doors,
  56.     Lights,
  57.     Tires,
  58. };
  59. new PlayerInfo[MAX_PLAYERS][pInfo];
  60.  
  61. enum rInfo
  62. {
  63.     Float:rPosX,    // Renting Booth Coord
  64.     Float:rPosY,
  65.     Float:rPosZ,
  66.     Float:rAngle,
  67.     Float:vSpawnX,  // Where the Vehicle Spawn
  68.     Float:vSpawnY,
  69.     Float:vSpawnZ,
  70.     Float:vAngle,
  71.     Text3D:Text3D,
  72.     Text3D:rDescription,
  73.     Created,
  74.     Object,
  75. };
  76.  
  77. new RentInfo[MAX_RENTALS][rInfo];
  78. stock split(const strsrc[], strdest[][], delimiter)
  79. {
  80.     new i, li;
  81.     new aNum;
  82.     new len;
  83.     while(i <= strlen(strsrc)){
  84.         if(strsrc[i]==delimiter || i==strlen(strsrc)){
  85.             len = strmid(strdest[aNum], strsrc, li, i, 128);
  86.             strdest[aNum][len] = 0;
  87.             li = i+1;
  88.             aNum++;
  89.         }
  90.         i++;
  91.     }
  92.     return 1;
  93. }
  94.  
  95. CMD:timeleft(playerid, params[])
  96. {
  97.     if(PlayerInfo[playerid][Rented] == 1) {
  98.     new string[128];
  99.     format(string, sizeof(string), "RENTAL{FFFFFF}: You're renting, time left: %d seconds.", PlayerInfo[playerid][TimeLeft]);
  100.     SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
  101.     }
  102.     return 1;
  103. }
  104.  
  105. CMD:rentalmenu(playerid, params[])
  106. {
  107.     if(IsPlayerAdmin(playerid))
  108.     {
  109.         ShowPlayerDialog(playerid, DIALOG_RENTALCREATE, DIALOG_STYLE_LIST, "Creating Rental", "Create Rental\nDelete Closest", "Select", "Cancel");
  110.     }
  111.     else { return 1; }
  112.     return 1;
  113. }
  114.  
  115. CMD:rent(playerid, params[])
  116. {
  117.     for( new idx = 0; idx != MAX_RENTALS; idx++ )
  118.     {
  119.         if(IsPlayerInRangeOfPoint(playerid, 1.2, RentInfo[idx][rPosX], RentInfo[idx][rPosY], RentInfo[idx][rPosZ]))
  120.         {
  121.             new rentalDialog[256];
  122.             if(PlayerInfo[playerid][Rented] != 1)
  123.             {
  124.                 strcat(rentalDialog, ""Vehicle_0_Name"- $"#Vehicle_0_Price#":30 Minute\n");
  125.                 strcat(rentalDialog, ""Vehicle_1_Name"- $"#Vehicle_1_Price#":30 Minute");
  126.                 ShowPlayerDialog(playerid, DIALOG_RENTAL, DIALOG_STYLE_LIST, "Renting", rentalDialog, "Select", "Cancel");
  127.             }
  128.             else
  129.             {
  130.                 ShowPlayerDialog(playerid, DIALOG_UNRENT, DIALOG_STYLE_LIST, "Unrenting", "Unrent Car", "Select", "Cancel");
  131.             }
  132.         }
  133.     }
  134.     return 1;
  135. }
  136.  
  137. public OnVehicleDeath(vehicleid, killerid)
  138. {
  139.     for(new i; i < MAX_PLAYERS; i++)
  140.     {
  141.         if(PlayerInfo[i][vType] == Vehicle_0_ID && PlayerInfo[i][Rented] == 1)
  142.         {
  143.             PlayerInfo[i][TimeLeft] = 0;
  144.             PlayerInfo[i][Rented] = 0;
  145.             SendClientMessage(i, COLOR_RED, "RENTAL{FFFFFF}: You broke your rented car, $"#Vehicle_0_Fine#" has been taken from your account to pay the fine.");
  146.             GivePlayerMoney(i, -Vehicle_0_Fine);
  147.         }
  148.         if(PlayerInfo[i][vType] == Vehicle_1_ID && PlayerInfo[i][Rented] == 1)
  149.         {
  150.             PlayerInfo[i][TimeLeft] = 0;
  151.             PlayerInfo[i][Rented] = 0;
  152.             SendClientMessage(i, COLOR_RED, "RENTAL{FFFFFF}: You broke your rented car, $"#Vehicle_1_Fine#" has been taken from your account to pay the fine.");
  153.             GivePlayerMoney(i, -Vehicle_1_Fine);
  154.         }
  155.     }
  156.     return 1;
  157. }
  158.  
  159. forward EndTiming(playerid);
  160. public EndTiming(playerid)
  161. {
  162.     if(PlayerInfo[playerid][TimeLeft] >= 1)
  163.     {
  164.         new Float: X, Float: Y, Float: Z, Float: A;
  165.         GetVehiclePos(PlayerInfo[playerid][Vehicle], X, Y, Z);
  166.         PlayerInfo[playerid][vPosX] = X, PlayerInfo[playerid][vPosY] = Y, PlayerInfo[playerid][vPosZ] = Z;
  167.         GetVehicleZAngle(PlayerInfo[playerid][Vehicle], A);
  168.         PlayerInfo[playerid][iAngle] = A;
  169.         PlayerInfo[playerid][TimeLeft]-=1;
  170.         new Float: health;
  171.         GetVehicleDamageStatus(PlayerInfo[playerid][Vehicle], PlayerInfo[playerid][Panels], PlayerInfo[playerid][Doors], PlayerInfo[playerid][Lights], PlayerInfo[playerid][Tires]);
  172.         GetVehicleHealth(PlayerInfo[playerid][Vehicle], health);
  173.         PlayerInfo[playerid][vHP] = health;
  174.     }
  175.     else
  176.     {
  177.         KillTimer(unrenttimer[playerid]);
  178.         SendClientMessage(playerid, COLOR_LIGHTGREEN, "RENTAL{FFFFFF}: Unrented.");
  179.         DestroyVehicle(PlayerInfo[playerid][Vehicle]);
  180.         PlayerInfo[playerid][Rented] = 0;
  181.         PlayerInfo[playerid][vPosX] = 0;
  182.         PlayerInfo[playerid][vPosY] = 0;
  183.         PlayerInfo[playerid][vPosZ] = 0;
  184.         PlayerInfo[playerid][iAngle] = 0;
  185.         PlayerInfo[playerid][Rented] = 0;
  186.         new pName[32];
  187.         GetPlayerName(playerid,pName, sizeof(pName));
  188.         new file[64];
  189.         format( file, 64, "Rentals/Users/%s.ini", pName );
  190.         if( fexist( file ) ) { fremove(file); }
  191.     }
  192. }
  193.  
  194. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  195. {
  196.     PlayerInfo[playerid][vColor1] = color1;
  197.     PlayerInfo[playerid][vColor2] = color2;
  198.     return 1;
  199. }
  200.  
  201. public OnFilterScriptInit()
  202. {
  203.     kontolCreated[0] = 0;
  204.     kontolCreated[1] = 0;
  205.     print(" Dynamic Vehicle Renting - with Saving [Cannary2048]");
  206.     LoadRent();
  207.     return 1;
  208. }
  209.  
  210. public OnPlayerSpawn(playerid)
  211. {
  212.     if(PlayerInfo[playerid][Rented] == 1)
  213.     {
  214.         KillTimer(unrenttimer[playerid]);
  215.         unrenttimer[playerid] = SetTimerEx("EndTiming", 1000, true, "i", playerid);
  216.     }
  217.     return 1;
  218. }
  219.  
  220. stock LoadRent()
  221. {
  222.     for( new i = 0; i != MAX_RENTALS; i++ )
  223.     {
  224.         if( RentInfo[i][Created] == 0 )
  225.         {
  226.             new file[64];
  227.             format( file, 64, "Rentals/rental_%d.ini", i );
  228.             if( fexist( file ) )
  229.             {
  230.                 RentInfo[i][Created] = 1;
  231.                 RentInfo[i][rPosX] = dini_Float( file, "X" );
  232.                 RentInfo[i][rPosY] = dini_Float( file, "Y" );
  233.                 RentInfo[i][rPosZ] = dini_Float( file, "Z" );
  234.                 RentInfo[i][rAngle] = dini_Float( file, "A" );
  235.                 RentInfo[i][vSpawnX] = dini_Float( file, "VX" );
  236.                 RentInfo[i][vSpawnY] = dini_Float( file, "VY" );
  237.                 RentInfo[i][vSpawnZ] = dini_Float( file, "VZ" );
  238.                 RentInfo[i][vAngle] = dini_Float( file, "VA" );
  239.                 RentInfo[i][Text3D] = Create3DTextLabel("[{00FFFF}JACKSON RENTING COMPANY{FFFFFF}]\nCheap Car Rental\n {FF0000}/rent{FFFFFF} to rent one!", 0xFFFFFFFF, RentInfo[i][rPosX], RentInfo[i][rPosY], RentInfo[i][rPosZ], 7.0, 0, 0);
  240.                 RentInfo[i][Object] = CreateObject( 2754, RentInfo[i][rPosX], RentInfo[i][rPosY], RentInfo[i][rPosZ]-0.3, 0, 0, RentInfo[i][rAngle]-90);
  241.                 SetObjectMaterialText(RentInfo[i][Object],"Jackson's Junkyard\n And Rental Corp.", 4, OBJECT_MATERIAL_SIZE_128x128, "Arial", 10, 1, 0xFFFFFFFF, 0xFF0000FF,  0);
  242.             }
  243.         }
  244.     }
  245.     return 1;
  246. }
  247.  
  248. stock CreateRentedVehicle(playerid, cartype, time)
  249. {
  250.     for( new i = 0; i != MAX_RENTALS; i++ )
  251.     {
  252.         if(IsPlayerInRangeOfPoint(playerid, 1.2, RentInfo[i][rPosX], RentInfo[i][rPosY], RentInfo[i][rPosZ]))
  253.         {
  254.             if(time == 1)
  255.             {
  256.                 PlayerInfo[playerid][TimeLeft] = 1800;
  257.                 unrenttimer[playerid] = SetTimerEx("EndTiming", 1000, true, "i", playerid);
  258.             }
  259.             if(time == 2)
  260.             {
  261.                 PlayerInfo[playerid][TimeLeft] = 3600;
  262.                 unrenttimer[playerid] = SetTimerEx("EndTiming", 1000, true, "i", playerid);
  263.             }
  264.             PlayerInfo[playerid][vPosX] =   RentInfo[i][vSpawnX];       // Current Vehicle Coord
  265.             PlayerInfo[playerid][vPosY] =   RentInfo[i][vSpawnY];
  266.             PlayerInfo[playerid][vPosZ] =   RentInfo[i][vSpawnZ];
  267.             new Float: X = PlayerInfo[playerid][vPosX],
  268.             Float: Y = PlayerInfo[playerid][vPosY],
  269.             Float: Z = PlayerInfo[playerid][vPosZ],
  270.             Float: A = PlayerInfo[playerid][iAngle];
  271.             PlayerInfo[playerid][iAngle] = RentInfo[i][vAngle];
  272.             PlayerInfo[playerid][vHP] = 1000.0;
  273.             PlayerInfo[playerid][Rented] = 1;
  274.             PlayerInfo[playerid][vType] = cartype;                  // Vehicle ID/Type
  275.             PlayerInfo[playerid][Vehicle] = CreateVehicle(cartype, X, Y, Z, A, 0, 0, -1);
  276.             new pName[32];
  277.             GetPlayerName(playerid,pName, sizeof(pName));
  278.             new file[64];
  279.             format( file, 64, "Rentals/Users/%s.ini", pName );
  280.             if( !fexist( file ) )
  281.             {
  282.                 dini_Create( file );
  283.                 dini_FloatSet( file, "Vehicle X", PlayerInfo[playerid][vPosX] );
  284.                 dini_FloatSet( file, "Vehicle Y", PlayerInfo[playerid][vPosY] );
  285.                 dini_FloatSet( file, "Vehicle Z", PlayerInfo[playerid][vPosZ] );
  286.                 dini_FloatSet( file, "Vehicle A", PlayerInfo[playerid][iAngle] );
  287.                 dini_IntSet( file, "Vehicle ID", PlayerInfo[playerid][vType] );
  288.                 dini_IntSet( file, "Player Time Left", PlayerInfo[playerid][TimeLeft] );
  289.                 dini_FloatSet( file, "Vehicle HP", PlayerInfo[playerid][vHP] );
  290.                 dini_IntSet( file, "Vehicle Color_1", PlayerInfo[playerid][vColor1] );
  291.                 dini_IntSet( file, "Vehicle Color_2", PlayerInfo[playerid][vColor2] );
  292.                 dini_IntSet( file, "Player Renting", PlayerInfo[playerid][Rented] );
  293.                 dini_IntSet( file, "Vehicle Panels", PlayerInfo[playerid][Panels] );
  294.                 dini_IntSet( file, "Vehicle Doors", PlayerInfo[playerid][Doors] );
  295.                 dini_IntSet( file, "Vehicle Lights", PlayerInfo[playerid][Lights] );
  296.                 dini_IntSet( file, "Vehicle Tires", PlayerInfo[playerid][Tires] );
  297.             }
  298.             break;
  299.         }
  300.      }
  301.     return 1;
  302. }
  303.  
  304. stock CreateRental( Float:x, Float:y, Float:z, Float:a, Float: vx, Float: vy, Float: vz, Float: va )
  305. {
  306.     for( new i = 0; i != MAX_RENTALS; i++ )
  307.     {
  308.         if( RentInfo[i][Created] == 0 )
  309.         {
  310.             RentInfo[i][Object] = CreateObject( 2754, x, y, z-0.3, 0, 0, a-90 );
  311.             SetObjectMaterialText(RentInfo[i][Object],"Jackson's Junkyard\n And Rental Corp.", 4, OBJECT_MATERIAL_SIZE_128x128, "Arial", 10, 1, 0xFFFFFFFF, 0xFF0000FF,  0);
  312.             RentInfo[i][Text3D] = Create3DTextLabel("[{00FFFF}JACKSON RENTING COMPANY{FFFFFF}]\nCheap Car Rental\n {FF0000}/rent{FFFFFF} to rent one!", 0xFFFFFFFF, x, y, z, 7.0, 0, 0);
  313.             RentInfo[i][Created] = 1;
  314.             RentInfo[i][rPosX] = x;
  315.             RentInfo[i][rPosY] = y;
  316.             RentInfo[i][rPosZ] = z;
  317.             RentInfo[i][rAngle] = a;
  318.             RentInfo[i][vSpawnX] = vx;
  319.             RentInfo[i][vSpawnY] = vy;
  320.             RentInfo[i][vSpawnZ] = vz;
  321.             RentInfo[i][vAngle] = va;
  322.             new file[64];
  323.             format( file, 64, "Rentals/rental_%d.ini", i );
  324.             if( !fexist( file ) )
  325.             {
  326.                 dini_Create( file );
  327.                 dini_FloatSet( file, "X", RentInfo[i][rPosX] );
  328.                 dini_FloatSet( file, "Y", RentInfo[i][rPosY] );
  329.                 dini_FloatSet( file, "Z", RentInfo[i][rPosZ] );
  330.                 dini_FloatSet( file, "A", RentInfo[i][rAngle] );
  331.                 dini_FloatSet( file, "VX", RentInfo[i][vSpawnX] );
  332.                 dini_FloatSet( file, "VY", RentInfo[i][vSpawnY] );
  333.                 dini_FloatSet( file, "VZ", RentInfo[i][vSpawnZ] );
  334.                 dini_FloatSet( file, "VA", RentInfo[i][vAngle] );
  335.             }
  336.             break;
  337.         }
  338.     }
  339.     return 1;
  340. }
  341.  
  342. stock SaveStats(playerid)
  343. {
  344.     new pName[32];
  345.     GetPlayerName(playerid,pName, sizeof(pName));
  346.     new file[64];
  347.     format( file, 64, "Rentals/Users/%s.ini", pName );
  348.     if( fexist( file ) )
  349.     {
  350.         dini_FloatSet( file, "Vehicle X", PlayerInfo[playerid][vPosX] );
  351.         dini_FloatSet( file, "Vehicle Y", PlayerInfo[playerid][vPosY] );
  352.         dini_FloatSet( file, "Vehicle Z", PlayerInfo[playerid][vPosZ] );
  353.         dini_FloatSet( file, "Vehicle A", PlayerInfo[playerid][iAngle] );
  354.         dini_IntSet( file, "Vehicle ID", PlayerInfo[playerid][vType] );
  355.         dini_IntSet( file, "Player Time Left", PlayerInfo[playerid][TimeLeft] );
  356.         dini_FloatSet( file, "Vehicle HP", PlayerInfo[playerid][vHP] );
  357.         dini_IntSet( file, "Vehicle Color_1", PlayerInfo[playerid][vColor1] );
  358.         dini_IntSet( file, "Vehicle Color_2", PlayerInfo[playerid][vColor2] );
  359.         dini_IntSet( file, "Player Renting", PlayerInfo[playerid][Rented] );
  360.         dini_IntSet( file, "Vehicle Panels", PlayerInfo[playerid][Panels] );
  361.         dini_IntSet( file, "Vehicle Doors", PlayerInfo[playerid][Doors] );
  362.         dini_IntSet( file, "Vehicle Lights", PlayerInfo[playerid][Lights] );
  363.         dini_IntSet( file, "Vehicle Tires", PlayerInfo[playerid][Tires] );
  364.     }
  365.     return 1;
  366. }
  367.  
  368. stock LoadStats(playerid)
  369. {
  370.     new pName[32];
  371.     GetPlayerName(playerid,pName, sizeof(pName));
  372.     new file[64];
  373.     format( file, 64, "Rentals/Users/%s.ini", pName );
  374.     if( fexist( file ) )
  375.     {
  376.         PlayerInfo[playerid][vPosX] = dini_Float( file, "Vehicle X" );
  377.         PlayerInfo[playerid][vPosY] = dini_Float( file, "Vehicle Y" );
  378.         PlayerInfo[playerid][vPosZ] = dini_Float( file, "Vehicle Z" );
  379.         PlayerInfo[playerid][iAngle] = dini_Float( file, "Vehicle A" );
  380.         PlayerInfo[playerid][vType] = dini_Int( file, "Vehicle ID" );
  381.         PlayerInfo[playerid][TimeLeft] = dini_Int( file, "Player Time Left" );
  382.         PlayerInfo[playerid][vHP] = dini_Float( file, "Vehicle HP" );
  383.         PlayerInfo[playerid][vColor1] = dini_Int( file, "Vehicle Color_1" );
  384.         PlayerInfo[playerid][vColor2] = dini_Int( file, "Vehicle Color_2" );
  385.         PlayerInfo[playerid][Rented] = dini_Int( file, "Player Renting");
  386.         PlayerInfo[playerid][Panels] = dini_Int( file, "Vehicle Panels");
  387.         PlayerInfo[playerid][Doors] = dini_Int( file, "Vehicle Doors");
  388.         PlayerInfo[playerid][Lights] = dini_Int( file, "Vehicle Lights");
  389.         PlayerInfo[playerid][Tires] = dini_Int( file, "Vehicle Tires");
  390.         PlayerInfo[playerid][Vehicle] = CreateVehicle(PlayerInfo[playerid][vType], PlayerInfo[playerid][vPosX], PlayerInfo[playerid][vPosY], PlayerInfo[playerid][vPosZ], PlayerInfo[playerid][iAngle], 0,0, 10);
  391.         SetVehicleHealth(PlayerInfo[playerid][Vehicle], PlayerInfo[playerid][vHP]);
  392.         ChangeVehicleColor(PlayerInfo[playerid][Vehicle], PlayerInfo[playerid][vColor1], PlayerInfo[playerid][vColor2]);
  393.         UpdateVehicleDamageStatus(PlayerInfo[playerid][Vehicle], PlayerInfo[playerid][Panels], PlayerInfo[playerid][Doors], PlayerInfo[playerid][Lights], PlayerInfo[playerid][Tires]);
  394.     }
  395.     return 1;
  396. }
  397.  
  398. stock SaveRent()
  399. {
  400.     for( new i = 0; i != MAX_RENTALS; i++ )
  401.     {
  402.         if( RentInfo[i][Created] == 1 )
  403.         {
  404.             new file[64];
  405.             format( file, 64, "Rentals/rental_%d.ini", i );
  406.             if( fexist( file ) )
  407.             {
  408.                 dini_FloatSet( file, "X", RentInfo[i][rPosX] );
  409.                 dini_FloatSet( file, "Y", RentInfo[i][rPosY] );
  410.                 dini_FloatSet( file, "Z", RentInfo[i][rPosZ] );
  411.                 dini_FloatSet( file, "A", RentInfo[i][rAngle] );
  412.                 dini_FloatSet( file, "VX", RentInfo[i][vSpawnX] );
  413.                 dini_FloatSet( file, "VY", RentInfo[i][vSpawnY] );
  414.                 dini_FloatSet( file, "VZ", RentInfo[i][vSpawnZ] );
  415.                 dini_FloatSet( file, "VA", RentInfo[i][vAngle] );
  416.             }
  417.         }
  418.     }
  419.     return 1;
  420. }
  421.  
  422. public OnFilterScriptExit()
  423. {
  424.     SaveRent();
  425.     for( new i = 0; i != MAX_RENTALS; i++ ) { DestroyObject(RentInfo[i][Object]); }
  426.     return 1;
  427. }
  428.  
  429. public OnPlayerDisconnect(playerid, reason)
  430. {
  431.     if(PlayerInfo[playerid][Rented] == 1) {
  432.         KillTimer(unrenttimer[playerid]);
  433.         DestroyVehicle(PlayerInfo[playerid][Vehicle]);
  434.         SaveStats(playerid);
  435.     }
  436.     return 1;
  437. }
  438.  
  439. public OnPlayerConnect(playerid)
  440. {
  441.     LoadStats(playerid);
  442.     if(PlayerInfo[playerid][Rented] == 1) {
  443.     new string[128];
  444.     format(string, sizeof(string), "RENTAL: {FFFFFF}You're renting, time left: %d seconds.", PlayerInfo[playerid][TimeLeft]);
  445.     SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
  446.     }
  447.     return 1;
  448. }
  449.  
  450. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  451. {
  452.     return 1;
  453. }
  454.  
  455. public OnPlayerExitVehicle(playerid, vehicleid)
  456. {
  457.     return 1;
  458. }
  459.  
  460. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  461. {
  462.     if(dialogid == DIALOG_RENTAL)
  463.     {
  464.         if(!response) { return -1; }
  465.         if(listitem == 0)
  466.         {
  467.             ShowPlayerDialog(playerid,DIALOG_RENTAL2, DIALOG_STYLE_LIST, "How long?", "30 Minutes - $"#Vehicle_0_Price#"\n1 Hour - $"#Vehicle_0_Price+500"", "Select", "Cancel");
  468.         }
  469.         if(listitem == 1)
  470.         {
  471.             ShowPlayerDialog(playerid,DIALOG_RENTAL3, DIALOG_STYLE_LIST, "How long?", "30 Minutes - $"#Vehicle_1_Price#"\n1 Hour - $"#Vehicle_1_Price+10"", "Select", "Cancel");
  472.         }
  473.         return 1;
  474.     }
  475.     if(dialogid == DIALOG_UNRENT)
  476.     {
  477.         if(!response) { return -1; }
  478.         PlayerInfo[playerid][TimeLeft] = 0;
  479.         return 1;
  480.     }
  481.     if(dialogid == DIALOG_RENTAL2)
  482.     {
  483.         if(!response) { return -1; }
  484.         if(listitem == 0 && GetPlayerMoney(playerid) > Vehicle_0_Price)
  485.         {
  486.             CreateRentedVehicle(playerid, Vehicle_0_ID, 1);
  487.             GivePlayerMoney(playerid, -Vehicle_0_Price); // Change This!
  488.         }
  489.         else if(GetPlayerMoney(playerid) < Vehicle_0_Price) { return SendClientMessage(playerid, COLOR_RED, "RENTAL{FFFFFF}: Insufficient fund"); }
  490.         if(listitem == 1 && GetPlayerMoney(playerid) > Vehicle_0_Price+500)
  491.         {
  492.             CreateRentedVehicle(playerid, Vehicle_0_ID, 2);
  493.             GivePlayerMoney(playerid, -Vehicle_0_Price-500); // Change This!
  494.         }
  495.         else if(GetPlayerMoney(playerid) < Vehicle_0_Price+500) { return SendClientMessage(playerid, COLOR_RED, "RENTAL{FFFFFF}: Insufficient fund"); }
  496.         return 1;
  497.     }
  498.     if(dialogid == DIALOG_RENTAL3)
  499.     {
  500.         if(!response) { return -1; }
  501.         if(listitem == 0 && GetPlayerMoney(playerid) > Vehicle_1_Price)
  502.         {
  503.             CreateRentedVehicle(playerid, Vehicle_1_ID, 1);
  504.             GivePlayerMoney(playerid, -Vehicle_1_Price-500);
  505.         }
  506.         else if(GetPlayerMoney(playerid) < Vehicle_1_Price) { return SendClientMessage(playerid, COLOR_RED, "RENTAL{FFFFFF}: Insufficient fund"); }
  507.         if(listitem == 1 && GetPlayerMoney(playerid) > Vehicle_1_Price+10)
  508.         {
  509.             CreateRentedVehicle(playerid, Vehicle_1_ID, 2);
  510.             GivePlayerMoney(playerid, -Vehicle_1_Price-10);
  511.         }
  512.         else if(GetPlayerMoney(playerid) < Vehicle_1_Price) { return SendClientMessage(playerid, COLOR_RED, "RENTAL{FFFFFF}: Insufficient fund"); }
  513.         return 1;
  514.     }
  515.     if(dialogid == DIALOG_RENTALCREATE)
  516.     {
  517.         if(!response) { return -1; }
  518.         if(listitem == 0)
  519.         {
  520.             ShowPlayerDialog(playerid, DIALOG_RENTALCREATE2, DIALOG_STYLE_LIST, "Creating Rental", "Set Rental\nSet Vehicle Spawn\nComplete", "Select", "Cancel");
  521.             return 1;
  522.         }
  523.         if(listitem == 1)
  524.         {
  525.             for(new i = 0; i < sizeof(RentInfo); i++)
  526.             {
  527.                 if(IsPlayerInRangeOfPoint(playerid, 4.0, RentInfo[i][rPosX], RentInfo[i][rPosY], RentInfo[i][rPosZ]))
  528.                 {
  529.                     if(RentInfo[i][Created] == 1)
  530.                     {
  531.                         RentInfo[i][Created] = 0;
  532.                         RentInfo[i][rPosX] = 0.0;
  533.                         RentInfo[i][rPosY] = 0.0;
  534.                         RentInfo[i][rPosZ] = 0.0;
  535.                         RentInfo[i][rAngle] = 0.0;
  536.                         RentInfo[i][vSpawnX] = 0.0;
  537.                         RentInfo[i][vSpawnY] = 0.0;
  538.                         RentInfo[i][vSpawnZ] = 0.0;
  539.                         RentInfo[i][vAngle] = 0.0;
  540.                         Delete3DTextLabel(RentInfo[i][Text3D]);
  541.                         DestroyObject(RentInfo[i][Object]);
  542.                         SaveRent();
  543.                     }
  544.                 }
  545.             }
  546.             return 1;
  547.         }
  548.         return 1;
  549.     }
  550.     if(dialogid == DIALOG_RENTALCREATE2)
  551.     {
  552.             if(!response) { return -1; }
  553.             if(listitem == 0)
  554.             {
  555.                 new Float: X, Float: Y, Float: Z, Float: A;
  556.                 GetPlayerPos(playerid, X, Y, Z);
  557.                 GetPlayerFacingAngle(playerid, A);
  558.                 SendClientMessage(playerid, COLOR_LIGHTGREEN, "RENTAL{FFFFFF}: Rental booth is setted.");
  559.                 rX = X;
  560.                 rY = Y;
  561.                 rZ = Z;
  562.                 rA = A;
  563.                 kontolCreated[0] = 1;
  564.             }
  565.             if(listitem == 1)
  566.             {
  567.                 new Float: x, Float: y, Float: z, Float: a;
  568.                 GetPlayerPos(playerid, x, y, z);
  569.                 GetPlayerFacingAngle(playerid, a);
  570.                 SendClientMessage(playerid, COLOR_LIGHTGREEN, "RENTAL{FFFFFF}: Vehicle spawn is setted.");
  571.                 vX = x;
  572.                 vY = y;
  573.                 vZ = z;
  574.                 vA = a;
  575.                 kontolCreated[1] = 1;
  576.             }
  577.             if(listitem == 2)
  578.             {
  579.                 if(kontolCreated[0] == 1 && kontolCreated[1] == 1){
  580.                 CreateRental(rX, rY, rZ, rA, vX, vY, vZ, vA);
  581.                 SaveRent();
  582.                 kontolCreated[0] = 0;
  583.                 kontolCreated[1] = 0;
  584.                 }
  585.                 else { return 0; }
  586.             }
  587.     }
  588.     return 1;
  589. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement