The online racing simulator
Showing more than one admin text
Hello lfs.net family. I would like to show more than one admin in the script file belonging to Yisc[NL] below, just like in the photo. Thank you in advance for your help.


Photo link = https://hizliresim.com/5fjpu63

Yisc's Code;


# Admin notify V1.00 01-11-15 - Initial release #
#################################################################

CatchEvent OnLapperStart()
OnLapperStart_Admin_Notify();
EndCatchEvent

CatchEvent OnConnect( $userName )
OnConnect_Admin_Notify();
EndCatchEvent

CatchEvent OnDisConnect( $userName, $reason )
OnDisConnect_Admin_Notify();
EndCatchEvent

Sub OnLapperStart_Admin_Notify()
### Declare global variables ###
GlobalVar $admins_present;
GlobalVar $admin_status;
GlobalVar $admin_name;
GlobalVar $admin_time_online;
### End ###

### Give global variables a value to start with ###
$admins_present=0;
### End ###
EndSub

Sub OnConnect_Admin_Notify()
### Set userName variable and load the nicknames of admins specified in admin.txt ###
$userName = GetCurrentPlayerVar( "UserName" );
UserGroupFromFile( "admin", "./admin.txt" );
### End ###

### Check if connecting player is an admin, if so, raise number by one ###
IF( UserInGroup( "admin", $userName ) == 1 )
THEN
$admins_present=$admins_present+1;
$admin_name = GetCurrentPlayerVar( "NickName" );
$admin_time_online = getLapperVar( "ShortTime" );
ENDIF
### End ###

Admin_status( $KeyFlags );
EndSub

Sub OnDisConnect_Admin_Notify()
### Check if discconnecting player is an admin, if so, lower number by one ###
IF( UserInGroup( "admin", $userName ) == 1 )
THEN
$admins_present=$admins_present-1;
ENDIF
### End ###

Admin_status( $KeyFlags );
EndSub

Sub Admin_status ( $KeyFlags )
### Check how many admins are online , if value above 0 ,status is 'online' , otherwise status is 'offline' and last name and time are removed ###
IF ( $admins_present > 0 )
THEN
$admin_status="^2online";
ELSE
$admin_status="^1offline";
$admin_name="^3(-N.A.-)";
$admin_time_online="^3(-N.A.-)";
ENDIF
### End ###

### Display button ###
openGlobalButton( "admins_present",50,1,100,5,1,-1,36,"^7Admin(s): ". $admin_status . " ^7| Last entered: " . $admin_name . " ^7| At: " . $admin_time_online );
### End ###
EndSub

I didn't understand anything from your forum post. Is there anyone who can expla
I'd like to help but I don't have time for LFS. Maybe someone else can help you.
Here some example codes you can work with.

<?php 
#Create a list of buttons with the playernames.
CASE "!lop":
$hgt = 80;
$LoP = getListOfPlayers("U");
privmsg("-----[List of buttons with connected players]-----");
FOREACH(
$Player IN $LoP)
$PLYuserName = $Player["value"];
openButton($userName,"Btn_".$PLYuserName,170,$hgt,30,4,1,-1,16+64,GetPlayerVar($PLYuserName,"NickName")." ^8(".$PLYuserName.")");
$hgt=$hgt+4;
ENDFOREACH
BREAK;
?>
=============================================================================
<?php 
$LoP
= getListOfPlayers("U");
FOREACH (
$Player in $LoP)

$User = $Player["value"];
$NickName = GetLapperVar($Player["value"],"NickName");
###Send message if a user is an admin
IF( UserisAdmin($User) == 1 )THEN
globalmsg
("Player: ".$NickName." (".$User.") is a admin");
ENDIF

ENDFOREACH
?>
Admin notify V1.03
I think this does what you want.
Read the changelog carefully.

Admin notify V1.03 15-07-2024

