How to make a simple non vehicle race ?
#1

....
Reply
#2

https://sampwiki.blast.hk/wiki/SetPlayerRaceCheckpoint

and

https://sampwiki.blast.hk/wiki/OnPlayerEnterRaceCheckpoint

Very simple.

Edit:
To show the three best times you can do something like this:

pawn Код:
new FP,FPName[MAX_PLAYER_NAME],FPTime;
new SP,SPName[MAX_PLAYER_NAME],SPTime;
new TP,TPName[MAX_PLAYER_NAME],TPTime;
new RaceStart;

CMD:StartRace(playerid,params[])
{
    if(RaceStart < 0)
    {
        RaceStart = GetTickCount();
        SendClientMessageToAll(COLOR_RED, "The race has started!");
    }
    else
    {
        RaceStart = -1;
        FP = 0;
        SP = 0;
        TP = 0;
        FPTime = 0;
        SPTime = 0;
        TPTime = 0;
    }
    return RaceStart;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    if(FP == 0)
    {
        new string[126];
        FP = 1;
        FPTime = GetTickCount() - RaceStart;
        GetPlayerName(playerid, FPName, sizeof(FPName));
        format(string, sizeof(string), "%s has come in first place, with the time of %i", FPName,FPTime);
        SendClientMessageToAll(COLOR_GREEN, string);
    }
    else if(SP == 0)
    {
        new string[126];
        SP = 1;
        SPTime = GetTickCount() - RaceStart;
        GetPlayerName(playerid, SPName, sizeof(SPName));
        format(string, sizeof(string), "%s has come in second place, with the time of %i", SPName,SPTime);
        SendClientMessageToAll(COLOR_GREEN, string);
    }
    else if(TP == 0)
    {
        new string[126];
        TP = 1;
        TPTime = GetTickCount() - RaceStart;
        GetPlayerName(playerid, TPName, sizeof(TPName));
        format(string, sizeof(string), "%s has come in third place, with the time of %i", TPName,TPTime);
        SendClientMessageToAll(COLOR_GREEN, string);
    }
    else if(FP > 0 && SP > 0 && TP > 0)
    {
        new string[126], Name[MAX_PLAYER_NAME], Time;
        GetPlayerName(playerid, Name, sizeof(Name));
        Time = GetTickCount() - RaceStart;
        format(string, sizeof(string), "%s has finished the race with the time of %i", Name, Time);
        SendClientMessageToAll(COLOR_GREEN, string);
    }
    return 1;
}
Reply
#3

Thank you so much !
Reply
#4

You're quite welcome my dear gentlemen.
Reply
#5

One more thing. How to make checkpoint like in 0:34 for a human ? Thanks
https://www.youtube.com/watch?v=8IWJ_8BPeKw
Reply
#6

Код:
SetPlayerRaceCheckpoint(playerid, type, Float:x, Float:y, Float:z, Float:nextx, Float:nexty, Float:nextz, Float:size)
If you want to change the type of Checkpoint, just change 'type'.
Example:
You might have:
pawn Код:
SetPlayerRaceCheckpoint(playerid, 1, ...);
Just change the 1 to a 3 if you are looking for a circle-like checkpoint.

So
pawn Код:
SetPlayerRaceCheckpoint(playerid, 3, etc...)
wiki.sa-mp.com/wiki/SetPlayerRaceCheckpoint explains what the type of checkpoints are.
The checkpoint type you are looking for is, 'Air Normal'.
Reply
#7

Oh now i look like .. when you open fridge and can't find any food because i already checked this
Thank you !
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)