The online racing simulator
F1 style Winner button (2 versions)
For V5.844

This is version 2.

I've now done a new layout for the button (Version 3) - see bottom of this post.

Original version 1 worked, just that I never allowed for people getting penalties. I drove very proper when I tested it!

You can ignore a lot of the posts on this page that go into vast detail of where I went wrong.


Buttons that pops up at end of race with position = 1/Winner/drivers name. 2/Runner Up/drivers name. 3/3rd Place/drivers name.

----------------------------------
|... | Winner............................. |
| 1 |-----------------------------|
| .. | Drivers Name in here........... |
----------------------------------

Bit like when you've watched race on tv and leading driver goes over finish line.

CREDITS:

Sinanju
----------
Idea (original or not), button formatting, including sizing, colouring and placement

Tim[NL]
-----------
ALL the difficult programming bits, advice, good will, etc.



Open up your LFSLapper.lpr file.

In the Action on Qual and race section, look for the Event OnResult( $flagConfirm ) section, that ends with EndEvent.

Paste main part of code there.

Included is English and French for pasting in the correct LANG section.

I hope my French translations ok. Easy enough to change if I've used wrong words.


Remember; no guarantees. All should work, but in case it doesn't, use at your own risk! In case it all goes horribly wrong, reload your saved lapper config file. The one you saved before you changed the coding. Right?

Little extra detail:
If only 2 in the race, you only get Winner and 2nd place flags popping up.

Flags only on for 10 seconds. So if first place finishes 11 seconds in front of 2nd, then it will go off before 2nd place flag goes on (underneath where winner flag was). You might want to think about keeping winner flag on few seconds longer than other flags. It would be very easy to add more flags (4 = better luck next time 5 = also ran, etc - as derogatory or as encouraging as you like).

===============================================
Version 3
---------
Slightly different look, but layout still same (your finish number on left/finish position top right/driver name bottom right).

Flags slightly smaller too - helps people still finishing race.

(Many thanks to the people who visited my server and gave me feedback on the flags).

Nearly everything same as previous version, except the look. See image.

Saved as text file - copy/cut and paste into relevant sections.

Same caveats; save, risk, etc.
Attached images
Winner Button.PNG
Winner Flag.PNG
winner flags.PNG
Winner Flags v3.PNG
Attached files
winner flag.txt - 5.3 KB - 213 views
Winner Flags v3.txt - 6.1 KB - 211 views
Being a VB programmer... for 8 years...

I just realized now that Insim looks like a mix between C and VB...

I never touched insim once. perhaps I should
Yeah right. InSim is a protocol/interface, not a programming language :doh:
You can write InSim applications in any language that supports TCP/UDP packets.
Quote from sinanju :For V5.844

Button that pops up at end of race with position = 1/Winner/drivers name.

-------------------------------------------
|... | Winner................................. |
| 1 |-------------------------------------|
| .. | Drivers Name in here........... |
-------------------------------------------

Bit like when you've watched race on tv and leading driver goes over finish line.

Many thanks to Fire_optikz001 for spotting my silly bug.

Look for the Event OnResult( $flagConfirm ) section, that ends with EndEvent.

Substitute all of following code:

Hi,
You winner flag looks very nice but to be sure that who won the race is really the winner you must use the $flagConfirm to. If the winner have a SG or DT penalty he can show up as a winner but he is disqualified in the race.
So the confirm flag must be 2 or 2+16 or 2+32.

Event OnResult confirm flags
CONF_MENTIONED 1
CONF_CONFIRMED 2
CONF_PENALTY_DT 4
CONF_PENALTY_SG 8
CONF_PENALTY_30 16
CONF_PENALTY_45 32
CONF_DID_NOT_PIT 64

Event OnResult( $flagConfirm )

SWITCH( GetCurrentPlayerVar("FinishedPos") )
CASE 1:
IF(( $flagConfirm == 2 )||( $flagConfirm == 18 )||( $flagConfirm == 34 ))
THEN
openGlobalButton( "winner_backing",66,136,74,34,3,10,32," ");
openGlobalButton( "number_1",67,137,10,32,3,10,16,"^01");
openGlobalButton( "winner_title",78,137,62,19,4,10,96,langEngine( "%{main_winnertitle}%" ));
openGlobalButton( "winner_name",78,156,58,12,3,10,64,langEngine( "%{main_winnername}%",$WinnerName));

openGlobalButton( "white_banner1",108,137,32,18,1,10,16," ");
openGlobalButton( "white_banner2",108,137,32,18,1,10,16," ");
openGlobalButton( "white_banner3",108,137,32,18,1,10,16," ");

openGlobalButton( "black_banner1",136,137,4,6,1,10,32," ");
openGlobalButton( "black_banner2",136,137,4,6,1,10,32," ");
openGlobalButton( "black_banner3",136,137,4,6,1,10,32," ");

