@@ -244,6 +244,37 @@ function RaceMode:onPlayerReachCheckpoint(player, checkpointNum)
244
244
RaceMode .setPlayerIsFinished (player )
245
245
finishActivePlayer ( player )
246
246
setPlayerStatus ( player , nil , " finished" )
247
+
248
+ local name = getPlayerName (player )
249
+ local message
250
+ local killmessage
251
+
252
+ if rank == 1 then
253
+ message = " You have won the race!"
254
+ killmessage = string.format (" %s won the race!" , name )
255
+ else
256
+ local suffix
257
+ local last = rank % 10
258
+ local exception = rank % 100 >= 11 and rank % 100 <= 13
259
+
260
+ if exception then
261
+ suffix = " th"
262
+ else
263
+ if last == 1 then
264
+ suffix = " st"
265
+ elseif last == 2 then
266
+ suffix = " nd"
267
+ elseif last == 3 then
268
+ suffix = " rd"
269
+ else
270
+ suffix = " th"
271
+ end
272
+ end
273
+
274
+ message = string.format (" You finished %s %s." , rank , suffix )
275
+ killmessage = string.format (" %s finished %s %s." , rank , suffix )
276
+ end
277
+
247
278
if rank == 1 then
248
279
gotoState (' SomeoneWon' )
249
280
showMessage (' You have won the race!' , 0 , 255 , 0 , player )
@@ -255,17 +286,23 @@ function RaceMode:onPlayerReachCheckpoint(player, checkpointNum)
255
286
self :setTimeLeft ( g_GameOptions .timeafterfirstfinish )
256
287
end
257
288
else
258
- showMessage (' You finished ' .. rank .. ( ( rank < 10 or rank > 20 ) and ({ [ 1 ] = ' st ' , [ 2 ] = ' nd ' , [ 3 ] = ' rd ' })[ rank % 10 ] or ' th ' ) .. ' ! ' , 0 , 255 , 0 , player )
289
+ showMessage (message , 0 , 255 , 0 , player )
259
290
end
260
- -- Output a killmessage
291
+
261
292
exports .killmessages :outputMessage (
262
293
{
263
- {" image" ,path = " img/killmessage.png" ,resource = getThisResource (),width = 24 },
264
- getPlayerName (player ),
294
+ victim = {
295
+ text = killmessage ,
296
+ color = {255 , 255 , 255 }
297
+ },
298
+ icon = {
299
+ path = " :race/img/killmessage.png" ,
300
+ width = 24
301
+ },
265
302
},
266
- root ,
267
- 255 ,0 ,0
303
+ root
268
304
)
305
+
269
306
self .rankingBoard :add (player , time )
270
307
if getActivePlayerCount () > 0 then
271
308
TimerManager .createTimerFor (" map" ,player ):setTimer (clientCall , 5000 , 1 , player , ' Spectate.start' , ' auto' )
0 commit comments