Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- jCheckpoints by Johurt(ES.^, Edgar).
- Date: 04-04-2013
- Video: http://www.youtube.com/watch?v=WQqVz1sJ9Xo
- */
- #include <a_samp>
- #define MAX_PLAYER_CPS 5
- #define PLUS_CP_SIZE 2.0
- new pCPID[MAX_PLAYERS],
- Float:pCPPosX[MAX_PLAYERS][MAX_PLAYER_CPS],
- Float:pCPPosY[MAX_PLAYERS][MAX_PLAYER_CPS],
- Float:pCPPosZ[MAX_PLAYERS][MAX_PLAYER_CPS],
- Float:pCPSize[MAX_PLAYERS][MAX_PLAYER_CPS],
- bool:pCPShow[MAX_PLAYERS][MAX_PLAYER_CPS];
- public OnPlayerConnect(playerid)
- {
- pCPID[playerid] = -1;
- for(new cp; cp < MAX_PLAYER_CPS; cp++)
- {
- pCPPosX[playerid][cp] = 0.0;
- pCPPosY[playerid][cp] = 0.0;
- pCPPosZ[playerid][cp] = 0.0;
- pCPSize[playerid][cp] = 0.0;
- pCPShow[playerid][cp] = false;
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp("/cp1", cmdtext, true, 4))
- {
- SetPlayerCheckpointEx(playerid, 0, -2026.5967, -101.1647, 35.1641, 3.0);
- return 1;
- }
- if(!strcmp("/cp2", cmdtext, true, 4))
- {
- SetPlayerCheckpointEx(playerid, 1, -2027.8463, -41.2431, 38.8047, 3.0);
- return 1;
- }
- return 0;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- new cpid = pCPID[playerid];
- switch(cpid)
- {
- case 0:
- {
- if(IsPlayerInCheckpointEx(playerid, cpid))
- {
- printf("Player enter %d ID checkpoint.", cpid);
- DisablePlayerCheckpointEx(playerid, 0);
- }
- }
- case 1:
- {
- if(IsPlayerInCheckpointEx(playerid, cpid))
- {
- printf("Player enter %d ID checkpoint.", cpid);
- DisablePlayerCheckpointEx(playerid, 1);
- }
- }
- }
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- new cpid = pCPID[playerid];
- switch(cpid)
- {
- case 1:
- {
- if(IsPlayerInCheckpointEx(playerid, cpid))
- {
- printf("Player leave %d ID checkpoint.", cpid);
- }
- }
- }
- return 1;
- }
- stock SetPlayerCheckpointEx(playerid, cpid, Float:x, Float:y, Float:z, Float:size)
- {
- if(cpid < 0 || cpid > MAX_PLAYER_CPS - 1)
- {
- printf("Error, you can't create cp with %d ID.", cpid);
- return 1;
- }
- pCPPosX[playerid][cpid] = x;
- pCPPosY[playerid][cpid] = y;
- pCPPosZ[playerid][cpid] = z;
- pCPSize[playerid][cpid] = size;
- pCPShow[playerid][cpid] = true;
- pCPID[playerid] = cpid;
- SetPlayerCheckpoint(playerid, x, y, z, size);
- return 1;
- }
- stock DisablePlayerCheckpointEx(playerid, cpid)
- {
- if(cpid < 0 || cpid > MAX_PLAYER_CPS - 1)
- {
- printf("Error, you can't delete cp with %d ID.", cpid);
- return 1;
- }
- pCPID[playerid] = -1;
- pCPPosX[playerid][cpid] = 0.0;
- pCPPosY[playerid][cpid] = 0.0;
- pCPPosZ[playerid][cpid] = 0.0;
- pCPSize[playerid][cpid] = 0.0;
- pCPShow[playerid][cpid] = false;
- DisablePlayerCheckpoint(playerid);
- for(new cp; cp < MAX_PLAYER_CPS; cp++)
- {
- if(pCPShow[playerid][cp])
- {
- pCPID[playerid] = cp;
- SetPlayerCheckpoint(playerid, pCPPosX[playerid][cp], pCPPosY[playerid][cp], pCPPosZ[playerid][cp], pCPSize[playerid][cp]);
- break;
- }
- }
- return 1;
- }
- stock DisableAllPlayerCheckpoints(playerid)
- {
- pCPID[playerid] = -1;
- DisablePlayerCheckpoint(playerid);
- for(new cp; cp < MAX_PLAYER_CPS; cp++)
- {
- if(pCPShow[playerid][cp])
- {
- pCPPosX[playerid][cp] = 0.0;
- pCPPosY[playerid][cp] = 0.0;
- pCPPosZ[playerid][cp] = 0.0;
- pCPSize[playerid][cp] = 0.0;
- pCPShow[playerid][cp] = false;
- }
- }
- return 1;
- }
- stock IsPlayerInCheckpointEx(playerid, cpid)
- {
- if(cpid < 0 || cpid > MAX_PLAYER_CPS)
- {
- printf("Error, you can't check cp with %d ID.", cpid);
- return false;
- }
- if(!pCPShow[playerid][cpid]) return false;
- if(!IsPlayerInRangeOfPoint(playerid, pCPSize[playerid][cpid] + PLUS_CP_SIZE, pCPPosX[playerid][cpid], pCPPosY[playerid][cpid], pCPPosZ[playerid][cpid])) return false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement