Highscore
#1

i have a race script and i dont know how i can script a highscore.

any ideas?

My race win code:

pawn Code:
public OnPlayerEnterRaceCheckpoint(playerid)
    {
    ...
    case finish:
    {
    new RTime = GetTickCount()-StartTickcount;
    new Min, Sec, Mil;
    ConvertTime(RTime, Min, Sec, Mil);
    if(position == 1)
    {
    GivePlayerMoney(playerid,10000);
    GetPlayerName(playerid, rank_1,sizeof(rank_1));
    format(string, sizeof(string), "Winner in %01d:%02d:%02d are %s",Min, Sec, Mil, rank_1);
    SendClientMessageToAll(blue, string);
    format(string, sizeof(string), "%s, you win: $10000",rank_1);
    SendClientMessage(playerid,blue, string);
    }

    if(position == 2)
    {
    GivePlayerMoney(playerid,6000);
    GetPlayerName(playerid, rank_2,sizeof(rank_2));
    format(string, sizeof(string), "2. in %01d:%02d:%02d are: %s ",Min, Sec, Mil, rank_2);
    SendClientMessageToAll(blue, string);
    format(string, sizeof(string), "%s, you win: $6000",rank_2);
    SendClientMessage(playerid,blue, string);
    }

    if(position == 3)
    {
    GivePlayerMoney(playerid,2000);
    GetPlayerName(playerid, rank_3,sizeof(rank_3));
    format(string, sizeof(string), "3. in %01d:%02d:%02d are: %s ",Min, Sec, Mil, rank_3);
    SendClientMessageToAll(blue, string);
    format(string, sizeof(string), "%s, you win: $2000",rank_3);
    SendClientMessage(playerid,blue, string);
    }
    DisablePlayerRaceCheckpoint(playerid);
    race[playerid] = 0;
    position++;
    racesticket[playerid] = 0;
    racecheck[playerid]=0;
    SetTimer("RestTime", 30000, 0);
    }
    }
Reply
#2

nobody?
Reply
#3

omg...

plz help..

need you more information about the race win, say it.
Reply
#4

Try something like:

//Global:
Code:
new RacePositions[3];
//This should be in the part where the race starts;
Code:
RacePositions[0] = -1;
RacePositions[1] = -1;
RacePositions[2] = -1;
Code:
public OnPlayerEnterRaceCheckpoint(playerid)
{
  ...
  case finish:
  {
    if(RacePositions[0] == -1)
    {
      RacePositions[0] = playerid;
      position = 1;
    }
    else if(RacePositions[1] == -1)
    {
      RacePositions[1] = playerid;
      position = 2;
    }
    else if(RacePositions[2] == -1)
    {
      RacePositions[2] = playerid;
      position = 3;
    }   
    //Rest of that callback....
  }
}
Reply
#5

hehe thx for your code.

but i search a highscore script, i have the time how long the player are racing too.

Example:
The currently highscore are 1:20:765.
I win the race in 1:15:654, than are the highscore is 1:15:654.
Reply
#6

Quote:
Originally Posted by =>Sandra<=
Try something like:

//Global:
Code:
new RacePositions[3];
//This should be in the part where the race starts;
Code:
RacePositions[0] = -1;
RacePositions[1] = -1;
RacePositions[2] = -1;
Code:
public OnPlayerEnterRaceCheckpoint(playerid)
{
  ...
  case finish:
  {
    if(RacePositions[0] == -1)
    {
      RacePositions[0] = playerid;
      position = 1;
    }
    else if(RacePositions[1] == -1)
    {
      RacePositions[1] = playerid;
      position = 2;
    }
    else if(RacePositions[2] == -1)
    {
      RacePositions[2] = playerid;
      position = 3;
    }   
    //Rest of that callback....
  }
}
Or, what I did for my script was just use two variables. Both store how many players are in the race when it starts, but one of them subtracts as players exit the race. When someone finishes, you subtract the one that subtracts from the one that doesn't.
Reply
#7

Quote:
Originally Posted by backwardsman97
Quote:
Originally Posted by =>Sandra<=
Try something like:

//Global:
Code:
new RacePositions[3];
//This should be in the part where the race starts;
Code:
RacePositions[0] = -1;
RacePositions[1] = -1;
RacePositions[2] = -1;
Code:
public OnPlayerEnterRaceCheckpoint(playerid)
{
  ...
  case finish:
  {
    if(RacePositions[0] == -1)
    {
      RacePositions[0] = playerid;
      position = 1;
    }
    else if(RacePositions[1] == -1)
    {
      RacePositions[1] = playerid;
      position = 2;
    }
    else if(RacePositions[2] == -1)
    {
      RacePositions[2] = playerid;
      position = 3;
    }  
    //Rest of that callback....
  }
}
Or, what I did for my script was just use two variables. Both store how many players are in the race when it starts, but one of them subtracts as players exit the race. When someone finishes, you subtract the one that subtracts from the one that doesn't.


I dont understand you.

I only need a Highscore, the time, how long the player are racing, are included.
I only need the best time, that the highscore are saving.

Example:

I type /race than come Sendclientmessage.......

1. 1:20:647 - Ribber
2. 0:00:000 - Nobody
3. 0:00:000 - Nobody
Reply
#8

...
Reply
#9

Reply
#10

have the same problem, i tried to use gettick and GetTickCount (both the same on windows) and after this to convert the time into min,sec,milisec, but i always return 0, example:

0:0.0

pawn Code:
public OnPlayerEnterRaceCheckpoint(playerid)
{
    new time = 0;
    if(CURRENTCP[playerid] == 1)
    {
        time = GetTickCount();
    }
    RaceInfo[Checkpoints] = dini_Int("/Races/CurrentRace.txt","Checkpoints");
    new MAXRACECPS = RaceInfo[Checkpoints];
   
    if(CURRENTCP[playerid] == MAXRACECPS)
    {
        new min1,sec,milis;
      ConvertTime(time,min1,sec,milis);
      DisablePlayerRaceCheckpoint(playerid);
        new name[24],string[128];
      GetPlayerName(playerid,name,24);
      format(string,128,"%s finished first :O(%d:%d.%d)",name,min1,sec,milis);
      SendClientMessage(playerid,THIAZ_YELLOW,string);
      PlayerPlaySound(playerid, 1076, 0.0, 0.0, 0.0);
     
    }
pawn Code:
stock ConvertTime(time, &minutes, &seconds, &milliseconds)
{
    for(new i; i<1000; i++) {
    if(time >= 1000) {
      time = time-1000;
      seconds++;
      if(seconds == 60) {
        seconds = 0;
        minutes++;
      }
    }else{
      milliseconds = time;
      break;
    }
  }
}
need help,

greetz
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)