Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ____ _ __
- / _/___ _________ _____ (_) /___ __
- / // __ \/ ___/ __ `/ __ \/ / __/ / / /
- _/ // / / (__ ) /_/ / / / / / /_/ /_/ /
- /___/_/ /_/____/\__,_/_/ /_/_/\__/\__, /
- /____/
- ____ _ _ __ __
- / _/___ _ __(_)____(_) /_ / /__
- / // __ \ | / / / ___/ / __ \/ / _ \
- _/ // / / / |/ / (__ ) / /_/ / / __/
- /___/_/ /_/|___/_/____/_/_.___/_/\___/
- ________ __ ____ _ __
- / ____/ /_ ___ _____/ /__/ __ \____ (_)___ / /______
- / / / __ \/ _ \/ ___/ //_/ /_/ / __ \/ / __ \/ __/ ___/
- / /___/ / / / __/ /__/ ,< / ____/ /_/ / / / / / /_(__ )
- \____/_/ /_/\___/\___/_/|_/_/ \____/_/_/ /_/\__/____/
- - Description
- It allows you to create invisible checkpoints for check when the player enter
- on invisible checkpoint with a vehicle or not.
- - Author
- Allan Jader (CyNiC)
- Babul: colaborated with the function: CreatePickupsInCircle
- http://forum.sa-mp.com/showpost.php?p=694885&postcount=5
- - Note
- You can change how much you want the include, leaving the credit to creator.
- */
- #include <a_samp>
- #define MAX_AREAS 50
- #define REAPPLY_CPS_TIMER 5000
- enum cpinfo
- {
- cpid,
- bool: created,
- area,
- bool: areaexist,
- type,
- Float:cpPosX,
- Float:cpPosY,
- Float:cpPosZ,
- }
- new invisiblecps[MAX_AREAS * 10][cpinfo];
- new bool: playerblock[MAX_PLAYERS];
- static highestcp;
- forward OnVehicleEnterICheckpoint(playerid, vehicleid, checkpointid);
- forward OnPlayerEnterICheckpoint(playerid, checkpointid);
- forward EnterCheckpoint(playerid, checkpointid, cptype);
- stock CreateIPlayerCheckpoint(Float:X, Float:Y, Float:Z, Float:size) return CreatePickupsInCircle(1, X, Y, Z,-1,size);
- stock CreateIVehicleCheckpoint(Float:X, Float:Y, Float:Z, Float:size) return CreatePickupsInCircle(14, X, Y, Z,-1,size);
- InvisibleCheckpoints(playerid, pickupid)
- {
- if(playerblock[playerid]) return 1;
- for(new i = 0; i < sizeof highestcp; ++i) if(pickupid == invisiblecps[i][cpid]) return SetTimerEx("EnterCheckpoint", true, false, "ddd", playerid, i, invisiblecps[i][type]);
- return 1;
- }
- public EnterCheckpoint(playerid, checkpointid, cptype)
- {
- if(cptype == 14)
- {
- OnVehicleEnterICheckpoint(playerid, GetPlayerVehicleID(playerid), invisiblecps[checkpointid][area]);
- playerblock[playerid] = true;
- SetTimerEx("unblockplayer", REAPPLY_CPS_TIMER, false, "d", playerid);
- ReloadArea(invisiblecps[checkpointid][area]);
- return 1;
- }
- OnPlayerEnterICheckpoint(playerid, invisiblecps[checkpointid][area]);
- playerblock[playerid] = true;
- SetTimerEx("unblockplayer", REAPPLY_CPS_TIMER, false, "d", playerid);
- ReloadArea(invisiblecps[checkpointid][area]);
- return true;
- }
- public OnPlayerEnterICheckpoint(playerid, checkpointid)
- {
- return 1;
- }
- public OnVehicleEnterICheckpoint(playerid, vehicleid, checkpointid)
- {
- return 1;
- }
- stock DestroyCheckpoint(checkpointid)
- {
- for(new i = 0; i < 360; ++i)
- {
- if(invisiblecps[i][area] == checkpointid)
- {
- invisiblecps[i][areaexist] = false;
- invisiblecps[i][created] = false;
- DestroyPickup(invisiblecps[i][cpid]);
- if(checkpointid == highestcp) highestcp--;
- }
- }
- return 1;
- }
- forward unblockplayer(playerid);
- public unblockplayer(playerid)
- {
- playerblock[playerid] = false;
- return 1;
- }
- ReloadArea(areaid)
- {
- for(new i = 0; i < sizeof invisiblecps; ++i)
- {
- if(invisiblecps[i][area] == areaid)
- {
- DestroyPickup(invisiblecps[i][cpid]);
- invisiblecps[i][cpid] = CreatePickup(1007, 14, invisiblecps[i][cpPosX], invisiblecps[i][cpPosY], invisiblecps[i][cpPosZ]);
- }
- }
- return 1;
- }
- stock CreatePickupsInCircle(ptype,Float:CX,Float:CY,Float:CZ,vw, Float:radius) //By Sacky
- {
- new Float: percent = floatdiv(floatdiv(360,radius), 4.0), area2, a;
- radius = floatdiv(radius,3.0);
- for(a = 0; a < sizeof invisiblecps; ++a)
- {
- if(!invisiblecps[a][areaexist])
- {
- if(a == 0)
- {
- area2 = invisiblecps[0][area] + 1;
- goto jump1;
- }
- area2 = invisiblecps[(a-1)][area] + 1;
- break;
- }
- }
- jump1:
- new Float: i, p;
- for(i = 0.0; i<360.0; i+=percent)
- {
- new Float:X, Float:Y, Float:Z;
- X = CX+(radius*floatsin(i,degrees));
- Y = CY+(radius*floatcos(i,degrees));
- Z = CZ;
- for(p = 0; p < sizeof invisiblecps; ++p)
- {
- if(!invisiblecps[p][created])
- {
- invisiblecps[p][created] = true;
- invisiblecps[p][cpid] = CreatePickup(1007,ptype,X,Y,Z,vw);
- invisiblecps[p][cpPosX] = X;
- invisiblecps[p][cpPosY] = Y;
- invisiblecps[p][cpPosZ] = Z;
- invisiblecps[p][area] = area2;
- invisiblecps[p][type] = ptype;
- invisiblecps[p][areaexist] = true;
- highestcp++;
- break;
- }
- }
- }
- return area2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement