Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*====================================================================================================
- Checkpoint: Easy checkpoint management.
- Author:
- * AnthonyDaSexy
- Version:
- * 1.2.3
- Last Updated:
- * 01.08.2016
- Credits:
- * SA:MP Team - For creating SA:MP obviously.
- * Ash. - The include was inspired by his.
- * Yashas - His modified version of zcmd (izcmd) was used in the example script.
- Description:
- * More functionality and features for checkpoints. Easy management, serversided and much more.
- Warranties:
- * This include is provided as is, no warranties whatsoever.
- Functions:
- * native SetPlayerCheckpoint(playerid, Float:x, Float:y, Float:z, Float:size, cp_id = UNUSED_CHECKPOINT_ID);
- * native DisablePlayerCheckpoint(playerid);
- * native IsValidCheckpoint(playerid);
- * native GetPlayerCheckpointId(playerid);
- * native GetPlayerCheckpointPos(playerid, &Float:x, &Float:y, &Float:z);
- * native GetPlayerCheckpointSize(playerid, &Float:size);
- * native IsPlayerInRangeOfCheckpoint(playerid, Float:range);
- * native Float:GetPlayerDistanceFromCheckpoint(playerid);
- * native SetPlayerRaceCheckpoint(playerid, type, Float:x, Float:y, Float:z, Float:nextx, Float:nexty, Float:nextz, Float:size, cp_id = UNUSED_CHECKPOINT_ID);
- * native DisablePlayerRaceCheckpoint(playerid);
- * native IsValidRaceCheckpoint(playerid);
- * native GetPlayerRaceCheckpointId(playerid);
- * native GetPlayerRaceCheckpointPos(playerid, &Float:x, &Float:y, &Float:z);
- * native GetPlayerRaceCheckpointNextPos(playerid, &Float:nextx, &Float:nexty, &Float:nextz);
- * native GetPlayerRaceCheckpointSize(playerid, &Float:size);
- * native IsPlayerInRangeOfRaceCheckpoint(playerid, Float:range);
- * native Float:GetDistanceFromRaceCheckpoint(playerid);
- Callbacks:
- * native OnPlayerCheckpointSet(playerid);
- * native OnPlayerCheckpointDisable(playerid);
- * native OnPlayerRaceCheckpointSet(playerid);
- * native OnPlayerRaceCheckpointDisable(playerid);
- Hooked Callbacks:
- * native OnPlayerConnect(playerid);
- * native OnPlayerEnterCheckpoint(playerid);
- * native OnPlayerLeaveCheckpoint(playerid);
- * native OnPlayerEnterRaceCheckpoint(playerid);
- * native OnPlayerLeaveRaceCheckpoint(playerid);
- ====================================================================================================*/
- #if !defined _samp_included
- #error Please include 'a_samp.inc' before 'checkpoint.inc'
- #endif
- #if defined _checkpoint_included
- #endinput
- #endif
- #define _checkpoint_included
- #pragma library checkpoint
- /*====================================================================================================
- Define invalid and unused checkpoind id.
- ====================================================================================================*/
- #define INVALID_CHECKPOINT_ID -1
- #define UNUSED_CHECKPOINT_ID 0
- /*====================================================================================================
- Variables:
- * enums, arrays, statics, ...:
- ====================================================================================================*/
- enum E_CHECKPOINT {
- cpId,
- Float:cpX,
- Float:cpY,
- Float:cpZ,
- Float:cpSize
- };
- static cpData[MAX_PLAYERS][E_CHECKPOINT];
- enum E_RACE_CHECKPOINT {
- cpId,
- cpType,
- Float:cpX,
- Float:cpY,
- Float:cpZ,
- Float:cpNextX,
- Float:cpNextY,
- Float:cpNextZ,
- Float:cpSize
- };
- static raceCpData[MAX_PLAYERS][E_RACE_CHECKPOINT];
- /*====================================================================================================
- native OnPlayerCheckpointSet(playerid);
- > playerid > The id of the player.
- Description:
- * Gets executed whenever a checkpoint is set using SetPlayerCheckpoint. It gets
- executed after the variables are saved so you can use all the include
- functions provided in this callback.
- ====================================================================================================*/
- #if defined OnPlayerCheckpointSet
- forward OnPlayerCheckpointSet(playerid);
- #endif
- /*====================================================================================================
- native OnPlayerCheckpointDisable(playerid);
- > playerid > The id of the player.
- Description:
- * Gets executed whenever a checkpoint is disabled using DisablePlayerCheckpoint. It gets
- executed before the variables are resetted, so you can use all the functions
- this include provide in the callback to do whatever.
- ====================================================================================================*/
- #if defined OnPlayerCheckpointDisable
- forward OnPlayerCheckpointDisable(playerid);
- #endif
- /*====================================================================================================
- native SetPlayerCheckpoint(playerid, Float:x, Float:y, Float:z, Float:size, cp_id = UNUSED_CHECKPOINT_ID);
- > playerid = The id of the player.
- > Float:x = The x position of the checkpoint
- > Float:y = The z position of the checkpoint.
- > Float:size = The size of the checkpoint.
- > cp_id = UNUSED_CHECKPOINT_ID = The id of the checkpoint (optional).
- Description:
- * Mark a checkpoint on the map for the player at the specified x, y, z position
- with the specified range. It will return 0 if the player is not connected or invalid
- and 1 if the checkpoint was successfully marked on the map.
- ====================================================================================================*/
- stock cp_SetPlayerCheckpoint(playerid, Float:x, Float:y, Float:z, Float:size, cp_id = UNUSED_CHECKPOINT_ID) {
- if(!IsPlayerConnected(playerid) || IsPlayerNPC(playerid))
- return 0;
- cpData[playerid][cpId] = cp_id;
- cpData[playerid][cpX] = x, cpData[playerid][cpY] = y, cpData[playerid][cpZ] = z, cpData[playerid][cpSize] = size;
- SetPlayerCheckpoint(playerid, x, y, z, size);
- #if defined OnPlayerCheckpointSet
- return OnPlayerCheckpointSet(playerid);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_SetPlayerCheckpoint
- #undef SetPlayerCheckpoint
- #else
- #define _ALS_SetPlayerCheckpoint
- #endif
- #define SetPlayerCheckpoint cp_SetPlayerCheckpoint
- /*====================================================================================================
- native DisablePlayerCheckpoint(playerid);
- > playerid = The id of the player.
- Description:
- * Disable / remove the checkpoint from the map, make it invisible for the player.
- It will return 0 if checkpoint is invalid and 1 if the checkpoint was successfully disabled.
- ====================================================================================================*/
- stock cp_DisablePlayerCheckpoint(playerid) {
- if(!IsValidCheckpoint(playerid))
- return DisablePlayerCheckpoint(playerid);
- #if defined OnPlayerCheckpointDisable
- OnPlayerCheckpointDisable(playerid);
- #endif
- cpData[playerid][cpId] = INVALID_CHECKPOINT_ID;
- cpData[playerid][cpX] = cpData[playerid][cpY] = cpData[playerid][cpZ] = cpData[playerid][cpSize] = 0.0000;
- DisablePlayerCheckpoint(playerid);
- return 1;
- }
- #if defined _ALS_DisablePlayerCheckpoint
- #undef DisablePlayerCheckpoint
- #else
- #define _ALS_DisablePlayerCheckpoint
- #endif
- #define DisablePlayerCheckpoint cp_DisablePlayerCheckpoint
- /*====================================================================================================
- native IsPlayerInCheckpoint(playerid);
- > playerid = The id of the player.
- Description:
- * Check if the player is inside the checkpoint, will return 1 if the player is inside the
- checkpoint and 0 if the player is not inside the checkpoint.
- ====================================================================================================*/
- stock cp_IsPlayerInCheckpoint(playerid) {
- if(!IsValidCheckpoint(playerid))
- return 0;
- if(!IsPlayerInRangeOfPoint(playerid, cpData[playerid][cpSize], cpData[playerid][cpX], cpData[playerid][cpY], cpData[playerid][cpZ]))
- return 0;
- return 1;
- }
- #if defined _ALS_IsPlayerInCheckpoint
- #undef IsPlayerInCheckpoint
- #else
- #define _ALS_IsPlayerInCheckpoint
- #endif
- #define IsPlayerInCheckpoint cp_IsPlayerInCheckpoint
- /*====================================================================================================
- native IsValidCheckpoint(playerid);
- > playerid = The id of the player.
- Description:
- * Check if the checkpoint is valid / marked. If the checkpoint is valid it will return 1,
- else if the checkpoint is invalid it will return 0.
- ====================================================================================================*/
- stock IsValidCheckpoint(playerid) {
- if(!IsPlayerConnected(playerid) || IsPlayerNPC(playerid))
- return 0;
- if(cpData[playerid][cpId] == INVALID_CHECKPOINT_ID && cpData[playerid][cpX] == 0.0000 && cpData[playerid][cpY] == 0.0000 && cpData[playerid][cpZ] == 0.0000 && cpData[playerid][cpSize] == 0.0000)
- return 0;
- return 1;
- }
- /*====================================================================================================
- native GetPlayerCheckpointId(playerid);
- > playerid = The id of the player.
- Description:
- * Get player's checkpoint id and returns it, if invalid return INVALID_CHECKPOINT_ID.
- ====================================================================================================*/
- stock GetPlayerCheckpointId(playerid) {
- if(!IsValidCheckpoint(playerid))
- return INVALID_CHECKPOINT_ID;
- return cpData[playerid][cpId];
- }
- /*====================================================================================================
- native GetPlayerCheckpointPos(playerid, &Float:x, &Float:y, &Float:z);
- > playerid = The id of the player.
- > &Float:x = The x position of the checkpoint.
- > &Float:y = The y position of the checkpoint.
- > &Float:z = The z position of the checkpoint.
- Description:
- * Get checkpoint position and store them into x, y, z float variables.
- return 1 if the checkpoint exists, else if it doesn't exist it will return 0.
- ====================================================================================================*/
- stock GetPlayerCheckpointPos(playerid, &Float:x, &Float:y, &Float:z) {
- if(!IsValidCheckpoint(playerid))
- return 0;
- x = cpData[playerid][cpX], y = cpData[playerid][cpY], z = cpData[playerid][cpZ];
- return 1;
- }
- /*====================================================================================================
- native GetPlayerCheckpointSize(playerid, &Float:size);
- > playerid = The id of the player.
- > &Float:size = The size of the checkpoint.
- Description:
- * Get the size of the checkpoint and stores it into the size float variable.
- return 1 if the checkpoint exists, else if it doesn't exist it will return 0.
- ====================================================================================================*/
- stock GetPlayerCheckpointSize(playerid, &Float:size) {
- if(!IsValidCheckpoint(playerid))
- return 0;
- size = cpData[playerid][cpSize];
- return 1;
- }
- /*====================================================================================================
- native IsPlayerInRangeOfCheckpoint(playerid, Float:range);,
- > playerid = The id of the player.
- > Float:range = The maximum range between the player and the checkpoint.
- Description:
- * Check if player is in range of the checkpoint with specified range. Returns 1 if the player
- is in range, else it returns 0 if player is not in range.
- ====================================================================================================*/
- stock IsPlayerInRangeOfCheckpoint(playerid, Float:range) {
- if(!IsValidCheckpoint(playerid))
- return 0;
- if(!IsPlayerInRangeOfPoint(playerid, range, cpData[playerid][cpX], cpData[playerid][cpY], cpData[playerid][cpZ]))
- return 0;
- return 1;
- }
- /*====================================================================================================
- native Float:GetPlayerDistanceFromCheckpoint(playerid);
- > playerid = The id of the player.
- Description:
- * Return the distance from player to checkpoint in float value,
- it returns 0.0000 if the checkpoint is invalid.
- ====================================================================================================*/
- stock Float:GetPlayerDistanceFromCheckpoint(playerid) {
- if(!IsValidCheckpoint(playerid))
- return 0.0000;
- return GetPlayerDistanceFromPoint(playerid, cpData[playerid][cpX], cpData[playerid][cpY], cpData[playerid][cpZ]);
- }
- /*====================================================================================================
- native OnPlayerEnterCheckpoint(playerid);
- > playerid = The id of the player.
- Description:
- * Hook into OnPlayerEnterCheckpoint and check if the checkpoint is valid,
- if not valid it will return 0.
- ====================================================================================================*/
- public OnPlayerEnterCheckpoint(playerid) {
- if(!IsValidCheckpoint(playerid))
- return 0;
- #if defined cp_OnPlayerEnterCheckpoint
- return cp_OnPlayerEnterCheckpoint(playerid);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnPlayerEnterCheckpoint
- #undef OnPlayerEnterCheckpoint
- #else
- #define _ALS_OnPlayerEnterCheckpoint
- #endif
- #define OnPlayerEnterCheckpoint cp_OnPlayerEnterCheckpoint
- #if defined cp_OnPlayerEnterCheckpoint
- forward cp_OnPlayerEnterCheckpoint(playerid);
- #endif
- /*====================================================================================================
- native OnPlayerLeaveCheckpoint(playerid);
- * playerid = The id of the player.
- Description:
- * Hook into OnPlayerLeaveCheckpoint and check if the checkpoint is valid,
- if not valid it will return 0.
- ====================================================================================================*/
- public OnPlayerLeaveCheckpoint(playerid) {
- if(!IsValidCheckpoint(playerid))
- return 0;
- #if defined cp_OnPlayerLeaveCheckpoint
- return cp_OnPlayerLeaveCheckpoint(playerid);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnPlayerLeaveCheckpoint
- #undef OnPlayerLeaveCheckpoint
- #else
- #define _ALS_OnPlayerLeaveCheckpoint
- #endif
- #define OnPlayerLeaveCheckpoint cp_OnPlayerLeaveCheckpoint
- #if defined cp_OnPlayerLeaveCheckpoint
- forward cp_OnPlayerLeaveCheckpoint(playerid);
- #endif
- /*====================================================================================================
- native OnPlayerRaceCheckpointSet(playerid);
- > playerid = The id of the player.
- Description:
- * Gets called whenever 'SetPlayerRaceCheckpoint' is used, all race checkpoint
- functions are usable inside the callback.
- ====================================================================================================*/
- #if defined OnPlayerRaceCheckpointSet
- forward OnPlayerRaceCheckpointSet(playerid);
- #endif
- /*====================================================================================================
- native OnPlayerRaceCheckpointDisable(playerid);
- > playerid = The id of the player.
- Description:
- * Gets called whenever 'DisablePlayerRaceCheckpoint' is used, all race checkpoint
- functions are usable inside the callback.
- ====================================================================================================*/
- #if defined OnPlayerRaceCheckpointDisable
- forward OnPlayerRaceCheckpointDisable(playerid);
- #endif
- /*====================================================================================================
- native SetPlayerRaceCheckpoint(playerid, type, Float:x, Float:y, Float:z, Float:nextx, Float:nexty, Float:nextz, Float:size, cp_id = UNUSED_CHECKPOINT_ID);
- > playerid = The id of the player.
- > type = The type / style of the race checkpoint.
- > Float:x = The x position of the race checkpoint.
- > Float:y = The y position of the race checkpoint.
- > Float:z = The z position of the race checkpoint.
- > Float:nextx = The nextx position of the race checkpoint.
- > Float:nexty = The nexty position of the race checkpoint.
- > Float:nextz = The nextz position of the race checkpoint.
- > Float:size = The size of the race checkpoint.
- > cp_id = UNUSED_CHECKPOINT_ID = The id of the checkpoint.
- Description:
- * Mark a race checkpoint on the player's map, stores all information into variables for easy
- access, can also be assigned an id for easier management of the checkpoint.
- ====================================================================================================*/
- stock cp_SetPlayerRaceCheckpoint(playerid, type, Float:x, Float:y, Float:z, Float:nextx, Float:nexty, Float:nextz, Float:size, cp_id = UNUSED_CHECKPOINT_ID) {
- if(!IsPlayerConnected(playerid) || IsPlayerNPC(playerid))
- return 0;
- raceCpData[playerid][cpId] = cp_id, raceCpData[playerid][cpType] = type,
- raceCpData[playerid][cpX] = x, raceCpData[playerid][cpY] = y, raceCpData[playerid][cpZ] = z,
- raceCpData[playerid][cpNextX] = nextx, raceCpData[playerid][cpNextY] = nexty, raceCpData[playerid][cpNextZ] = nextz,
- raceCpData[playerid][cpSize] = size;
- SetPlayerRaceCheckpoint(playerid, type, x, y, z, nextx, nexty, nextz, size);
- #if defined OnPlayerRaceCheckpointSet
- return OnPlayerRaceCheckpointSet(playerid);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_SetPlayerRaceCheckpoint
- #undef SetPlayerRaceCheckpoint
- #else
- #define _ALS_SetPlayerRaceCheckpoint
- #endif
- #define SetPlayerRaceCheckpoint cp_SetPlayerRaceCheckpoint
- /*====================================================================================================
- native DisablePlayerRaceCheckpoint(playerid);
- > playerid = The id of the player.
- Description:
- * Disable / unmark race checkpoint from player's map and reset all race checkpoint
- variables.
- ====================================================================================================*/
- stock cp_DisablePlayerRaceCheckpoint(playerid) {
- if(!IsValidRaceCheckpoint(playerid))
- return DisablePlayerRaceCheckpoint(playerid);
- raceCpData[playerid][cpId] = raceCpData[playerid][cpType] = INVALID_CHECKPOINT_ID,
- raceCpData[playerid][cpX] = raceCpData[playerid][cpY] = raceCpData[playerid][cpZ] =
- raceCpData[playerid][cpNextX] = raceCpData[playerid][cpNextY] = raceCpData[playerid][cpNextZ] =
- raceCpData[playerid][cpSize] = 0.0000;
- DisablePlayerRaceCheckpoint(playerid);
- #if defined OnPlayerRaceCheckpointDisable
- return OnPlayerRaceCheckpointDisable(playerid);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_DisablePlayerRaceCheckpoin
- #undef DisablePlayerRaceCheckpoint
- #else
- #define _ALS_DisablePlayerRaceCheckpoin
- #endif
- #define DisablePlayerRaceCheckpoint cp_DisablePlayerRaceCheckpoint
- /*====================================================================================================
- native IsValidRaceCheckpoint(playerid);
- > playerid = The id of the player.
- Description:
- * Checks if the race checkpoint is valid, return 1 if valid
- and return 0 if not valid.
- ====================================================================================================*/
- stock IsValidRaceCheckpoint(playerid) {
- if(!IsPlayerConnected(playerid) || IsPlayerNPC(playerid))
- return 0;
- if(raceCpData[playerid][cpId] == INVALID_CHECKPOINT_ID && raceCpData[playerid][cpType] == INVALID_CHECKPOINT_ID && raceCpData[playerid][cpX] == 0.0000 && raceCpData[playerid][cpY] == 0.0000 && raceCpData[playerid][cpZ] == 0.0000 && raceCpData[playerid][cpNextX] == 0.0000 && raceCpData[playerid][cpNextY] == 0.0000 && raceCpData[playerid][cpNextZ] == 0.0000 && raceCpData[playerid][cpSize] == 0.0000)
- return 0;
- return 1;
- }
- /*====================================================================================================
- native GetPlayerRaceCheckpointId(playerid);
- > playerid = The id of the player.
- Description:
- * Get the player's race checkpoint id and returns it. Will return INVALID_CHECKPOINT_ID
- if player's race checkpoint is invalid.
- ====================================================================================================*/
- stock GetPlayerRaceCheckpointId(playerid) {
- if(!IsValidRaceCheckpoint(playerid))
- return INVALID_CHECKPOINT_ID;
- return raceCpData[playerid][cpId];
- }
- /*====================================================================================================
- native GetPlayerRaceCheckpointPos(playerid, &Float:x, &Float:y, &Float:z);
- > playerid = The id of the player.
- > &Float:x = The x position of the race checkpoint.
- > &Float:y = The y position of the race checkpoint.
- > &Float:z = The z position of the race checkpoint.
- Description:
- * Get race checkpoint position and store them into x, y, z float variables.
- return 1 if the race checkpoint exists, else if it doesn't exist it will return 0.
- ====================================================================================================*/
- stock GetPlayerRaceCheckpointPos(playerid, &Float:x, &Float:y, &Float:z) {
- if(!IsValidRaceCheckpoint(playerid))
- return 0;
- x = raceCpData[playerid][cpX], y = raceCpData[playerid][cpY], z = raceCpData[playerid][cpZ];
- return 1;
- }
- /*====================================================================================================
- native GetPlayerRaceCheckpointNextPos(playerid, &Float:nextx, &Float:nexty, &Float:nextz);
- > playerid = The id of the player.
- > &Float:nextx = The nextx position of the race checkpoint.
- > &Float:nexty = The nexty position of the race checkpoint.
- > &Float:nextz = The nextz position of the race checkpoint.
- Description:
- * Get race checkpoint next position and store them into nextx, nexty, nextz float variables.
- return 1 if the race checkpoint exists, else if it doesn't exist it will return 0.
- ====================================================================================================*/
- stock GetPlayerRaceCheckpointNextPos(playerid, &Float:nextx, &Float:nexty, &Float:nextz) {
- if(!IsValidRaceCheckpoint(playerid))
- return 0;
- nextx = raceCpData[playerid][cpNextX], nexty = raceCpData[playerid][cpNextY], nextz = raceCpData[playerid][cpNextZ];
- return 1;
- }
- /*====================================================================================================
- native GetPlayerRaceCheckpointSize(playerid, &Float:size);
- > playerid = The id of the player.
- > &Float:size = The size of the race checkpoint.
- Description:
- * Get the size of the race checkpoint and stores it into the size float variable.
- return 1 if the race checkpoint exists, else if it doesn't exist it will return 0.
- ====================================================================================================*/
- stock GetPlayerRaceCheckpointSize(playerid, &Float:size) {
- if(!IsValidRaceCheckpoint(playerid))
- return 0;
- size = raceCpData[playerid][cpSize];
- return 1;
- }
- /*====================================================================================================
- native IsPlayerInRangeOfRaceCheckpoint(playerid, Float:range);,
- > playerid = The id of the player.
- > Float:range = The maximum range between the player and the race checkpoint.
- Description:
- * Check if player is in range of the race checkpoint with specified range. Returns 1 if the player
- is in range, else it returns 0 if player is not in range.
- ====================================================================================================*/
- stock IsPlayerInRangeOfRaceCheckpoint(playerid, Float:range) {
- if(!IsValidRaceCheckpoint(playerid))
- return 0;
- if(!IsPlayerInRangeOfPoint(playerid, range, raceCpData[playerid][cpX], raceCpData[playerid][cpY], raceCpData[playerid][cpZ]))
- return 0;
- return 1;
- }
- /*====================================================================================================
- native Float:GetDistanceFromRaceCheckpoint(playerid);
- > playerid = The id of the player.
- Description:
- * Return the distance from player to race checkpoint in float value,
- it returns 0.0000 if the race checkpoint is invalid.
- ====================================================================================================*/
- stock Float:GetDistanceFromRaceCheckpoint(playerid) {
- if(!IsValidRaceCheckpoint(playerid))
- return 0.0000;
- return GetPlayerDistanceFromPoint(playerid, raceCpData[playerid][cpX], raceCpData[playerid][cpY], raceCpData[playerid][cpZ]);
- }
- /*====================================================================================================
- native OnPlayerEnterRaceCheckpoint(playerid);
- > playerid = The id of the player.
- Description:
- * Hook into OnPlayerEnterRaceCheckpoint to check if the race checkpoint
- is valid, return 0 and block the callback if race checkpoint is invalid.
- ====================================================================================================*/
- public OnPlayerEnterRaceCheckpoint(playerid) {
- if(!IsValidRaceCheckpoint(playerid))
- return 0;
- #if defined cp_OnPlayerEnterRaceCheckpoint
- return cp_OnPlayerEnterRaceCheckpoint(playerid);
- #else
- return 1;
- #endif
- }
- #if defined ALS_OnPlayerEnterRaceCheckpoint
- #undef OnPlayerEnterRaceCheckpoint
- #else
- #define ALS_OnPlayerEnterRaceCheckpoint
- #endif
- #define OnPlayerEnterRaceCheckpoint cp_OnPlayerEnterRaceCheckpoint
- #if defined cp_OnPlayerEnterRaceCheckpoint
- forward cp_OnPlayerEnterRaceCheckpoint(playerid);
- #endif
- /*====================================================================================================
- native OnPlayerLeaveRaceCheckpoint(playerid);
- > playerid = The id of the player.
- Description:
- * Hook into OnPlayerLeaveRaceCheckpoint to check if the race checkpoint
- is valid, return 0 and block the callback if race checkpoint is invalid.
- ====================================================================================================*/
- public OnPlayerLeaveRaceCheckpoint(playerid) {
- if(!IsValidRaceCheckpoint(playerid))
- return 0;
- #if defined cp_OnPlayerLeaveRaceCheckpoint
- return cp_OnPlayerLeaveRaceCheckpoint(playerid);
- #else
- return 1;
- #endif
- }
- #if defined ALS_OnPlayerLeaveRaceCheckpoint
- #undef OnPlayerLeaveRaceCheckpoint
- #else
- #define ALS_OnPlayerLeaveRaceCheckpoint
- #endif
- #define OnPlayerLeaveRaceCheckpoint cp_OnPlayerLeaveRaceCheckpoint
- #if defined cp_OnPlayerLeaveRaceCheckpoint
- forward cp_OnPlayerLeaveRaceCheckpoint(playerid);
- #endif
- /*====================================================================================================
- native OnPlayerConnect(playerid);
- > playerid = The id of the player.
- Description:
- * Hook into OnPlayerConnect and reset both race checkpoint and checkpoint variables.
- ====================================================================================================*/
- public OnPlayerConnect(playerid) {
- if(!IsPlayerConnected(playerid) || IsPlayerNPC(playerid))
- return 0;
- cpData[playerid][cpId] = raceCpData[playerid][cpId] = raceCpData[playerid][cpType] = INVALID_CHECKPOINT_ID,
- cpData[playerid][cpX] = cpData[playerid][cpY] = cpData[playerid][cpZ] = cpData[playerid][cpSize] =
- raceCpData[playerid][cpX] = raceCpData[playerid][cpY] = raceCpData[playerid][cpZ] =
- raceCpData[playerid][cpNextX] = raceCpData[playerid][cpNextY] = raceCpData[playerid][cpNextZ] =
- raceCpData[playerid][cpSize] = 0.0000;
- #if defined cp_OnPlayerConnect
- return cp_OnPlayerConnect(playerid);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnPlayerConnect
- #undef OnPlayerConnect
- #else
- #define _ALS_OnPlayerConnect
- #endif
- #define OnPlayerConnect cp_OnPlayerConnect
- #if defined cp_OnPlayerConnect
- forward cp_OnPlayerConnect(playerid);
- #endif
- /*====================================================================================================
- End of checkpoint include.
- ====================================================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement