Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*======================================================================================================*
- * This Taxi System is made by Jeffry! *
- * *
- * *
- * Made in April 2010. *
- * *
- * Your Rights: *
- * *
- * -You are allowed to modify this Filterscript, aslong as you DO NOT remove credits or re-upload it. *
- * *
- * -You are NOT allowed to re-upload this Filterscript. *
- * -You are NOT allowed to claim this as your own. *
- * -You are NOT allowed to remove any credits. *
- * *
- * Thank you. *
- * Have fun. I would be happy if you give me /credits. :D *
- * *
- *=======================================================================================================*/
- #include <a_samp>
- #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
- //========================================================================================================================
- //-------------------------Definitions that you may change----------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------------------------
- #define MAX_TAXI_LOCATIONS 200 // Change this if you have more.
- #define MAX_TAXI_NAME 100 // This is the Maximum lenght of the taxi name. Changing is not advised.
- #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.
- #define MINIMUM_PRICE 10000 // I made it to 10 000$ so it fills the Max price over map (-3000 => 3000) to 100 000$
- #define PRINT_ON // Add the "//" infront of it, to disable the printed message when a Taxi is created.
- //------------------------------------------------------------------------------------------------------------------------
- //-------------------------End of the Definitions-------------------------------------------------------------------------
- //========================================================================================================================
- new TaxiID;
- new Float:Taxi_X[MAX_TAXI_LOCATIONS];
- new Float:Taxi_Y[MAX_TAXI_LOCATIONS];
- new Float:Taxi_Z[MAX_TAXI_LOCATIONS];
- new Float:Taxi_Ang[MAX_TAXI_LOCATIONS];
- new Taxi_Int[MAX_TAXI_LOCATIONS];
- new Taxi_Name[MAX_TAXI_LOCATIONS][MAX_TAXI_NAME];
- new Taxi_Exists[MAX_TAXI_LOCATIONS];
- new Float:PricePerKM;
- new MiniPrice;
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" [FS] Advanced Taxi System by Jeffry");
- print("--------------------------------------\n");
- PricePerKM=PRICE_PER_KM;
- MiniPrice=MINIMUM_PRICE;
- // Put your Taxi-Locations here. You find them in: .../scriptfiles/Saved_Taxi_Locs.txt
- // I have also added some locations, if you want to use them, you find them in: Some_Locations.txt
- // Now....have fun with the Taxi! :D
- AddTaxi("The Ship", 2000.6123, 1524.4371, 18.1923, 0.0000, 0);
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n--------------------------------------");
- print(" The Taxi System has been unloaded.");
- print("--------------------------------------\n");
- return 1;
- }
- //===========The Commands============================================================================================================================================
- dcmd_taxi(playerid,params[])
- {
- new taxi, string[128];
- taxi=strval(params[0]);
- if(!strlen(params)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /taxi [Number]");
- if(taxi>TaxiID-1 || taxi<0) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: This location does not exist!");
- if(!IsNumeric(params[0])) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: This location does not exist!");
- new Float:px,Float:py,Float:pz;
- GetPlayerPos(playerid,px,py,pz);
- new Float:price=floatsqroot( ( (Taxi_X[taxi]-px)*(Taxi_X[taxi]-px) ) + ( (Taxi_Y[taxi]-py)*(Taxi_Y[taxi]-py) ) + ( (Taxi_Z[taxi]-pz)*(Taxi_Z[taxi]-pz) ) );
- new price2=(floatround(price*PricePerKM, floatround_round))+MiniPrice;
- if(price2>GetPlayerMoney(playerid))
- {
- format(string,sizeof(string),"ERROR: You don't have enough money. Price: %d $ | Have: %d $ | %d $ more needed.", price2,GetPlayerMoney(playerid), price2-GetPlayerMoney(playerid));
- return SendClientMessage(playerid, 0xFF0000AA, string);
- }
- SetPlayerPos(playerid, Taxi_X[taxi], Taxi_Y[taxi], Taxi_Z[taxi]);
- SetPlayerFacingAngle(playerid, Taxi_Ang[taxi]);
- SetPlayerInterior(playerid, Taxi_Int[taxi]);
- SetCameraBehindPlayer(playerid);
- GivePlayerMoney(playerid, -price2);
- format(string,sizeof(string),"Thank you for the %d $. Enjoy your stay at ''%s''", price2,Taxi_Name[taxi]);
- SendClientMessage(playerid, 0xFFFF6EFF, string);
- return 1;
- }
- dcmd_tsave(playerid,params[])
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: You need to be a RCON-Admin to save Taxi-Locations.");
- if(!strlen(params)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /tsave [Locationname]");
- new string[128], name[MAX_TAXI_NAME], Index;
- name=strtok(params, Index);
- new Float:px,Float:py,Float:pz, Float:A, Int, File:SaveLog;
- GetPlayerPos(playerid,px,py,pz);
- GetPlayerFacingAngle(playerid, A);
- Int=GetPlayerInterior(playerid);
- 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);
- SendClientMessage(playerid, 0xFF9900AA, string);
- format(string,sizeof(string),"Taxi %d saved to ''Saved_Taxi_Locs.txt''. Add it to Taxi.pwn !", TaxiID);
- SendClientMessage(playerid, 0xFFFFFFFF, string);
- format(string, sizeof(string), "AddTaxi(\"%s\", %0.4f, %0.4f, %0.4f, %0.4f, %d);\r\n", params[0], px, py, pz, A, Int);
- SaveLog=fopen("Saved_Taxi_Locs.txt", io_append);
- fwrite(SaveLog, string);
- fclose(SaveLog);
- AddTaxi(name, px, py, pz, A, Int);
- return 1;
- }
- dcmd_locations(playerid,params[])
- {
- if(!strlen(params)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /locations [Page]");
- new taxi = strval(params[0]); new string[128], name[MAX_TAXI_NAME];
- if(taxi<0) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Invalid Page.");
- if(taxi>(MAX_TAXI_LOCATIONS/8) || Taxi_Exists[taxi*8]!=1) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Invalid Page.");
- if(!IsNumeric(params[0])) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Invalid Page.");
- format(string, sizeof(string), "Welcome to the Taxi-Locations [Page: %d]", taxi);
- SendClientMessage(playerid, 0xFF0000AA, string);
- for(new i=(taxi*8); i<(taxi*8)+8; i++)
- {
- if(i>MAX_TAXI_LOCATIONS || Taxi_Exists[i]!=1)
- {
- format(string, sizeof(string), "Type /locations %d to see the previous page.",taxi-1);
- SendClientMessage(playerid, 0xFF9900AA, string);
- return 1;
- }
- name=Taxi_Name[i];
- new Float:px,Float:py,Float:pz;
- GetPlayerPos(playerid,px,py,pz);
- new Float:price=floatsqroot( ( (Taxi_X[i]-px)*(Taxi_X[i]-px) ) + ( (Taxi_Y[i]-py)*(Taxi_Y[i]-py) ) + ( (Taxi_Z[i]-pz)*(Taxi_Z[i]-pz) ) );
- new price2=(floatround(price*PricePerKM, floatround_round))+MiniPrice;
- format(string, sizeof(string), "[%d] %s (Price: %d $)", i, name, price2);
- SendClientMessage(playerid, 0xFFFFFFFF, string);
- if(i<=7 && Taxi_Exists[i+1]!=1)
- {
- return 1;
- }
- if(i==(taxi*8)+7 && Taxi_Exists[i+1]!=1)
- {
- format(string, sizeof(string), "Type /locations %d to see the previous page.",taxi-1);
- SendClientMessage(playerid, 0xFF9900AA, string);
- return 1;
- }
- if(i==7)
- {
- format(string, sizeof(string), "Type /locations %d to see the next page.",taxi+1);
- SendClientMessage(playerid, 0xFF9900AA, string);
- return 1;
- }
- }
- format(string, sizeof(string), "Type /locations %d to see the next page. Type /locations %d to see the previous page.", taxi+1,taxi-1);
- SendClientMessage(playerid, 0xFF9900AA, string);
- return 1;
- }
- dcmd_setkmprice(playerid,params[])
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Only RCON-Admins can change the kilometer price.");
- if(!strlen(params)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /setkmprice [Price]");
- if(params[0]>10000000 || params[0]<0) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Invalid Price!");
- PricePerKM=strval(params[0]);
- new string[128], name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(string,sizeof(string),"[TAXI] Administrator %s (ID:%d) has set the Kilometer Price to %0.0f $ .", name, playerid, PricePerKM);
- SendClientMessage(playerid, 0xFF9900AA, string);
- return 1;
- }
- dcmd_setminimum(playerid,params[])
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Only RCON-Admins can change the minimum price.");
- if(!strlen(params)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /setminimum [Price]");
- if(params[0]>10000000 || params[0]<0) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Invalid Price!");
- MiniPrice=strval(params[0]);
- new string[128], name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(string,sizeof(string),"[TAXI] Administrator %s (ID:%d) has set the Minimum Price to %d $ .", name, playerid, MiniPrice);
- SendClientMessage(playerid, 0xFF9900AA, string);
- return 1;
- }
- //==================================================================================================================================================================
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(taxi,4,cmdtext);
- dcmd(tsave,5,cmdtext);
- dcmd(locations,9,cmdtext);
- dcmd(setkmprice,10,cmdtext);
- dcmd(setminimum,10,cmdtext);
- return 0;
- }
- /*
- * First version released by mike, this one created by DracoBlue
- * Has also a fix to use "-" and "+" in the beginning of the number.
- */
- stock IsNumeric(const string[]) {
- new length=strlen(string);
- if (length==0) return false;
- for (new i = 0; i < length; i++) {
- if (
- (string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+') // Not a number,'+' or '-'
- || (string[i]=='-' && i!=0) // A '-' but not at first.
- || (string[i]=='+' && i!=0) // A '+' but not at first.
- ) return false;
- }
- if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
- return true;
- }
- /*
- * Originally created by mabako, tuned by DracoBlue
- */
- AddTaxi(Name[MAX_TAXI_NAME], Float:TaxiX, Float:TaxiY, Float:TaxiZ, Float:TaxiAng, TaxiInt)
- {
- Taxi_Name[TaxiID]=Name;
- Taxi_X[TaxiID]=TaxiX;
- Taxi_Y[TaxiID]=TaxiY;
- Taxi_Z[TaxiID]=TaxiZ;
- Taxi_Ang[TaxiID]=TaxiAng;
- Taxi_Int[TaxiID]=TaxiInt;
- Taxi_Exists[TaxiID]=1;
- #if defined PRINT_ON
- print("------------------------------Taxi--------------------------------------");
- printf("Taxi %d (%s) sucessfully created!", TaxiID, Name);
- printf("X: %0.4f | Y: %0.4f | Z: %0.4f | Angle: %0.4f | Interior: %d", TaxiX, TaxiY, TaxiZ, TaxiAng, TaxiInt);
- print("------------------------------------------------------------------------");
- print(" ");
- #endif
- TaxiID++;
- }
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement