[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
#2

Thanks a lot for sending me the link!
Reply
#3

Quote:
Originally Posted by burgershot
Thanks a lot for sending me the link!
happy to help
Reply
#4

Thanks alot, ive been looking for something like this

only 1 question= i am a newb scripter and i wanted to know where this goes or how to make it a function

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 ) );
}
SOLVED nvm tnx
Reply
#5

Quote:
Originally Posted by *James*
Thanks alot, ive been looking for something like this

only 1 question= i am a newb scripter and i wanted to know where this goes or how to make it a function

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 ) );
}
SOLVED nvm tnx
Good to see that you got it working, and thanks!

P.S: Thanks to you I noticed that I forgot to put the function in the example script
Reply
#6

nice man
i like it
Reply
#7

Quote:
Originally Posted by Shubham_Mathur
nice man
i like it
thanks! :P
Reply
#8

Love the idea. Nice work
Reply
#9

nice tutorial now the beginners will understand how streamers accually work


[TUT]Multipile Checkpoints Without Streamer!
Quote:

That's it! you just made your own checkpoint streamer

lol
Reply
#10

This is far from what I'd call a tutorial and some of that code is very inefficient IMHO.

No offence, just my two cents.
Reply
#11

For distance checking it is best to use y_less's macro
Reply
#12

Quote:
Originally Posted by Donny
This is far from what I'd call a tutorial and some of that code is very inefficient IMHO.

No offence, just my two cents.
Well as I said at the bottom of the main post:
Quote:

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!

and why wouldn't you call it a tutorial?
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++
Quote:
Originally Posted by Matthias_
Love the idea. Nice work
Quote:
Originally Posted by °ғαιιοцт°
nice tutorial now the beginners will understand how streamers accually work


[TUT]Multipile Checkpoints Without Streamer!
Quote:

That's it! you just made your own checkpoint streamer

lol
Thanks
Reply
#13

I know what you said dude but that won't fix scripting mistakes will it, for example:

You are creating a timer each time a player connects, if you leave your server on for a while it could end up with thousands of timers all running at the same time and all doing the same job.

I said this isn't what I call a tutorial because all it does is tell you where to put things, it doesn't tell you why and it doesn't explain any of the functions or code (well some code it does, I'll give you that one), all it does is say "put this here and start your server".

You see what I mean ?

No worries either way, I don't actually care hehe, just being constructive.
Reply
#14

I can't help but notice this tutorial basically teaches you how to make a streamer :P
Reply
#15

Quote:
Originally Posted by Donny
I know what you said dude but that won't fix scripting mistakes will it, for example:

You are creating a timer each time a player connects, if you leave your server on for a while it could end up with thousands of timers all running at the same time and all doing the same job.

I said this isn't what I call a tutorial because all it does is tell you where to put things, it doesn't tell you why and it doesn't explain any of the functions or code (well some code it does, I'll give you that one), all it does is say "put this here and start your server".

You see what I mean ?

No worries either way, I don't actually care hehe, just being constructive.
Well I do agree with the timer, it would be more efficient to put it under OnGameModeInIt but I never had any problems with it and since I am not able to test it on a large server I wouldn't know the consequences

But I think I explain it fairly well, I mean it is my first tutorial and now I know to explain the functions/code more in the future (As well as edit this one )

Thanks for the advice :P

Quote:
Originally Posted by Weirdosport
I can't help but notice this tutorial basically teaches you how to make a streamer :P
I guess the topic title is kind of ironic but it is easier to understand than most of the streamers I've seen
Reply
#16

Nice tutorial.

I'd replace/fix your GetDistanceToPoint function though (Why use slow functions when you can use standard operators ).

Code:
#define PlayerToPoint(%0,%1,%2,%3,%4,%5,%6) \
(((%0 - %3) * (%0 - %3)) + ((%1 - %4) * (%1 - %4)) + ((%2 - %5) * (%2 - %5)) <= %6 * %6)

//by Y_less - http://forum.sa-mp.com/index.php?top...#post_distance
Reply
#17

i Always Get:
Code:
C:\Users\NightSlayer\Desktop\GTA San andreas\SAMP Server\gamemodes\LSRP.pwn(1428) : error 017: undefined symbol "X"
C:\Users\NightSlayer\Desktop\GTA San andreas\SAMP Server\gamemodes\LSRP.pwn(1430) : error 017: undefined symbol "X"
C:\Users\NightSlayer\Desktop\GTA San andreas\SAMP Server\gamemodes\LSRP.pwn(1434) : error 017: undefined symbol "playerid"
C:\Users\NightSlayer\Desktop\GTA San andreas\SAMP Server\gamemodes\LSRP.pwn(1376) : error 017: undefined symbol "X"
Please Help?
Reply
#18

Quote:
Originally Posted by TheNotorius
i Always Get:
Code:
C:\Users\NightSlayer\Desktop\GTA San andreas\SAMP Server\gamemodes\LSRP.pwn(1428) : error 017: undefined symbol "X"
C:\Users\NightSlayer\Desktop\GTA San andreas\SAMP Server\gamemodes\LSRP.pwn(1430) : error 017: undefined symbol "X"
C:\Users\NightSlayer\Desktop\GTA San andreas\SAMP Server\gamemodes\LSRP.pwn(1434) : error 017: undefined symbol "playerid"
C:\Users\NightSlayer\Desktop\GTA San andreas\SAMP Server\gamemodes\LSRP.pwn(1376) : error 017: undefined symbol "X"
Please Help?
If it is under public CheckpointCheck or OnPlayerEnterCheckpoint you have to change the X to the X coordinate of where you want the checkpoint, Y to the Y coordinate and Z to the Z coordinate.

To get the coordinates go into debug or you server and do /save, then in the saved position folder copy the 3 numbers (separated by commas) that come AFTER the frist one

Code:
AddPlayerClass( 0, The X You Want, The Y You Want, The Z You Want, 269.15, 26, 36, 28, 150, 0, 0 );
as for the playerid, I made an error Change DisablePlayerCheckpoint(playerid); to DisablePlayerCheckpoint(i);
Reply
#19

I love it, very useful and easy to understand and works perfectly.

Good job!
Reply
#20

i have a probelm tho...how can i fix the "sendclientmessge" spam when i enter a checkpoint?

its accually pretty annoying...

and btw awesome tutorial!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)