[Tutorial] Simple Checkpoint
#1

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.
Reply
#2

Nice
Reply
#3

Thanks once again for your nice comment
Reply
#4

i am loving it
Reply
#5

Thank you for the nice comment sir.
Reply
#6

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

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

Can you post some images about checkpoint please?
Reply
#9

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)
Reply
#10

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
Reply
#11

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


Forum Jump:


Users browsing this thread: 1 Guest(s)