[HELP]Race checkpints help
#1

Hello all I tried to learn every tutorial of making race , but they don't explain how to add 3rd cp and I need to make about 15 races can anyone give me codes of the following coordinates? After that I can make the other races by learning and understanding this one..

Quote:

-1145.5658,-1045.6901,128.5027 [ Race Cp -1 ]
-1183.2870,-1002.4471,128.5025 [ Race Cp -2 ]
-1172.3785,-988.5954,128.5025 [ Race Cp - 3]
-1129.6694,-1018.2800,128.5025 [ Race Cp -4 ]
-1098.4072,-1057.1410,128.4954 [ Race Cp -5 ]
-1045.0264,-1022.5968,128.4956 [ Race Cp -6 ]
-1011.6423,-980.4113,128.5025 [ Race Cp - 7 ]
-1035.6104,-953.7844,128.5026 [ Race Cp - 8 ]
-1081.0226,-997.9811,128.5026 [ Race Cp - 9 ]
-1089.9166,-962.7728,128.5025 [ Race Cp -10]
-1123.8011,-964.7301,128.5021 [ Race Cp -11 ]
-1156.1207,-932.0033,128.5025 [ Race Cp -12 ]
-1210.1948,-1017.1234,127.5494 [ Race Cp -13 ]
-1145.9674,-1034.9795,128.5025 [ Race Cp -14 ]
Your help may be appreiciated thanks
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=507416
Reply
#3

Bump
Reply
#4

You can use IsPlayerInRangeOfPoint or a variable to check which race checkpoint you've set in OnPlayerEnterRaceCheckpoint, and then set the next accordingly.
Reply
#5

Can you explain ?
Reply
#6

Just put together an example.
Think it like x[], y[] and z[] are your different coordinates, i just numbered them to make it easier to understand how they all relate.
pawn Код:
SetPlayerRaceCheckpoint(playerid, 0, x[0], y[0], z[0], x[1], y[1], z[1], 5);
    // Sets the players race checkpoint to the coordinates number "0", and the arrow will be pointing to the next checkpoint, at coordinates number "1"

public OnPlayerEnterRaceCheckpoint(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, 5, x[0], y[0], z[0]))
        // If the player is in range of the coordinates number "0", the same coordinates as the first checkpoint is at
    {
        SetPlayerRaceCheckpoint(playerid, 0, x[1], y[1], z[1], x[2], y[2], z[2], 5);
            // Then set the next checkpoint, at coordinates "1", and make the arrow point to coordinates number "2"
    }
    if(IsPlayerInRangeOfPoint(playerid, 5, x[1], y[1], z[1]))
        // If the player is in range of the coordinates number "1", the same coordinates as the second checkpoint is at
    {
        SetPlayerRaceCheckpoint(playerid, 0, x[2], y[2], z[2], x[3], y[3], z[3], 5);
            // Then set the next checkpoint, at coordinates "2", and make the arrow point to coordinates number "3"
    }
    // Continue for all checkpoints
    return 1;
}
Reply
#7

Thank you very much
Reply
#8

Error : When i use the Values again , it says Symbol already used " SetPlayerRaceCheckpoint " and samp with " IsPlayerInRangeOfPoint"
Reply
#9

Can you show your new script along with the exact errors?
Reply
#10

Sure I will post tomorrow soon
Reply
#11

Geez, just put everything in one big array so you can use the array index to set the next checkpoint. Checking every single checkpoint by hand is just a big waste of time and very hard to maintain. When making a change, you only want to do it one place. Not in several different places.

PHP Code:
new const Float:gCheckpoints[][3] = {
    {-
1145.5658,-1045.6901,128.5027},
    {-
1183.2870,-1002.4471,128.5025},
    
// etc, etc
    
{-1145.9674,-1034.9795,128.5025}
};
new 
gCurrentPlayerCheckpoint[MAX_PLAYERS] = {0, ...}; // this stores the id of the currently visible checkpoint 
In OnPlayerEnterRaceCheckpoint, you increment the above player variable by 1. Then you check if it is equal to "sizeof(gCheckpoints)" to check if they've gone through all checkpoints (and thus have finished the race).