- Added GlobalVar $style (value can be "last" (default) or "list")
- Added routine to display a list of online admins
Attached files
admin_notify.txt - 3.1 KB - 54 views
Quote from Yisc[NL :;2096921"]I think this does what you want...

Merhaba Yisc[NL]

I added the administrator list file you provided to my server, but the script you provided still does not show more than one administrator.
My wish is to be able to see all admins on the screen, no matter how many admins there are on the server. I don't want it to be in the form of the prefixed code given by Bas Driver, I want to be able to see it on my screen all the time.
Here is the Turkish version of the code you gave and the way I removed the last login time.

https://hizliresim.com/rvazrkn
and I realized that.
It shows people who are not admins.
I just want to see the admin list
On which server are you playing?
So we can check.

Seems you havent been playing since 2017.
Last online :
Sat 30 Dec 2017, 19:18
Quote from Bass-Driver :On which server are you playing...

I'm playing on my own localhost server in the 6R version. Maybe that's why it didn't appear
Admin notify V1.04
If you are only seeing one admin, you haven't read my changelog careful enough.
To see all admins you have to set $style to value 'list'
You also have to make sure that the path to your admin file is correct.

I did realize I made a mistake in my thought process last night, so here is version 1.04

Admin notify V1.04 16-07-2024

- Added GlobalVar $top_bot_adm_not_default
- Added GlobalVar $top_bot_adm_not
- Restructured code to display / remove admin button

Also added instructions what has to be edited at what line number:

If you want all admins to be displayed, change line 39
Make sure to have set the correct path to your admin file in line 48
Attached files
admin_notify.txt - 3.9 KB - 45 views
Hello Yisc[NL],

I tested the Admin notify V1.04 update dated 16-07-2024, and it works. However, I noticed an issue:

For example, if there are 2 admins, they both appear in the bottom left corner. But when the second admin exits and re-enters the server, a gap appears between the first and second admin. How can this be fixed?
The position of the buttons gets only reset when no admin is present.
It could be solved by closing all buttons once an admin enters and then draw them again, but I opted against it to prevent buttons popping on and off all the time.
Is there no other solution for this? Because when there is a gap between two authorities, it looks unattractive
Just put additional if statements that takes care of how many limads there are and then make correct vertical position offset for each button. It's really simple, but requires some thinking.
Admin notify V1.05
Admin notify V1.05 03-08-2024

- Added GlobalVar $admin_array
- Added code to find free spot in array when admin connects
- Added code to make spot in array free again when admin disconnects
- Added code to dynamically calculate button position for connecting admin
- Renamed GlobalVar $top_bot_adm_not_default to $top_bot_adm_notify_default
- Renamed GlobalVar $top_bot_adm_not to $top_bot_adm_notify
- Removed code to restore default button position when number of admins goes to zero
Attached files
admin_notify.txt - 5.5 KB - 36 views
Thanks Yisc[NL] Smile
but still the same problem persists
Quote from AL.OZCAN :but still the same problem persists

Can you show me one (or maybe a few) screenshot(s)?
It should be like this:

3 admins connected, button 1, 2 and 3 are used (starting at the bottom and going up)
Then admin 2 goes away, leaving an open space in the list.
When another admin connects, the programs knows that spot 2 is free and will add the admin there.

In the previous system a counter was raised every time an admin connected and therefor big gaps would be possible and the counter only went back to zero, when the last admin would leave.
With the new code the gaps will be filled once new admins come in.
I have tested that and it worked, but maybe I am not understanding the issue correctly.
I found out that the problem was caused by me and I fixed it, but there is a problem:
If the second admin is active in the game and the first admin exits the game and enters again, the problem in the photo below occurs, but if I use the !reload command in the game, the problem is solved.

1. Admin's screen
https://hizliresim.com/t3d3i0c
2. Admin's screen
https://hizliresim.com/79071ge

1st Admin When he exits and enters, the 1st admin's screen
https://hizliresim.com/ssn2eem

(PROBLEM) - 2st Admin When he exits and enters, the 2nd admin's screen
https://hizliresim.com/s1mpsy1
Admin notify V1.06
Thanks for the screenshots and explanation.
Made the issue clear to me.

Admin notify V1.06 04-08-2024

- Fixed bug in calculating button position (should use default to start with)
Attached files
admin_notify.txt - 5.6 KB - 27 views
It worked flawlessly!
I am very, very grateful to you for everything, Yisc[NL].
I will never forget this kindness
In V1.06 04-08-2024 txt file,
You specified it as 46 in this section, but it will be 47 = #. If you want all admins to appear, you need to change line 46.

FGED GREDG RDFGDR GSFDG