JeffryUGP

[FS] Advanced Taxi System by Jeffry - (Without Money)

Jul 25th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 11.76 KB | None | 0 0
  1. /*======================================================================================================*
  2. * This Taxi System is made by Jeffry!                                                                   *
  3. *                                                                                                       *
  4. *                                                                                                       *
  5. * Made in April 2010.                                                                                   *
  6. *                                                                                                       *
  7. * Your Rights:                                                                                          *
  8. *                                                                                                       *
  9. * -You are allowed to modify this Filterscript, aslong as you DO NOT remove credits or re-upload it.    *
  10. *                                                                                                       *
  11. * -You are NOT allowed to re-upload this Filterscript.                                                  *
  12. * -You are NOT allowed to claim this as your own.                                                       *
  13. * -You are NOT allowed to remove any credits.                                                           *
  14. *                                                                                                       *
  15. * Thank you.                                                                                            *
  16. * Have fun. I would be happy if you give me /credits.  :D                                               *
  17. *                                                                                                       *
  18. *=======================================================================================================*/
  19.  
  20. #include <a_samp>
  21. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  22.  
  23. //========================================================================================================================
  24. //-------------------------Definitions that you may change----------------------------------------------------------------
  25. //------------------------------------------------------------------------------------------------------------------------
  26. #define MAX_TAXI_LOCATIONS 200     // Change this if you have more.
  27. #define MAX_TAXI_NAME 100         // This is the Maximum lenght of the taxi name. Changing is not advised.
  28. #define PRICE_PER_KM 10.60655    // I decided to make it to 10.60655$ as it will cost 90 000$ from one end to the other.
  29. #define MINIMUM_PRICE 10000     // I made it to 10 000$ so it fills the Max price over map (-3000 => 3000) to 100 000$
  30. #define PRINT_ON               // Add the "//" infront of it, to disable the printed message when a Taxi is created.
  31. //------------------------------------------------------------------------------------------------------------------------
  32. //-------------------------End of the Definitions-------------------------------------------------------------------------
  33. //========================================================================================================================
  34.  
  35. new TaxiID;
  36. new Float:Taxi_X[MAX_TAXI_LOCATIONS];
  37. new Float:Taxi_Y[MAX_TAXI_LOCATIONS];
  38. new Float:Taxi_Z[MAX_TAXI_LOCATIONS];
  39. new Float:Taxi_Ang[MAX_TAXI_LOCATIONS];
  40. new Taxi_Int[MAX_TAXI_LOCATIONS];
  41. new Taxi_Name[MAX_TAXI_LOCATIONS][MAX_TAXI_NAME];
  42. new Taxi_Exists[MAX_TAXI_LOCATIONS];
  43. new Float:PricePerKM;
  44. new MiniPrice;
  45.  
  46. public OnFilterScriptInit()
  47. {
  48.     print("\n--------------------------------------");
  49.     print(" [FS] Advanced Taxi System by Jeffry");
  50.     print("--------------------------------------\n");
  51.     PricePerKM=PRICE_PER_KM;
  52.     MiniPrice=MINIMUM_PRICE;
  53.    
  54.     // Put your Taxi-Locations here. You find them in: .../scriptfiles/Saved_Taxi_Locs.txt
  55.     // I have also added some locations, if you want to use them, you find them in:  Some_Locations.txt
  56.     // Now....have fun with the Taxi! :D
  57.     AddTaxi("The Ship", 2000.6123, 1524.4371, 18.1923, 0.0000, 0);
  58.    
  59.     return 1;
  60. }
  61.  
  62. public OnFilterScriptExit()
  63. {
  64.     print("\n--------------------------------------");
  65.     print(" The Taxi System has been unloaded.");
  66.     print("--------------------------------------\n");
  67.     return 1;
  68. }
  69.  
  70. //===========The Commands============================================================================================================================================
  71. dcmd_taxi(playerid,params[])
  72. {
  73.     new taxi, string[128];
  74.     taxi=strval(params[0]);
  75.     if(!strlen(params)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /taxi [Number]");
  76.     if(taxi>TaxiID-1 || taxi<0) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: This location does not exist!");
  77.     if(!IsNumeric(params[0])) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: This location does not exist!");
  78.     SetPlayerPos(playerid, Taxi_X[taxi], Taxi_Y[taxi], Taxi_Z[taxi]);
  79.     SetPlayerFacingAngle(playerid, Taxi_Ang[taxi]);
  80.     SetPlayerInterior(playerid, Taxi_Int[taxi]);
  81.     SetCameraBehindPlayer(playerid);
  82.    
  83.     format(string,sizeof(string),"Enjoy your stay at ''%s''", price2,Taxi_Name[taxi]);
  84.     SendClientMessage(playerid, 0xFFFF6EFF, string);
  85.     return 1;
  86. }
  87.  
  88. dcmd_tsave(playerid,params[])
  89. {
  90.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: You need to be a RCON-Admin to save Taxi-Locations.");
  91.     if(!strlen(params)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /tsave [Locationname]");
  92.     new string[128], name[MAX_TAXI_NAME], Index;
  93.     name=strtok(params, Index);
  94.     new Float:px,Float:py,Float:pz, Float:A, Int, File:SaveLog;
  95.     GetPlayerPos(playerid,px,py,pz);
  96.     GetPlayerFacingAngle(playerid, A);
  97.     Int=GetPlayerInterior(playerid);
  98.     format(string,sizeof(string),"Taxi %d added:  Name: %s | X: %0.4f | Y: %0.4f | Z: %0.4f | Angle: %0.4f | Interior: %d", TaxiID, params[0], px, py, pz, A, Int);
  99.     SendClientMessage(playerid, 0xFF9900AA, string);
  100.     format(string,sizeof(string),"Taxi %d saved to ''Saved_Taxi_Locs.txt''. Add it to Taxi.pwn !", TaxiID);
  101.     SendClientMessage(playerid, 0xFFFFFFFF, string);
  102.     format(string, sizeof(string), "AddTaxi(\"%s\", %0.4f, %0.4f, %0.4f, %0.4f, %d);\r\n", params[0], px, py, pz, A, Int);
  103.     SaveLog=fopen("Saved_Taxi_Locs.txt", io_append);
  104.     fwrite(SaveLog, string);
  105.     fclose(SaveLog);
  106.     AddTaxi(name, px, py, pz, A, Int);
  107.     return 1;
  108. }
  109.  
  110. dcmd_locations(playerid,params[])
  111. {
  112.     if(!strlen(params)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /locations [Page]");
  113.     new taxi = strval(params[0]); new string[128], name[MAX_TAXI_NAME];
  114.     if(taxi<0) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Invalid Page.");
  115.     if(taxi>(MAX_TAXI_LOCATIONS/8) || Taxi_Exists[taxi*8]!=1) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Invalid Page.");
  116.     if(!IsNumeric(params[0])) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Invalid Page.");
  117.     format(string, sizeof(string), "Welcome to the Taxi-Locations [Page: %d]", taxi);
  118.     SendClientMessage(playerid, 0xFF0000AA, string);
  119.     for(new i=(taxi*8); i<(taxi*8)+8; i++)
  120.     {
  121.         if(i>MAX_TAXI_LOCATIONS || Taxi_Exists[i]!=1)
  122.         {
  123.             format(string, sizeof(string), "Type /locations %d to see the previous page.",taxi-1);
  124.             SendClientMessage(playerid, 0xFF9900AA, string);
  125.             return 1;
  126.         }
  127.         name=Taxi_Name[i];
  128.         format(string, sizeof(string), "[%d] %s", i, name);
  129.         SendClientMessage(playerid, 0xFFFFFFFF, string);
  130.         if(i<=7 && Taxi_Exists[i+1]!=1)
  131.         {
  132.             return 1;
  133.         }
  134.         if(i==(taxi*8)+7 && Taxi_Exists[i+1]!=1)
  135.         {
  136.             format(string, sizeof(string), "Type /locations %d to see the previous page.",taxi-1);
  137.             SendClientMessage(playerid, 0xFF9900AA, string);
  138.             return 1;
  139.         }
  140.         if(i==7)
  141.         {
  142.             format(string, sizeof(string), "Type /locations %d to see the next page.",taxi+1);
  143.             SendClientMessage(playerid, 0xFF9900AA, string);
  144.             return 1;
  145.         }
  146.     }
  147.     format(string, sizeof(string), "Type /locations %d to see the next page. Type /locations %d to see the previous page.", taxi+1,taxi-1);
  148.     SendClientMessage(playerid, 0xFF9900AA, string);
  149.     return 1;
  150. }
  151.  
  152. dcmd_setkmprice(playerid,params[])
  153. {
  154.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Only RCON-Admins can change the kilometer price.");
  155.     if(!strlen(params)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /setkmprice [Price]");
  156.     if(params[0]>10000000 || params[0]<0) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Invalid Price!");
  157.     PricePerKM=strval(params[0]);
  158.     new string[128], name[MAX_PLAYER_NAME];
  159.     GetPlayerName(playerid, name, sizeof(name));
  160.     format(string,sizeof(string),"[TAXI] Administrator %s (ID:%d) has set the Kilometer Price to %0.0f $ .", name, playerid, PricePerKM);
  161.     SendClientMessage(playerid, 0xFF9900AA, string);
  162.     return 1;
  163. }
  164.  
  165. dcmd_setminimum(playerid,params[])
  166. {
  167.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Only RCON-Admins can change the minimum price.");
  168.     if(!strlen(params)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /setminimum [Price]");
  169.     if(params[0]>10000000 || params[0]<0) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Invalid Price!");
  170.     MiniPrice=strval(params[0]);
  171.     new string[128], name[MAX_PLAYER_NAME];
  172.     GetPlayerName(playerid, name, sizeof(name));
  173.     format(string,sizeof(string),"[TAXI] Administrator %s (ID:%d) has set the Minimum Price to %d $ .", name, playerid, MiniPrice);
  174.     SendClientMessage(playerid, 0xFF9900AA, string);
  175.     return 1;
  176. }
  177. //==================================================================================================================================================================
  178.  
  179. public OnPlayerCommandText(playerid, cmdtext[])
  180. {
  181.     dcmd(taxi,4,cmdtext);
  182.     dcmd(tsave,5,cmdtext);
  183.     dcmd(locations,9,cmdtext);
  184.     dcmd(setkmprice,10,cmdtext);
  185.     dcmd(setminimum,10,cmdtext);
  186.     return 0;
  187. }
  188.  
  189. /*
  190.  * First version released by mike, this one created by DracoBlue
  191.  * Has also a fix to use "-" and "+" in the beginning of the number.
  192.  */
  193. stock IsNumeric(const string[]) {
  194.     new length=strlen(string);
  195.     if (length==0) return false;
  196.     for (new i = 0; i < length; i++) {
  197.         if (
  198.         (string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+') // Not a number,'+' or '-'
  199.         || (string[i]=='-' && i!=0)                                             // A '-' but not at first.
  200.         || (string[i]=='+' && i!=0)                                             // A '+' but not at first.
  201.         ) return false;
  202.     }
  203.     if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
  204.     return true;
  205. }
  206. /*
  207.  * Originally created by mabako, tuned by DracoBlue
  208.  */
  209.  
  210. AddTaxi(Name[MAX_TAXI_NAME], Float:TaxiX, Float:TaxiY, Float:TaxiZ, Float:TaxiAng, TaxiInt)
  211. {
  212.     Taxi_Name[TaxiID]=Name;
  213.     Taxi_X[TaxiID]=TaxiX;
  214.     Taxi_Y[TaxiID]=TaxiY;
  215.     Taxi_Z[TaxiID]=TaxiZ;
  216.     Taxi_Ang[TaxiID]=TaxiAng;
  217.     Taxi_Int[TaxiID]=TaxiInt;
  218.     Taxi_Exists[TaxiID]=1;
  219.     #if defined PRINT_ON
  220.     print("------------------------------Taxi--------------------------------------");
  221.     printf("Taxi %d (%s) sucessfully created!", TaxiID, Name);
  222.     printf("X: %0.4f | Y: %0.4f | Z: %0.4f | Angle: %0.4f | Interior: %d", TaxiX, TaxiY, TaxiZ, TaxiAng, TaxiInt);
  223.     print("------------------------------------------------------------------------");
  224.     print(" ");
  225.     #endif
  226.     TaxiID++;
  227. }
  228.  
  229. strtok(const string[], &index)
  230. {
  231.     new length = strlen(string);
  232.     while ((index < length) && (string[index] <= ' '))
  233.     {
  234.         index++;
  235.     }
  236.  
  237.     new offset = index;
  238.     new result[20];
  239.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  240.     {
  241.         result[index - offset] = string[index];
  242.         index++;
  243.     }
  244.     result[index - offset] = EOS;
  245.     return result;
  246. }
Add Comment
Please, Sign In to add comment