If this isn't the case, you proceed to check if the variable is equal to "sizeof(gCheckpoints) - 1" so you can set the "finish flag" on the last checkpoint and prevent an out of bounds error (nextx/y/z referring to a checkpoint that does not exist).

In any other case, you just continue with a normal checkpoint, like so:
PHP Code:
SetPlayerRaceCheckpoint
(
    
playerid
    
0// type
    
gCheckpoints[gCurrentPlayerCheckpoint[playerid]][0], // x
    
gCheckpoints[gCurrentPlayerCheckpoint[playerid]][1], // y
    
gCheckpoints[gCurrentPlayerCheckpoint[playerid]][2], // z
    
gCheckpoints[gCurrentPlayerCheckpoint[playerid] + 1][0], //nextx
    
gCheckpoints[gCurrentPlayerCheckpoint[playerid] + 1][1], //nexty
    
gCheckpoints[gCurrentPlayerCheckpoint[playerid] + 1][2], // nextz
    
6.0 // size
); 
Using this method you can just change the contents of the array without having to worry about anything else.
Reply
#12

Dude then where is IsPlayerInRangeOfPoint ? Because we need to get the 2nd cp after 1st orelse it will not show the 2 nd cp and only 1 cp remain
Reply
#13

my race what i made
Quote:

CMD:kart1(playerid, params[])
{
SetPlayerRaceCheckpoint(playerid, 0, -1145.5658,-1045.6901,128.5027,-1183.2870,-1002.4471,128.5025, 5);
return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, 5, -1145.5658,-1045.6901,128.5027))

{
SetPlayerRaceCheckpoint(playerid, 0, -1183.2870,-1002.4471,128.5025, -1172.3785,-988.5954,128.5025, 5);

}
if(IsPlayerInRangeOfPoint(playerid, 5, -1183.2870,-1002.4471,128.5025))

{
SetPlayerRaceCheckpoint(playerid, 1, -1172.3785,-988.5954,128.5025, -1129.6694,-1018.2800,128.5025, 5);

}
if(IsPlayerInRangeOfPoint(playerid, 5,-1098.4072,-1057.1410,128.4954))
return 1;
}

Errors
Quote:

C:\Users\Tarun\Desktop\Ultimate SAMP KeyBinder\New folder (2)\gamemodes\rp.pwn(111) : warning 209: function "OnPlayerEnterRaceCheckpoint" should return a value
C:\Users\Tarun\Desktop\Ultimate SAMP KeyBinder\New folder (2)\gamemodes\rp.pwn(139) : error 021: symbol already defined: "OnPlayerEnterRaceCheckpoint"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

Reply
#14

Quote:
Originally Posted by fuckingcruse
View Post
Errors
You made an bracket mistake and forgot sth in the cmd, write it like this:

PHP Code:
CMD:kart1(playerid)
{
    
SetPlayerRaceCheckpoint(playerid0, -1145.5658,-1045.6901,128.5027,-1183.2870,-1002.4471,128.50255);
    return 
1;
}
public 
OnPlayerEnterRaceCheckpoint(playerid)
{
    if(
IsPlayerInRangeOfPoint(playerid5, -1145.5658,-1045.6901,128.5027))
    {
        
SetPlayerRaceCheckpoint(playerid0, -1183.2870,-1002.4471,128.5025, -1172.3785,-988.5954,128.50255);
    }
    else if(
IsPlayerInRangeOfPoint(playerid5, -1183.2870,-1002.4471,128.5025))
    {
        
SetPlayerRaceCheckpoint(playerid1, -1172.3785,-988.5954,128.5025, -1129.6694,-1018.2800,128.50255);
    }
    else if(
IsPlayerInRangeOfPoint(playerid5,-1098.4072,-1057.1410,128.4954))
    {
        
//here u made nothing..lol
    
}
    return 
1;

Greekz
Reply
#15

Done got it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)