Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //========================================================================================================================
- //-------------------------CopyRight by HireMe (PPSV)---------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------------------------
- //This script saves X Y Z positions and the angle to.---------------------------------------------------------------------
- //Because this script saves the Angle it is very usefull for saving positions for vehicles.-------------------------------
- //USAGE: go to the place you want to save and put your char in the right angle then type: /saveplace [Locationname]-------
- //------------------------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------------------------
- //========================================================================================================================
- #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_POSITION_LOCATIONS 200 // Change this if you have more.
- #define MAX_POSITION_NAME 100 // This is the Maximum lenght of the Position name. Changing is not advised.
- #define PRINT_ON // Add the "//" infront of it, to disable the printed message when a Position is created.
- //------------------------------------------------------------------------------------------------------------------------
- //-------------------------End of the Definitions-------------------------------------------------------------------------
- //========================================================================================================================
- new PositionID;
- new Float:Position_X[MAX_POSITION_LOCATIONS];
- new Float:Position_Y[MAX_POSITION_LOCATIONS];
- new Float:Position_Z[MAX_POSITION_LOCATIONS];
- new Float:Position_Ang[MAX_POSITION_LOCATIONS];
- new Position_Int[MAX_POSITION_LOCATIONS];
- new Position_Name[MAX_POSITION_LOCATIONS][MAX_POSITION_NAME];
- new Position_Exists[MAX_POSITION_LOCATIONS];
- //===========The Commands============================================================================================================================================
- dcmd_saveplace(playerid,params[])
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: You need to be a RCON-Admin to save Position-Locations.");
- if(!strlen(params)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /saveplace [Locationname]");
- new string[128], name[MAX_POSITION_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),"Position %d added: Name: %s | X: %0.4f | Y: %0.4f | Z: %0.4f | Angle: %0.4f | Interior: %d", PositionID, params[0], px, py, pz, A, Int);
- SendClientMessage(playerid, 0xFF9900AA, string);
- format(string,sizeof(string),"Position %d saved to ''Saved_Position_Locs.txt''. Add it to Position.pwn !", PositionID);
- SendClientMessage(playerid, 0xFFFFFFFF, string);
- format(string, sizeof(string), "Position(\"%s\", %0.4f, %0.4f, %0.4f, %0.4f, %d);\r\n", params[0], px, py, pz, A, Int);
- SaveLog=fopen("Saved_Position_Locs.txt", io_append);
- fwrite(SaveLog, string);
- fclose(SaveLog);
- AddPosition(name, px, py, pz, A, Int);
- return 1;
- }
- //==================================================================================================================================================================
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(saveplace,9,cmdtext);
- return 0;
- }
- 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;
- }
- AddPosition(Name[MAX_POSITION_NAME], Float:PositionX, Float:PositionY, Float:PositionZ, Float:PositionAng, PositionInt)
- {
- Position_Name[PositionID]=Name;
- Position_X[PositionID]=PositionX;
- Position_Y[PositionID]=PositionY;
- Position_Z[PositionID]=PositionZ;
- Position_Ang[PositionID]=PositionAng;
- Position_Int[PositionID]=PositionInt;
- Position_Exists[PositionID]=1;
- #if defined PRINT_ON
- print("------------------------------Position--------------------------------------");
- printf("Position %d (%s) sucessfully created!", PositionID, Name);
- printf("X: %0.4f | Y: %0.4f | Z: %0.4f | Angle: %0.4f | Interior: %d", PositionX, PositionY, PositionZ, PositionAng, PositionInt);
- print("------------------------------------------------------------------------");
- print(" ");
- #endif
- PositionID++;
- }
- 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