Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- // ---------------------------------------
- Incorporated Gaming Release.
- DO NOT REMOVE THE ABOVE OR ANY CREDITS.
- I_Checkpoint.
- By Snowman12.
- // ---------------------------------------
- */
- #if defined I_Checkpoint included
- #endinput
- #endif
- #define I_Checkpoint included
- #include <streamer>
- #include <YSI\y_hooks>
- #include <YSI\y_ini>
- #include <a_samp>
- #if !defined _streamer_included
- #error You will be needing to download streamer.inc.
- #endif
- #define INCLUDE_REVISION (2)
- #define MAX_CHECKPOINTS (300)
- #define INVALID_CHECKPOINT_ID (0xFFFF)
- #define CHECKPOINT_LOCATION "Checkpoints/check%d.ini"
- #if !defined COL_YELLOW
- #define COL_YELLOW "{F2FF00}"
- #endif
- /* CHANGE LOG */
- /*
- R1 - Release.
- R2 -
- Saving/Loading System Y_INI.
- DestroyDynamicCheckpoint added.
- Fixed some bugs.
- */
- /*
- native CreateDynamicCheckpoint(CheckpointName[28], Float: X, Float: Y, Float: Z, Float: Size, Float: EX, Float: EY, Float: EZ, Interior = -1, EInterior = -1);
- native DestroyDynamicCheckpoint(ID);
- */
- forward loadCheckpoints_data(ID, name[], value[]);
- enum E_CHECKPOINT_INFO
- {
- E_CHECKPOINT_NAME[30],
- Text3D: E_LABEL,
- E_CHECKPOINT,
- bool: E_CREATED,
- Float: E_LOCX,
- Float: E_LOCY,
- Float: E_LOCZ,
- Float: E_SIZE,
- Float: E_ENTER_X,
- Float: E_ENTER_Y,
- Float: E_ENTER_Z,
- E_INTERIOR,
- E_ENTER_INTERIOR,
- };
- new CheckpointInfo[MAX_CHECKPOINTS][E_CHECKPOINT_INFO];
- hook OnGameModeInit()
- {
- print("====================================");
- print("| CHECKPOINT CREATOR LOADED |");
- print("| MAX CHECKPOINTS: %d |");
- print("| (c) Incorporated Gaming 2011 |");
- printf("| VERSION: R%d |",INCLUDE_REVISION);
- print("====================================");
- return 1;
- }
- CreateDynamicCheckpoint(CheckpointName[28], Float: X, Float: Y, Float: Z, Float: Size, Float: EX, Float: EY, Float: EZ, Interior = -1, EInterior = -1)
- {
- new ID = GetFreeCheckpointSlot();
- new szString[50];
- if(ID != INVALID_CHECKPOINT_ID)
- {
- format(szString,sizeof(szString),""COL_YELLOW"Checkpoint:{FFFFFF}\n%s",CheckpointName);
- format(CheckpointInfo[ID][E_CHECKPOINT_NAME], 30, "%s", CheckpointName);
- CheckpointInfo[ID][E_CHECKPOINT] = CreateDynamicCP(X, Y, Z, Size, VirtualWorld, Interior);
- CheckpointInfo[ID][E_LABEL] = Create3DTextLabel(szString,0xFFFFFFFF, X, Y, Z, 15.0, 0);
- CheckpointInfo[ID][E_LOCX] = X, CheckpointInfo[ID][E_LOCY] = Y, CheckpointInfo[ID][E_LOCZ] = Z;
- CheckpointInfo[ID][E_CREATED] = true;
- CheckpointInfo[ID][E_SIZE] = Size;
- CheckpointInfo[ID][E_ENTER_X] = EX, CheckpointInfo[ID][E_ENTER_Y], CheckpointInfo[ID][E_ENTER_Z];
- CheckpointInfo[ID][E_INTERIOR] = Interior;
- CheckpointInfo[ID][E_ENTER_INTERIOR] = EInterior;
- format(szString, sizeof(szString), CHECKPOINT_LOCATION, ID);
- new INI:File;
- iFile = INI_Open(szString);
- INI_SetTag(iFile, "Checkpoint Information");
- INI_WriteString(iFile, "CheckpointName",CheckpointName);
- INI_WriteFloat(iFile, "X", X);
- INI_WriteFloat(iFile, "Y", Y);
- INI_WriteFloat(iFile, "Z", Z);
- INI_WriteFloat(iFile, "Size", Size);
- INI_WriteFloat(iFile, "EX", EX);
- INI_WriteFloat(iFile, "EY", EY);
- INI_WriteFloat(iFile, "EZ", EZ);
- INI_WriteInt(iFile, "Interior", Interior);
- INI_WriteInt(iFile, "EnterInterior", EInterior);
- INI_Close(iFile);
- return ID;
- }
- return INVALID_CHECKPOINT_ID;
- }
- DestroyDynamicCheckpoint(ID)
- {
- if(!CheckpointInfo[ID][E_CREATED])
- return 0;
- static szString[30];
- format(szString,28,CHECKPOINT_LOCATION,ID);
- fremove(szString);
- DestroyDynamicCP(CheckpointInfo[ID][E_CHECKPOINT]);
- Delete3DTextLabel(CheckpointInfo[ID][E_LABEL]);
- CheckpointInfo[ID][E_CREATED] = false;
- return 1;
- }
- hook OnPlayerEnterDynamicCP(playerid, checkpointid)
- {
- for(new i; i < MAX_CHECKPOINTS; i++)
- {
- if(CheckpointInfo[i][E_CHECKPOINT] == checkpointid)
- {
- if(CheckpointInfo[i][E_ENTER_INTERIOR] >= 1)
- {
- SetPlayerInterior(playerid, CheckpointInfo[i][E_ENTER_INTERIOR]);
- }
- SetPlayerPos(playerid, CheckpointInfo[i][E_ENTER_X], CheckpointInfo[i][E_ENTER_Y], CheckpointInfo[i][E_ENTER_Z]);
- }
- }
- return 1;
- }
- stock strmatch(const str1[], const str2[])
- {
- if ((strcmp(str1, str2, true, strlen(str2)) == 0) && (strlen(str2) == strlen(str1))) return true;
- return false;
- }
- stock GetFreeCheckpointSlot()
- {
- for(new i; i < MAX_CHECKPOINTS; i++)
- {
- if(!CheckpointInfo[i][E_CREATED])
- return i;
- }
- return INVALID_CHECKPOINT_ID;
- }
- stock LoadCheckpointsFromFile()
- {
- new
- iFile[50]
- ;
- for(new i; i < MAX_CHECKPOINTS; i++)
- {
- format(iFile, 28, CHECKPOINT_LOCATION, i);
- if(fexist(iFile))
- {
- INI_ParseFile(iFile, "loadCheckpoints_%s", .bExtra = true, .extra = i);
- CheckpointInfo[i][E_CHECKPOINT] = CreateDynamicCP(CheckpointInfo[i][E_LOCX],CheckpointInfo[i][E_LOCY],CheckpointInfo[i][E_LOCZ],CheckpointInfo[i][E_SIZE], -1, CheckpointInfo[i][E_INTERIOR]);
- format(iFile, sizeof(iFile), ""COL_YELLOW"Checkpoint:{FFFFFF}\n%s",CheckpointInfo[i][E_CHECKPOINT_NAME]);
- CheckpointInfo[i][E_LABEL] = Create3DTextLabel(iFile, 0xFFFFFFFF, CheckpointInfo[i][E_LOCX], CheckpointInfo[i][E_LOCY], CheckpointInfo[i][E_LOCZ], 15.0, 0);
- CheckpointInfo[i][E_CREATED] = true;
- }
- }
- return 1;
- }
- public loadCheckpoints_data(ID, name[], value[])
- {
- if(strmatch(name, "CheckpointName")) format(CheckpointInfo[ID][E_CHECKPOINT_NAME], 28, "%s", value);
- if(strmatch(name, "X")) CheckpointInfo[ID][E_LOCX] = floatstr(value);
- if(strmatch(name, "Y")) CheckpointInfo[ID][E_LOCY] = floatstr(value);
- if(strmatch(name, "Z")) CheckpointInfo[ID][E_LOCZ] = floatstr(value);
- if(strmatch(name, "Size")) CheckpointInfo[ID][E_SIZE] = floatstr(value);
- if(strmatch(name, "EX")) CheckpointInfo[ID][E_ENTER_X] = floatstr(value);
- if(strmatch(name, "EY")) CheckpointInfo[ID][E_ENTER_Y] = floatstr(value);
- if(strmatch(name, "EZ")) CheckpointInfo[ID][E_ENTER_Z] = floatstr(value);
- if(strmatch(name, "Interior")) CheckpointInfo[ID][E_INTERIOR] = strval(value);
- if(strmatch(name, "EnterInterior")) CheckpointInfo[ID][E_ENTER_INTERIOR] = strval(value);
- }
Advertisement
Add Comment
Please, Sign In to add comment