Race mode help!
#1

Hi, Sorry for posting many threads. I am making mission stats which will tell how many Races wons, and how many times we have finish it in 1st, 2nd and 3rd pos.
I'm little bit confused how can i count for each position(1st , 2nd, 3rd). Just give me example, i will do it further myself.

CODES:

finished checkpoint
Код:
             case 23:
             {
                    //static place;
                    //place++;
                //==============================================================
                static place;
                static const Scores[] = {7, 5, 4};

                new ScoreAdd = (place >= sizeof(Scores)) ? 3 : Scores[place];

                SetPlayerScore(playerid, GetPlayerScore(playerid) + ScoreAdd);
                //==============================================================
                static const Cash[] = {8000, 6000, 4000};

                new CashAdd = (place >= sizeof(Cash)) ? 2000 : Cash[place];

                GivePlayerMoney(playerid, CashAdd);
                place++;
                //==============================================================
                new string2[128];
                format(string2,sizeof(string2),"{7C7C7C}» You've Recieved %d Points and $%d for Completing the Race.",ScoreAdd, CashAdd);
                SendClientMessage(playerid,-1,string2);
                //==============================================================
                DisablePlayerRaceCheckpoint(playerid);
                AccInfo[playerid][RacesFinish]++;
                PlayerPlaySound(playerid, 1056, 0.0, 0.0 , 10.0);
                Stats[playerid] = 31;
                new name[MAX_PLAYER_NAME], string[128];
                GetPlayerName(playerid, name, sizeof(name));
                format(string, sizeof(string), "{FF6868}» Race: {FF0000}%s {FF6868}finished the race in %d%s place. {FF0000}(%s) (FPS: %d) ", name, place, (place == 1) ? ("st") : (place == 2) ? ("nd") : (place == 3) ? ("rd") : ("th"), ConvertTime(GetTickCount() - rTestcount), pFPS);
                SendClientMessageToAll(green, string);
                DisablePlayerCheckpoint(playerid);
                return 1;
             }
Reply
#2

At the beginning of a race, set a variable to 0. Whenever someone finishes the race, increase the number by 1 and that number will be their finishing position.

To help you understand:
PHP код:
new racepos;
OnRaceStart{
    
racepos 0;
}
OnPlayerFinishRace(playerid){
    
racepos++;
    new 
str[128];
    
format(strsizeof(str), "You finished at position %i"racepos);
    
SendClientMessage(playerid, -1str);

Keep in mind, racepos has to be a global variable!
Reply
#3

wait, i think i have written something in the topic;
i want to count means if i type /mstats - (mission stats), it will show me a msgbox dialog
there it will be, like
Код:
1st position: %d
2nd position: %d
3rd position: %d
it will tell how many races i have finished with 1st pos, 2nd pos, 3rd pos.
hope you understand
Reply
#4

Anyone
Reply
#5

save the postion on player data .-.?
PHP код:
new postion1[MAX_PLAYERS],postion2[MAX_PLAYERS],postion3[MAX_PLAYERS];
OnPlayerFinishRace(playerid){
   for(new 
0MAX_PLAYERSi++) {
    if(
postion1(i) == 0) {
    new 
str[128];
    
format(strsizeof(str), "You finished at position 1");
    
SendClientMessage(playerid, -1str);
    
// your magic to save it here?
    
else if(postion1(i) == && postion2(i) == 0) {
    
format(strsizeof(str), "You finished at position 2"); 
    
SendClientMessage(playerid, -1str);
    
// your magic to save it here?
    
else if(postion1(i) == && postion2(i) == && postion3(i) == 0) {
    
format(strsizeof(str), "You finished at position 3"); 
    
SendClientMessage(playerid, -1str);
    
// your magic to save it here?
  
}
 }

Reply
#6

look i made something like this....
PHP код:
                //==========================================================
                
for(new 0MAX_PLAYERSi++)
                {
                if(
place(i) == 1//764 line
                
{
                new 
str[128];
                
format(strsizeof(str), "You finished at position 1");
                
SendClientMessage(playerid, -1str);
                
AccInfo[playerid][R1st]++;
                else if(
place(i) == 2)
                {
                
format(strsizeof(str), "You finished at position 2");
                
SendClientMessage(playerid, -1str);
                
AccInfo[playerid][2nd]++;
                else if(
place(i) == 3)
                {
                
format(strsizeof(str), "You finished at position 3");
                
SendClientMessage(playerid, -1str);
                
AccInfo[playerid][3rd]++;
                }
               }
             } 
Код:
(764) : error 012: invalid function call, not a valid address
(764) : warning 215: expression has no effect
(764) : error 001: expected token: ";", but found ")"
(764) : error 029: invalid expression, assumed zero
(764) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#7

Quote:
Originally Posted by SpikY_
Посмотреть сообщение
look i made something like this....
PHP код:
                //==========================================================
                
for(new 0MAX_PLAYERSi++)
                {
                if(
place(i) == 1//764 line
                
{
                new 
str[128];
                
format(strsizeof(str), "You finished at position 1");
                
SendClientMessage(playerid, -1str);
                
AccInfo[playerid][R1st]++;
                else if(
place(i) == 2)
                {
                
format(strsizeof(str), "You finished at position 2");
                
SendClientMessage(playerid, -1str);
                
AccInfo[playerid][2nd]++;
                else if(
place(i) == 3)
                {
                
format(strsizeof(str), "You finished at position 3");
                
SendClientMessage(playerid, -1str);
                
AccInfo[playerid][3rd]++;
                }
               }
             } 
Код:
(764) : error 012: invalid function call, not a valid address
(764) : warning 215: expression has no effect
(764) : error 001: expected token: ";", but found ")"
(764) : error 029: invalid expression, assumed zero
(764) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
you made : new place; or new place[MAX_PLAYERS]; ?
Reply
#8

there is
Код:
static place;
Reply
#9

Quote:
Originally Posted by SpikY_
Посмотреть сообщение
there is
Код:
static place;
hmmm instead (i) use [i] like >>
PHP код:
                //==========================================================
                
for(new 0MAX_PLAYERSi++)
                {
                if(
place[i] == 1//764 line
                
{
                new 
str[128];
                
format(strsizeof(str), "You finished at position 1");
                
SendClientMessage(playerid, -1str);
                
AccInfo[playerid][R1st]++;
                else if(
place[i] == 2)
                {
                
format(strsizeof(str), "You finished at position 2");
                
SendClientMessage(playerid, -1str);
                
AccInfo[playerid][2nd]++;
                else if(
place[i] == 3)
                {
                
format(strsizeof(str), "You finished at position 3");
                
SendClientMessage(playerid, -1str);
                
AccInfo[playerid][3rd]++;
                }
               }
             } 
Reply
#10

still same errors
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)