1st has won the race?
#1

how would i make like if the first person goes in the last race checkpoint would say like Noob has won the race
Player Carbon has finshed second and it keeps going on to the max players for the race heres what i got so far

pawn Код:
case 17:
         {
              DisablePlayerRaceCheckpoint(playerid);
              PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
              SetPlayerRaceCheckpoint(playerid, 1,3825.4634,-2516.0691,46.5305,3829.0635,-2531.2246,52.5604,10);
              Stats[playerid] = 18;
              new name[MAX_PLAYER_NAME], string[100];
              GetPlayerName(playerid, name, sizeof(name));
              format(string, sizeof(string), "Player %s Has Finshed Race [1st]", name ); // how would i make it for all playrs go like player noob has finshed second player carbon has finshed 3rd
              SendClientMessageToAll(ADMIN_RED, string);
              return 1;
         }
Reply
#2

Solved
Reply
#3

this will more likely be an EPIC fail but

pawn Код:
case 17:
         {
              new place;
              DisablePlayerRaceCheckpoint(playerid);
              PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
              SetPlayerRaceCheckpoint(playerid, 1,3825.4634,-2516.0691,46.5305,3829.0635,-2531.2246,52.5604,10);
              Stats[playerid] = 18;
              new name[MAX_PLAYER_NAME], string[100];
              GetPlayerName(playerid, name, sizeof(name));
              format(string, sizeof(string), "Player %s Has Finshed Race [%d]", name, place); // how would i make it for all playrs go like player noob has finshed second player carbon has finshed 3rd
              SendClientMessageToAll(ADMIN_RED, string);
              return 1;
         }
Epic fail but uh at least I'm helping D:
Reply
#4

I think you would do something like

top of your script:
pawn Код:
new Race;
at the start of the race
pawn Код:
Race = 0;
at the end of the race:
pawn Код:
Race ++;
new place = Race;
format(string,sizeof(string),"%s has finished the race %d",name,place);
Send...Message(blah blah );
this sets it so everytime somone finishes the race it sets the race variable +1 and then formats since you set it to 0 at the start of the race, the first player that goes through the finish it will set to 1, the second person it will set to 2 and so on
Reply
#5

pawn Код:
case 17:
         {
              static place;
              place++;
              DisablePlayerRaceCheckpoint(playerid);
              PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
              SetPlayerRaceCheckpoint(playerid, 1,3825.4634,-2516.0691,46.5305,3829.0635,-2531.2246,52.5604,10);
              Stats[playerid] = 18;
              new name[MAX_PLAYER_NAME], string[100];
              GetPlayerName(playerid, name, sizeof(name));
              format(string, sizeof(string), "Player %s Has Finshed Race [%d%s]", name, place, (place == 1) ? ("st") : (place == 2) ? ("nd") : (place == 3) ? ("rd") : ("th")); // how would i make it for all playrs go like player noob has finshed second player carbon has finshed 3rd
              SendClientMessageToAll(ADMIN_RED, string);
              return 1;
         }
Hope it works.

Few notes: This automatically shows "1st", "2nd", "3th", "4th", etc with the correct characters after the number.

Also: You might need to make "place" global (instead of static), or place it at the beginning of the callback so you can reset it to 0 again.
Reply
#6

Solved
Reply
#7

Euh, you could re-define MAX_PLAYERS, or if you mean to get the current amount of players online, set either a variable that increases each time a player joins and decreases when one leaves OR do a loop;

pawn Код:
stock GetPlayersOnline()
{
  new online;
  for(new i; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) online++; }
  return online;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)