openGlobalButton( "black_banner4",112,137,4,6,1,10,32," ");
openGlobalButton( "black_banner5",112,137,4,6,1,10,32," ");
openGlobalButton( "black_banner6",112,137,4,6,1,10,32," ");

openGlobalButton( "black_banner7",120,137,4,6,1,10,32," ");
openGlobalButton( "black_banner8",120,137,4,6,1,10,32," ");
openGlobalButton( "black_banner9",120,137,4,6,1,10,32," ");

openGlobalButton( "black_banner10",128,137,4,6,1,10,32," ");
openGlobalButton( "black_banner11",128,137,4,6,1,10,32," ");
openGlobalButton( "black_banner12",128,137,4,6,1,10,32," ");

openGlobalButton( "black_bannera",108,143,4,6,1,10,32," ");
openGlobalButton( "black_bannerb",108,143,4,6,1,10,32," ");
openGlobalButton( "black_bannerc",108,143,4,6,1,10,32," ");

openGlobalButton( "black_bannerd",116,143,4,6,1,10,32," ");
openGlobalButton( "black_bannere",116,143,4,6,1,10,32," ");
openGlobalButton( "black_bannerf",116,143,4,6,1,10,32," ");

openGlobalButton( "black_bannerg",124,143,4,6,1,10,32," ");
openGlobalButton( "black_bannerh",124,143,4,6,1,10,32," ");
openGlobalButton( "black_banneri",124,143,4,6,1,10,32," ");

openGlobalButton( "black_bannerj",132,143,4,6,1,10,32," ");
openGlobalButton( "black_bannerk",132,143,4,6,1,10,32," ");
openGlobalButton( "black_bannerl",132,143,4,6,1,10,32," ");

openGlobalButton( "black_bannera1",136,149,4,6,1,10,32," ");
openGlobalButton( "black_bannera2",136,149,4,6,1,10,32," ");
openGlobalButton( "black_bannera3",136,149,4,6,1,10,32," ");

openGlobalButton( "black_bannera4",112,149,4,6,1,10,32," ");
openGlobalButton( "black_bannera5",112,149,4,6,1,10,32," ");
openGlobalButton( "black_bannera6",112,149,4,6,1,10,32," ");

openGlobalButton( "black_bannera7",120,149,4,6,1,10,32," ");
openGlobalButton( "black_bannera8",120,149,4,6,1,10,32," ");
openGlobalButton( "black_bannera9",120,149,4,6,1,10,32," ");

openGlobalButton( "black_bannera10",128,149,4,6,1,10,32," ");
openGlobalButton( "black_bannera11",128,149,4,6,1,10,32," ");
openGlobalButton( "black_bannera12",128,149,4,6,1,10,32," ");
ENDIF
BREAK;
DEFAULT:
BREAK;
ENDSWITCH

EndEvent

Quote from CodieMorgan :Being a VB programmer... for 8 years...

I just realized now that Insim looks like a mix between C and VB...

I never touched insim once. perhaps I should

It's LFSLapper scripting language, not InSim.
-
(Nick.) DELETED by Nick.
Thats nice!
Quote from Tim NL :Hi,
You winner flag looks very nice but to be sure that who won the race is really the winner you must use the $flagConfirm to.

Hi Tim[NL]
I should have thought it was a bit too easy!

In truth, I never gave penalties much thought. I was just thinking that if the event is called Event OnResult( $flagConfirm), then it would give me the same results as LFS does (as shown in LFS table at top right of screen when race complete).

Looking at the complicated code (cloud code - ie way over my head!), have you got something like this already implemented on your server?

Couple of things about your code:

I had $WinnerName = GetCurrentPlayerVar("NickName"); then put this name in one of the buttons (openGlobalButton( "winner_name",78,156,58,12,3,10,64,langEngine( "%{main_winnername}%",$WinnerName));).

That line of code no longer exists in your version, so do I need to change this $WinnerName back to "NickName"?

Does CASE 1 mean the 1st player to finish (after allowing for penalties)?

Just that I'm working on coding to have top 3 results show as flags. Do I need to use Case 1, Case 2 and Case 3 for the 3 results?

Thanks.
Quote from aroX123 :I suggested this a while ago

Hi

The winner flag was something I just thought of at weekend.

However, it probably could be made to look like it's moving across the screen (you'd need to draw it, update and re-draw it a bit left, update and re-draw again further left, update and re-draw.....).

And as you can see in previous posts, the coding is a bit complicated, so that's me out!

However. I don't think it would be smooth like you see on tv, as all I could do was show the buttons for minimum of 1 second a time. Might not matter to some.

