[Tutorial] [TUT]Multiple Checkpoints Without Streamer!
#1

*-Multiple Checkpoints Tutorial-*
By: Yuryfury
What Is This Tutorial About?
To add multiple checkpoints without a streamer! Why would you release a script using someone else's work when you don't have to?

Required Function(s):
GetDistanceToPoint
pawn Code:
stock Float: GetDistanceToPoint(playerid,Float: X2,Float:Y2 ,Float: Z2)
{
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid,X,Y,Z);
  return floatsqroot ( floatpower ( floatabs ( floatsub ( X , X2 ) ) , 2 ) + floatpower ( floatabs ( floatsub ( Y , Y2 ) ) , 2 ) + floatpower ( floatabs ( floatsub ( Z , Z2 ) ) , 2 ) );
}
Steps:
Step 1: Get The Coordinates For Your Checkpoints(Using /save in-game).

Step 2: Open up a new pawno file or an existing one.

Step 3: Towards the top(somewhere under #include <a_samp>) add the GetDistanceToPoint Function.

Step 4: Under OnPlayerConnect OnGameModeInit(Thanks to Donny) add a timer: SetTimer("CheckpointCheck",500,1); and forward it: forward CheckpointCheck();.

Step 5: Create A New Public Called CheckpointCheck at the bottom of your script:
pawn Code:
public CheckpointCheck()
{
  for(new i; i<MAX_PLAYERS; i++)// a loop that goes though all players
  {
    if(IsPlayerConnected(i))//checks if the player is connected
    {

    }
  }
  return 1;
}
Step 6: Get The coordinates of your first checkpoint from your save file and replace X,Y,Z with them:
pawn Code:
public CheckpointCheck()
{
  for(new i; i<MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
    {
        if(GetDistanceToPoint(i,X,Y,Z)<=10) //change 10 to what ever you want the "view distance" to be.
        {
          SetPlayerCheckpoint(i,-X,Y,Z,2);//Change 2 to what ever radius you want (of the checkpoint)
        }
    }
  }
  return 1;
}
Explanation: Here we check the players distance to the checkpoint's location. If he is closer or exactly 10 coordinates away the checkpoint is shown.

Step 7: Now we want to disable the checkpoint when the player is not in the area:
pawn Code:
public CheckpointCheck()
{
  for(new i; i<MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
    {
        if(GetDistanceToPoint(i,X,Y,Z)<=10) //change 10 to what ever you want hte "view distance" to be.
        {
          SetPlayerCheckpoint(i,-X,Y,Z,2);//Change 2 to what ever radius you want (of the checkpoint)
        }
        else
        {
          DisablePlayerCheckpoint(i);
        }
    }
  }
  return 1;
}
Step 8: To make the checkpoint do something we add these lines under OnPlayerEnterCheckpoint(playerid);
pawn Code:
public OnPlayerEnterCheckpoint(playerid)
{
    if(GetDistanceToPoint(playerid,X,Y,Z)<=2)//the same X,Y,Z coords as the ones you put into the timer || the 2 should be your checkpoint radius
    {
        GameTextForPlayer(playerid,"You Entered A "Streamed" Checkpoint!",5000,3);
    }
    return 1;
}
Explanation: Here once again we check the players distance from the checkpoint. If the player is less or exactly 2 coordinates away then this function is called(GameTextForPlayer)

Step 9: Your finished script should look something like this

And That's It! You Just Made Your Own "Checkpoint Streamer"! Feel Free To Use And Change It All You Want, You Don't Even Need To Put Me In The Credits(Unless you Want To :P)
If you have any problems ask here!

P.S: I understand that checkpoint streamers are a bit more efficient but here you don't need an extra include or filterscript. This is a lot easier especially if you are only making a small amount of checkpoints. And most importantly you made it so there is no mess with credits if you ever host or release a gamemode!
Reply


Messages In This Thread
[TUT]Multiple Checkpoints Without Streamer! - by Yuryfury - 19.08.2009, 19:43
Re: [TUT]Multiple Checkpoints Without Streamer! - by burgershot - 19.08.2009, 20:26
Re: [TUT]Multiple Checkpoints Without Streamer! - by Yuryfury - 19.08.2009, 22:19
Re: [TUT]Multiple Checkpoints Without Streamer! - by *James* - 20.08.2009, 00:11
Re: [TUT]Multiple Checkpoints Without Streamer! - by Yuryfury - 20.08.2009, 02:05
Re: [TUT]Multiple Checkpoints Without Streamer! - by Shubham - 29.08.2009, 06:11
Re: [TUT]Multiple Checkpoints Without Streamer! - by Yuryfury - 29.08.2009, 20:01
Re: [TUT]Multiple Checkpoints Without Streamer! - by GTA_Rules - 29.08.2009, 20:17
Re: [TUT]Multiple Checkpoints Without Streamer! - by ғαιιοцт - 29.08.2009, 20:24
Re: [TUT]Multiple Checkpoints Without Streamer! - by Donny_k - 29.08.2009, 20:30
Re: [TUT]Multiple Checkpoints Without Streamer! - by Google63 - 29.08.2009, 21:11
Re: [TUT]Multiple Checkpoints Without Streamer! - by Yuryfury - 29.08.2009, 23:11
Re: [TUT]Multiple Checkpoints Without Streamer! - by Donny_k - 29.08.2009, 23:46
Re: [TUT]Multiple Checkpoints Without Streamer! - by Weirdosport - 29.08.2009, 23:59
Re: [TUT]Multiple Checkpoints Without Streamer! - by Yuryfury - 30.08.2009, 01:23
Re: [TUT]Multiple Checkpoints Without Streamer! - by Kyosaur - 30.08.2009, 02:53
Re: [TUT]Multiple Checkpoints Without Streamer! - by TheNotorius - 10.09.2009, 02:03
Re: [TUT]Multiple Checkpoints Without Streamer! - by Yuryfury - 10.09.2009, 03:09
Re: [TUT]Multiple Checkpoints Without Streamer! - by splatterpuss1 - 01.10.2009, 22:02
Re: [TUT]Multiple Checkpoints Without Streamer! - by Owenlishious - 29.04.2010, 15:05
Re: [TUT]Multiple Checkpoints Without Streamer! - by billiout - 23.05.2010, 15:00
Re: [TUT]Multiple Checkpoints Without Streamer! - by JumboJet - 18.08.2010, 20:33
Re: [TUT]Multiple Checkpoints Without Streamer! - by willsuckformoney - 18.08.2010, 23:45
Re: [TUT]Multiple Checkpoints Without Streamer! - by Backwardsman97 - 19.08.2010, 02:55
Re: [TUT]Multiple Checkpoints Without Streamer! - by Roperr - 30.08.2010, 21:40
Re: [TUT]Multiple Checkpoints Without Streamer! - by sickem - 05.09.2010, 07:43
Re: [TUT]Multiple Checkpoints Without Streamer! - by ipsBruno - 01.10.2010, 17:13
Re: [TUT]Multiple Checkpoints Without Streamer! - by Yuryfury - 22.08.2011, 03:28
Re: [TUT]Multiple Checkpoints Without Streamer! - by Dark Killer - 15.01.2013, 10:23

Forum Jump:


Users browsing this thread: 6 Guest(s)