SA-MP Forums Archive
[Tutorial] Simple Checkpoint - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Simple Checkpoint (/showthread.php?tid=340025)



Simple Checkpoint - Mento - 05.05.2012

CheckPoints:
Checkpoints are the red cylinders you may see around many servers. They are quite useful for jobs, missions, or events. There are two types of checkpoints, one being race checkpoints and the other is normal checkpoints. Race checkpoints are large checkpoints, they are either a very large cylinder, used in GTA:San Andreas Single Player for street races, or large circle checkpoints, used in GTA:San Andreas Single Player for airplane license missions. Then there are normal checkpoints, usually a small cylinder that can be narrow or wide, used in GTA:San Andreas Single Player for food stores, barber shops, etc.

Race Checkpoints:
Creating Race Checkpoints is with the following function.
pawn Code:
SetPlayerRaceCheckpoint();
Removing, or disabling, Race Checkpoints is with the following function.
pawn Code:
DisablePlayerRaceCheckpoint();
Normal Checkpoints:
Creating Normal Checkpoints is with the following function.
pawn Code:
SetPlayerCheckpoint();
Removing, or disabling, Normal Checkpoints is with the following function.
pawn Code:
DisablePlayerCheckpoint();
The Code:
Now that we know what the two types of checkpoints are in SAMP and how to create and remove both of them, we can continue. We began by finding the following function:
pawn Code:
public OnPlayerSpawn(playerid)
Inside the function we choose what kind of checkpoint we are planning to make, so lets for now pick a normal checkpoint:
pawn Code:
public OnPlayerSpawn(playerid)
{
    SetPlayerCheckpoint(playerid, 0, 0, 0, 5);
    return 1;
}
When creating the checkpoint there are 5 parts, you first put the player's id, then their x, y, z coordinates, and finally the width of the cylinder checkpoint, in this case 5. The following checkpoint will be created at coordinates 0, 0, 0, when the player is spawned. Now let us say we want to make it so when the player enters this checkpoint, they should get a weapon, so we find the following function:
pawn Code:
public OnPlayerEnterCheckpoint(playerid)
This function does as it says, when the player enters a checkpoint, it does something. But wait, how does it know what checkpoint? Well we have to identify it, we can do this by finding out if the player is near a certain coordinates, that we created our checkpoint at, an example:
pawn Code:
public OnPlayerEnterCheckpoint(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, 5, 0, 0, 0))
    {
        GivePlayerWeapon(playerid, 24, 9999);
        DisablePlayerCheckpoint(playerid);
    }
    return 1;
}
Now the player will enter the checkpoint we created, once they enter the script will check if they are in the range of 0, 0, 0, and then give them a weapon with 9999 ammo, and then remove our checkpoint. This is one example of what a checkpoint can do, but it can be changed to give Armour, Health, or even kill the player.


Re: Simple Checkpoint - SwiftKidZ - 06.05.2012

Nice


Re: Simple Checkpoint - Mento - 06.05.2012

Thanks once again for your nice comment


Re: Simple Checkpoint - bashar0151 - 07.05.2012

i am loving it


Re: Simple Checkpoint - Mento - 07.05.2012

Thank you for the nice comment sir.


Re: Simple Checkpoint - sgtjones12 - 10.07.2012

When i add multiple checkpoints it only shows one and not the others


Re: Simple Checkpoint - newbienoob - 10.07.2012

Use streamer
https://sampforum.blast.hk/showthread.php?tid=102865
pawn Code:
native CreateDynamicCP()
public OnPlayerEnterDynamicCP(playerid,checkpointid)



Respuesta: Simple Checkpoint - [Nikolay] - 10.07.2012

Can you post some images about checkpoint please?


Re: Respuesta: Simple Checkpoint - zombieking - 10.07.2012

Quote:
Originally Posted by [Nikolay]
View Post
Can you post some images about checkpoint please?
Why? You didn't saw any checkpoints? If so , he wrote that checkpoints are red cylinders with various sizes.. Not really a thing which would need images.

ON: Good tutorial , 10/10 (+rep for you)


Re: Simple Checkpoint - sgtjones12 - 10.07.2012

Quote:
Originally Posted by newbienoob
View Post
Use streamer
https://sampforum.blast.hk/showthread.php?tid=102865
pawn Code:
native CreateDynamicCP()
public OnPlayerEnterDynamicCP(playerid,checkpointid)
Ok thank you


Re: Simple Checkpoint - Mento - 11.07.2012

No problem, thanks for all the comments, I am very glad it helped.