Checkpoints - 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)
+--- Thread: Checkpoints (
/showthread.php?tid=596347)
CreateDynamicCP as SetPlayerCheckpoint? -
Sheperc - 16.12.2015
Hi again ya'll.
So I am having a bit of another problem. You see I downloaded the Streamer (by Incognito) and I want to make some checkpoints that when you enter one, another one appears. So for such I need checkpoint ID's, and that's okay. I need the same style CreateDynamicCP as SetPlayerCheckpoint, meaning I need them to NOT stream, but just add one at a time. So why am I not using SetPlayerCheckpoint? Again, I need seperate checkpointid's. So how am I supposed to handle this? Help appreciated.
Re: Checkpoints -
prineside - 16.12.2015
Well, if you need to show another checkpoint and hide the old one, you can do that without Streamer, using only SetPlayerCheckpoint
1. Store checkpoint positions in prefered order into an array
PHP код:
#define NUMBER_OF_CP_POSITIONS (16) // Number of different positions for checkpoints
enum Vector3 {
Float:X,
Float:Y,
Float:Z
}
checkpointPositions[NUMBER_OF_CP_POSITIONS][Vector3] = {
{ 100.0, 200.0, 5.0 }, // 1-st checkpoint player should go to
{ 200.0, 300.0, 10.0 }, // 2-nd, which we'll show as soon as player enter first
...
};
2. Create an array where you'll store ID of current checkpoint for each player
PHP код:
new currentPlayerCheckpoint[MAX_PLAYERS];
3. When player starts doing something (I don't know what you are going to do with checkpoints), set that ID to 0 and show the first checkpoint (whick has index 0 in positions array)
PHP код:
// Simply shows current checkpoint player has to go to
public ShowCurrentPlayerCheckpoint( playerid ) {
new idx = currentPlayerCheckpoint[ playerid ];
SetPlayerCheckpoint( playerid, checkpointPositions[ idx ][ X ], checkpointPositions[ idx ][ Y ], checkpointPositions[ idx ][ Z ], 5.0 );
}
// This public is called on event start
public WhenSomethingStarts( playerid ) {
currentPlayerCheckpoint[ playerid ] = 0;
ShowCurrentPlayerCheckpoint( playerid ); // Show the first CP
}
4. Finaly, callback handling
PHP код:
public OnPlayerEnterCheckpoint( playerid ) {
new cpID = currentPlayerCheckpoint[ playerid ]; // That's the ID of CP player entered
// To get CP position, use checkpointPositions[ cpID ][ X / Y / Z ]
// Now lets show him the next CP or do something else if he entered the last one
if ( cpID == NUMBER_OF_CP_POSITIONS - 1 ) {
// That was the last CP, player walked through all of them and now we can give him something / finish event / start it again etc.
} else {
// That checkpoint was not last, let's show the next one
currentPlayerCheckpoint[ playerid ]++;
ShowCurrentPlayerCheckpoint( playerid );
}
}
That's the idea. This code may have errors, you should use it as an example but not as completed working thing
Re: Checkpoints -
Sheperc - 16.12.2015
That might just be something I was looking for. Seems I need to learn a little bit more. Thanks for putting me on the right path.