Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Ryder Race small help.

$
0
0
Hi guys,

It might be a problem for me as i am not a even good coder, so i'l looking for help from a good coders. I won't call this a problem, just a small fix. I'm using Ryder race system, and there is a record system made for many persons but i want only one person can broke a record.

I'll looks like this when a record i made/broken (Check below). So, this race system saving a 5 persons with broken record (I want it be only for one person not 5)

Now it looks like this:

Code:

BestRacerTime_0=23614
BestRacer_0=Hunud
BestRacerTime_1=0
BestRacer_1=noone
BestRacerTime_2=0
BestRacer_2=noone
BestRacerTime_3=0
BestRacer_3=noone
BestRacerTime_4=0
BestRacer_4=noone

But i want it to be like this. Only one record saved from 1 person

Code:

BestRacerTime_0=23614
BestRacer_0=Hunud

CODES:

Code:

public OnPlayerEnterRaceCheckpoint(playerid)
{
        if(CPProgess[playerid] == TotalCP -1)
        {
                new
                    TimeStamp,
                    TotalRaceTime,
                    string[256],
                    rFile[256],
                    pName[MAX_PLAYER_NAME],
                        rTime[3],
                        Prize[2],
                        TempTotalTime,
                        TempTime[3]
                ;
                Position++;
                GetPlayerName(playerid, pName, sizeof(pName));
                TimeStamp = GetTickCount();
                TotalRaceTime = TimeStamp - RaceTick;
                ConvertTime(var, TotalRaceTime, rTime[0], rTime[1], rTime[2]);
                switch(Position)
                {
                    case 1: Prize[0] = (random(random(5000)) + 10000), Prize[1] = 10;
                    case 2: Prize[0] = (random(random(4500)) + 9000), Prize[1] = 9;
                    case 3: Prize[0] = (random(random(4000)) + 8000), Prize[1] = 8;
                    case 4: Prize[0] = (random(random(3500)) + 7000), Prize[1] = 7;
                    case 5: Prize[0] = (random(random(3000)) + 6000), Prize[1] = 6;
                    case 6: Prize[0] = (random(random(2500)) + 5000), Prize[1] = 5;
                    case 7: Prize[0] = (random(random(2000)) + 4000), Prize[1] = 4;
                    case 8: Prize[0] = (random(random(1500)) + 3000), Prize[1] = 3;
                    case 9: Prize[0] = (random(random(1000)) + 2000), Prize[1] = 2;
                    default: Prize[0] = random(random(1000)), Prize[1] = 1;
                }
                format(string, sizeof(string), ">> \"%s\" has finished the race in position \"%d\".", pName, Position);
                SendClientMessageToAll(WHITE, string);
                format(string, sizeof(string), "    - Time: \"%d:%d.%d\".", rTime[0], rTime[1], rTime[2]);
                SendClientMessageToAll(WHITE, string);
                format(string, sizeof(string), "    - Prize: \"$%d and +%d Score\".", Prize[0], Prize[1]);
                SendClientMessageToAll(WHITE, string);
               
                if(FinishCount <= 5)
                {
                        format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", RaceName);
                    format(string, sizeof(string), "BestRacerTime_%d", TimeProgress);
                    TempTotalTime = dini_Int(rFile, string);
                    ConvertTime(var1, TempTotalTime, TempTime[0], TempTime[1], TempTime[2]);
                    if(TotalRaceTime <= dini_Int(rFile, string) || TempTotalTime == 0)
                    {
                        dini_IntSet(rFile, string, TotalRaceTime);
                                format(string, sizeof(string), "BestRacer_%d", TimeProgress);
                        if(TempTotalTime != 0) format(string, sizeof(string), ">> \"%s\" has broken the record of \"%s\" with \"%d\" seconds faster on the \"%d\"'st/th place!", pName, dini_Get(rFile, string), -(rTime[1] - TempTime[1]), TimeProgress+1);
                                        else format(string, sizeof(string), ">> \"%s\" has broken a new record of on the \"%d\"'st/th place!", pName, TimeProgress+1);
                SendClientMessageToAll(GREEN, "  ");
                                SendClientMessageToAll(GREEN, string);
                                SendClientMessageToAll(GREEN, "  ");
                                format(string, sizeof(string), "BestRacer_%d", TimeProgress);
                                dini_Set(rFile, string, pName);
                                TimeProgress++;
                    }
                }
                FinishCount++;
                GivePlayerMoney(playerid, Prize[0]);
                SetPlayerScore(playerid, GetPlayerScore(playerid) + Prize[1]);
                DisablePlayerRaceCheckpoint(playerid);
                CPProgess[playerid]++;
                if(FinishCount >= JoinCount) return StopRace();
    }
        else
        {
                CPProgess[playerid]++;
                CPCoords[CPProgess[playerid]][3]++;
                RacePosition[playerid] = floatround(CPCoords[CPProgess[playerid]][3], floatround_floor);
            SetCP(playerid, CPProgess[playerid], CPProgess[playerid]+1, TotalCP, RaceType);
            PlayerPlaySound(playerid, 1137, 0.0, 0.0, 0.0);
        }
    return 1;
}

Code:

        if(newkeys & KEY_SECONDARY_ATTACK)
        {
            if(BuildTakeCheckpoints == true)
            {
                ShowDialog(playerid, 606);
                        format(rNameFile, sizeof(rNameFile), "/rRaceSystem/RaceNames/RaceNames.txt");
                        TotalRaces = dini_Int(rNameFile, "TotalRaces");
                        TotalRaces++;
                        dini_IntSet(rNameFile, "TotalRaces", TotalRaces);
                        format(string, sizeof(string), "Race_%d", TotalRaces-1);
                        format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", BuildName);
                        dini_Set(rNameFile, string, BuildName);
                        dini_IntSet(rFile, "TotalCP", BuildCheckPointCount);
                        Loop(x, 5)
                        {
                                format(string, sizeof(string), "BestRacerTime_%d", x);
                                dini_Set(rFile, string, "0");
                                format(string, sizeof(string), "BestRacer_%d", x);
                                dini_Set(rFile, string, "noone");
                        }
            }
        }
        return 1;
}

I hope you will help me. I'll reward a person/s with cookie(REP) who will solved this "problem" Thanks

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>