But there is another issue, which Krayy advised on reply to my bug report about time going missing in a countdown timer (see Krayy's post http://www.lfsforum.net/showthread.php?p=1251250#post1251250, which he thinks is a latency issue).

There are some other issues.

Believe it or not, some drivers absolutely hate seeing other buttons and graphix cluttering up the screen - happy enough probably when watching races, but don't like it when they're racing. However, saying that, it should be possible I suppose to code it so that only spectators see it.

Other issue is sheer number of buttons now starting to clutter the screen.
Some discussion on how many can be there at any one time (maybe 239?), but if I have the pitboard made by Yisc[NL] on at same time as my drift meter, and my leaderboard, I'm running out of buttons. I already have to close something (usually pitboard) when I want to put the gui config screen on made by Tim[NL].

Even a simplifies version of my winner flag would probably still use at least 16 buttons up (I'd need to delete the additional overlay buttons that give better black and white contrast).
Quote from sinanju :Hi Tim[NL]
I should have thought it was a bit too easy!
In truth, I never gave penalties much thought. I was just thinking that if the event is called Event OnResult( $flagConfirm), then it would give me the same results as LFS does (as shown in LFS table at top right of screen when race complete).
Looking at the complicated code (cloud code - ie way over my head!), have you got something like this already implemented on your server?
Couple of things about your code:

I had $WinnerName = GetCurrentPlayerVar("NickName"); then put this name in one of the buttons (openGlobalButton( "winner_name",78,156,58,12,3,10,64,langEngine( "%{main_winnername}%",$WinnerName)).

That line of code no longer exists in your version, so do I need to change this $WinnerName back to "NickName"?

Does CASE 1 mean the 1st player to finish (after allowing for penalties)?

Just that I'm working on coding to have top 3 results show as flags. Do I need to use Case 1, Case 2 and Case 3 for the 3 results?

Thanks.

Hi,
Sorry, i missed this line $WinnerName = GetCurrentPlayerVar("NickName"); in the script, i just did a copy past from some lines from my own script.:doh:

I have on [NLR]NL Racing Copper (Demo) or on [NLR]FBM Racing (S2) and some other servers a point system, to give points after a race and store them in a database.


SWITCH( GetCurrentPlayerVar("[COLOR=orange]FinishedPos[/COLOR]") ) [COLOR=blue]# you can use any var here[/COLOR]
CASE 1: [COLOR=blue]# 1 is the value of GetCurrentPlayerVar("[COLOR=orange]FinishedPos[/COLOR]")[/COLOR]
[COLOR=seagreen]do something[/COLOR]
BREAK;
CASE 2:
[COLOR=seagreen]do something[/COLOR]
BREAK;
CASE 3:
[COLOR=seagreen]do something[/COLOR]
BREAK;
DEFAULT: [COLOR=blue]# If no value match then do this[/COLOR]
[COLOR=seagreen]do something else[/COLOR]
BREAK;
ENDSWITCH

You can with CASE 2 , CASE 3 and so on , show thing or give points ( i have now CASE 1 to 24 )


Event OnResult( $flagConfirm )
$WinnerName = GetCurrentPlayerVar("NickName");
SWITCH( GetCurrentPlayerVar("FinishedPos") )
CASE 1:
IF(( $flagConfirm == 2 )||( $flagConfirm == 18 )||( $flagConfirm == 34 ))
THEN
openGlobalButton( "winner_backing",66,136,74,34,3,10,32," ");
openGlobalButton( "number_1",67,137,10,32,3,10,16,"^01");
openGlobalButton( "winner_title",78,137,62,19,4,10,96,langEngine( "%{main_winnertitle}%" ));
openGlobalButton( "winner_name",78,156,58,12,3,10,64,langEngine( "%{main_winnername}%",$WinnerName));

openGlobalButton( "white_banner1",108,137,32,18,1,10,16," ");
openGlobalButton( "white_banner2",108,137,32,18,1,10,16," ");
openGlobalButton( "white_banner3",108,137,32,18,1,10,16," ");

openGlobalButton( "black_banner1",136,137,4,6,1,10,32," ");
openGlobalButton( "black_banner2",136,137,4,6,1,10,32," ");
openGlobalButton( "black_banner3",136,137,4,6,1,10,32," ");

openGlobalButton( "black_banner4",112,137,4,6,1,10,32," ");
openGlobalButton( "black_banner5",112,137,4,6,1,10,32," ");
openGlobalButton( "black_banner6",112,137,4,6,1,10,32," ");

openGlobalButton( "black_banner7",120,137,4,6,1,10,32," ");
openGlobalButton( "black_banner8",120,137,4,6,1,10,32," ");
openGlobalButton( "black_banner9",120,137,4,6,1,10,32," ");

openGlobalButton( "black_banner10",128,137,4,6,1,10,32," ");
openGlobalButton( "black_banner11",128,137,4,6,1,10,32," ");
openGlobalButton( "black_banner12",128,137,4,6,1,10,32," ");

openGlobalButton( "black_bannera",108,143,4,6,1,10,32," ");
openGlobalButton( "black_bannerb",108,143,4,6,1,10,32," ");
openGlobalButton( "black_bannerc",108,143,4,6,1,10,32," ");

openGlobalButton( "black_bannerd",116,143,4,6,1,10,32," ");
openGlobalButton( "black_bannere",116,143,4,6,1,10,32," ");
openGlobalButton( "black_bannerf",116,143,4,6,1,10,32," ");

openGlobalButton( "black_bannerg",124,143,4,6,1,10,32," ");
openGlobalButton( "black_bannerh",124,143,4,6,1,10,32," ");
openGlobalButton( "black_banneri",124,143,4,6,1,10,32," ");

openGlobalButton( "black_bannerj",132,143,4,6,1,10,32," ");
openGlobalButton( "black_bannerk",132,143,4,6,1,10,32," ");
openGlobalButton( "black_bannerl",132,143,4,6,1,10,32," ");

openGlobalButton( "black_bannera1",136,149,4,6,1,10,32," ");
openGlobalButton( "black_bannera2",136,149,4,6,1,10,32," ");
openGlobalButton( "black_bannera3",136,149,4,6,1,10,32," ");

openGlobalButton( "black_bannera4",112,149,4,6,1,10,32," ");
openGlobalButton( "black_bannera5",112,149,4,6,1,10,32," ");
openGlobalButton( "black_bannera6",112,149,4,6,1,10,32," ");

openGlobalButton( "black_bannera7",120,149,4,6,1,10,32," ");
openGlobalButton( "black_bannera8",120,149,4,6,1,10,32," ");
openGlobalButton( "black_bannera9",120,149,4,6,1,10,32," ");

openGlobalButton( "black_bannera10",128,149,4,6,1,10,32," ");
openGlobalButton( "black_bannera11",128,149,4,6,1,10,32," ");
openGlobalButton( "black_bannera12",128,149,4,6,1,10,32," ");
ENDIF
BREAK;
ENDSWITCH

EndEvent

Quote from aroX123 :I suggested this a while ago
http://www.lfsforum.net/showthread.php?t=60030 (not only this but the insim)

Posting a video link isn't exactly doing the coding, but....

One thing that really annoys me is that when I'm spectating and go around the track, you cannot tell the racers name and position unless you are in an overhead cam mode with names turned on and have the race list up.

So...what I'm thinking is to see if there is a way to get lapper button that appears when you go to spectate mode and the camera changes to cahse/heli/tv and shows the player name and position just as in the first few seconds of video in your link.

I'll do some investigation and see what I can do.
I'm a huge fan of F1, and love all of these ideas. That implamented with the F1 style timing and scoring would be very interesting!
Is there a option to increase the time ( 10 secs) that the winner board stops on for ?
Quote from Mikjen :Is there a option to increase the time ( 10 secs) that the winner board stops on for ?

Hi,

openGlobalButton( "Id of button",left_pos,top_pos,lenght_of_button,hight_of_button,1,time,32,"Text in the Button", goto_this_sub_when_clicked_on_button );

With time you can set the number(s) of seconds how long a button stay on screen. If use -1 it will stay till you close the button with closeGlobalButton.

By 1 is used for multiline buttons, is the hight where the next line will start.
By 32 you can lineout the text of button and change collor ( only Light or Dark and lineout left or right or in the middle).

So in the winnerflag change in every line 10 to something else.
openGlobalButton( "winner_backing",66,136,74,34,3,10,32," ");
Quote from Mikjen :Is there a option to increase the time ( 10 secs) that the winner board stops on for ?

In version 3 of my code, I've set all button times to 12 seconds.

openGlobalButton( "win_backing",34,44,38,18,1,[COLOR=Red][B]12[/B][/COLOR],32," "); # backing for whole flag

However, if you're confident enough of doing so, I'd suggest that the different finish places be set with different times, e.g.
Winner 12 seconds
2nd Place 10 seconds
3rd Place 8 seconds
4th Place 6 seconds
5th Place 4 seconds
This is because of time difference of drivers passing the finish line. The bigger the gap between drivers, the more chance you have of all flags still being shown at one time.

To reset times, open code and change all 10 buttons between Case 2 and Break to 10, all 10 buttons between Case 3 and Break change to 8, all 10 buttons between Case 4 and Break change to 6 and all 10 buttons between Case 5 and Break change to 4.

Or pick your own number of seconds per place.

FGED GREDG RDFGDR GSFDG