Race Postion Ingame (Rep +2)
#1

Hello everyone! i am currently working on race gm, and my aim is to make like this..:
Screen taken from Adrenaline (Racing)


The position which i am, ex:1 ,2, 3
Need help in that, rep ++ for best ans.

pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
new gTotalRacers;
new Text:MPlayers[MAX_PLAYERS];
new Text:RPos;
new PCar1;
new PCar2;
new PCar3;
new PCar4;
new PCar5;
new Racer[MAX_PLAYERS];

main()
{
    print("\n----------------------------------");
    print(" Race GameMode");
    print("----------------------------------\n");
}

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Race");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);

    RPos = TextDrawCreate(534.000000, 335.000000, "0");
    TextDrawBackgroundColor(RPos, 255);
    TextDrawFont(RPos, 1);
    TextDrawLetterSize(RPos, 0.529999, 3.799998);
    TextDrawColor(RPos, -470031446);
    TextDrawSetOutline(RPos, 1);
    TextDrawSetProportional(RPos, 1);
   
    PCar1 = AddStaticVehicleEx(596,825.70001221,-1981.80004883,12.69999981,0.00000000,-1,-1,999999); //Police Car (LSPD)
    PCar2 = AddStaticVehicleEx(596,830.00000000,-1981.69995117,12.69999981,0.00000000,-1,-1,999999); //Police Car (LSPD)
    PCar3 = AddStaticVehicleEx(596,834.50000000,-1981.69995117,12.69999981,0.00000000,-1,-1,999999); //Police Car (LSPD)
    PCar4 = AddStaticVehicleEx(596,839.59997559,-1981.50000000,12.69999981,0.00000000,-1,-1,999999); //Police Car (LSPD)
    PCar5 = AddStaticVehicleEx(596,844.40002441,-1981.40002441,12.69999981,0.00000000,-1,-1,999999); //Police Car (LSPD)

    for(new playerid; playerid < MAX_PLAYERS; playerid++)
    {
        MPlayers[playerid] = TextDrawCreate(551.000000, 358.000000, "    /32");
        TextDrawAlignment(MPlayers[playerid], 2);
        TextDrawBackgroundColor(MPlayers[playerid], 255);
        TextDrawFont(MPlayers[playerid], 1);
        TextDrawLetterSize(MPlayers[playerid], 0.440000, 1.300000);
        TextDrawColor(MPlayers[playerid], -1);
        TextDrawSetOutline(MPlayers[playerid], 0);
        TextDrawSetProportional(MPlayers[playerid], 1);
        TextDrawSetShadow(MPlayers[playerid], 1);
    }
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    gTotalRacers++;
    new tmp[5];
    format(tmp,5,"/%d",gTotalRacers);
    TextDrawSetString(MPlayers[playerid],tmp);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    gTotalRacers--;
    new tmp[5];
    format(tmp,5,"/%d",gTotalRacers);
    TextDrawSetString(MPlayers[playerid],tmp);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid, MPlayers[playerid]);
    TextDrawShowForPlayer(playerid, RPos);
    SetPlayerRaceCheckpoint(playerid, 0,835.374389,-1859.481933,12.587397,812.102172,-1774.344116,13.203566,10);
    Racer[playerid] = 1;
    if(playerid == 0)
    {
        PutPlayerInVehicle(playerid,PCar1, 0);
    }
    else if(playerid == 1)
    {
        PutPlayerInVehicle(playerid,PCar2, 0);
    }
    else if(playerid == 2)
    {
        PutPlayerInVehicle(playerid,PCar3, 0);
    }
    else if(playerid == 3)
    {
        PutPlayerInVehicle(playerid,PCar4, 0);
    }
    else if(playerid == 4)
    {
        PutPlayerInVehicle(playerid,PCar5, 0);
    }
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    switch(Racer[playerid])
    {
        case 1:
        {
            DisablePlayerRaceCheckpoint(playerid);
            PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
            SetPlayerRaceCheckpoint(playerid, 0,812.102172,-1774.344116,13.203566,813.857421,-1645.215332,13.103794,10);
            Racer[playerid] = 2;
            return 1;
        }
        case 2:
        {
            DisablePlayerRaceCheckpoint(playerid);
            PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
            SetPlayerRaceCheckpoint(playerid, 0,813.857421,-1645.215332,13.103794,879.339782,-1575.621704,13.099643,10);
            Racer[playerid] = 3;
            return 1;
        }
        case 3:
        {
            DisablePlayerRaceCheckpoint(playerid);
            PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
            SetPlayerRaceCheckpoint(playerid, 0,879.339782,-1575.621704,13.099643,1036.568481,-1572.104003,13.110089,10);
            Racer[playerid] = 4;
            return 1;
        }
        case 4:
        {
            DisablePlayerRaceCheckpoint(playerid);
            PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
            SetPlayerRaceCheckpoint(playerid, 0,1036.568481,-1572.104003,13.110089,1288.525878,-1569.905395,13.107045,10);
            Racer[playerid] = 5;
            return 1;
        }
        case 5:
        {
            DisablePlayerRaceCheckpoint(playerid);
            PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
            SetPlayerRaceCheckpoint(playerid, 0,1288.525878,-1569.905395,13.107045,1310.379760,-1548.127563,13.188509,10);
            Racer[playerid] = 6;
            return 1;
        }
    }
    return 1;
}
Reply
#2

k, I join this question. I was searching for this 'function' a long time ago, and found nothing.
Reply
#3

Ok, let me put this out in pseudo code:

Код:
new racepos[MAX_PLAYERS];

Max player loop
    if (current player checkpoint > current idx checkpoint) && racepos player != 1
        racepos playerid --
    else if current player checkpoint < current idx checkpoint
        racepos playerid ++
    else
        get pos of the active checkpoint
        get distance of player to checkpoint
        get distance of idx to checkpoint

        if (distance player < distance idx) && racepos player != 1
            racepos player --
        else
            racepos player ++
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
Ok, let me put this out in pseudo code:

Код:
new racepos[MAX_PLAYERS];

Max player loop
    if (current player checkpoint > current idx checkpoint) && racepos player != 1
        racepos playerid --
    else if current player checkpoint < current idx checkpoint
        racepos playerid ++
    else
        get pos of the active checkpoint
        get distance of player to checkpoint
        get distance of idx to checkpoint

        if (distance player < distance idx) && racepos player != 1
            racepos player --
        else
            racepos player ++
pseudo code ??
i m working on pawn code, can u make that in pawn code??
Reply
#5

Quote:
Originally Posted by Wikipedia
Pseudocode (sometimes written as pseudo-code) is a form of source code that is written for humans, not machines, to read. It is often written to show how an algorithm works.
It's up to you to make it, I'm not your slave.
Reply
#6

ohh thanks i know that you are not slave :P lol
how to get distance of player??
Reply
#7

Vince, you should release this script, a ton of scripters were trying to script this thing and most of them failed. SHARE THE SCRIPT, PLZZZZZZZZZZZZZZZZZZ
Reply
#8

@***** i didnt understand, can you code me how to set the inrace positons of players via textdraw...
Reply
#9

Sameer.. just read their tips, then read samp wiki and put some effort in it.
Reply
#10

actually where are the tips??
i didnt find any..
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)