# Admin notify V1.00 01-11-2015 - Initial release # # Admin notify V1.01 23-11-2015 - Added a global message to be send when an admin connects # # Admin notify V1.02 12-06-2016 - Fixed a bug which prevented spotting a disconnect # # 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 # # 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 # # 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 # ################################################################################################################################# # If you want all admins to be displayed, change line 46 # # Make sure to have set the correct path to your admin file in line 80 # ################################################################################################################################# CatchEvent OnLapperStart() OnLapperStart_Admin_Notify(); EndCatchEvent CatchEvent OnConnect( $userName ) OnConnect_Admin_Notify(); EndCatchEvent CatchEvent OnDisConnect( $userName, $reason ) OnDisConnect_Admin_Notify( $userName, $reason ); EndCatchEvent Sub OnLapperStart_Admin_Notify() ### Declare global variables ### GlobalVar $admins_present; GlobalVar $admin_status; GlobalVar $admin_name; GlobalVar $admin_time_online; GlobalVar $style; GlobalVar $top_bot_adm_notify_default; GlobalVar $top_bot_adm_notify; ### End ### ### Give global variables a value to start with ### $admins_present=0; $style="last"; #value can be "last" (default) or "list" $top_bot_adm_notify_default=194; $top_bot_adm_notify=$top_bot_adm_notify_default; ### End ### ### Declare array with carnames ### GlobalVar $admin_array; $admin_array[1,1] = ""; $admin_array[1,2] = ""; $admin_array[1,3] = ""; $admin_array[1,4] = ""; $admin_array[1,5] = ""; $admin_array[1,6] = ""; $admin_array[1,7] = ""; $admin_array[1,8] = ""; $admin_array[1,9] = ""; $admin_array[1,10] = ""; $admin_array[1,11] = ""; $admin_array[1,12] = ""; $admin_array[1,13] = ""; $admin_array[1,14] = ""; $admin_array[1,15] = ""; $admin_array[1,16] = ""; $admin_array[1,17] = ""; $admin_array[1,18] = ""; $admin_array[1,19] = ""; $admin_array[1,20] = ""; ### End ### EndSub Sub OnConnect_Admin_Notify() ### Set userName variable and load the nicknames of admins specified in admin.txt ### $userName = GetCurrentPlayerVar( "UserName" ); UserGroupFromFile( "admin", "./../default/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" ); GlobalMsg ( GetCurrentPlayerVar( "NickName" ) . "^7 connected and is server admin" ); IF ($style == "last") THEN Admin_status( $KeyFlags ); ELSE ### Loop through array $admin_array to find a free slot and then add the username of the admin to that slot ### FOR( $i = 1; $i <= 20; $i = $i + 1 ) IF ($admin_array[1,$i] == "") THEN $admin_array[1,$i] = "" . $userName; $button_offset = ($i-1)*5; break; ENDIF ENDFOR ### End ### $top_bot_adm_notify=$top_bot_adm_notify-$button_offset; openGlobalButton( "admins_present_".$admin_name,1,$top_bot_adm_notify,50,5,1,-1,80,"^7Admin: ". $admin_name ); ENDIF ENDIF ### End ### EndSub Sub OnDisConnect_Admin_Notify( $userName, $reason ) ### Check if discconnecting player is an admin, if so, lower number by one ### IF( UserInGroup( "admin", $userName ) == 1 ) THEN $admins_present=$admins_present-1; IF ($style == "last") THEN Admin_status( $KeyFlags ); ELSE ### Loop through array $admin_array to find a free slot and then add the username of the admin to that slot ### FOR( $i = 1; $i <= 20; $i = $i + 1 ) IF ($admin_array[1,$i] == $userName) THEN $admin_array[1,$i] = ""; break; ENDIF ENDFOR ### End ### $admin_name = GetPlayerVar($userName,"NickName"); closeGlobalButton("admins_present_".$admin_name); ENDIF ENDIF ### End ### 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 ### IF ($style == "last") THEN openGlobalButton( "admins_present",50,1,100,5,1,-1,36,"^7Admin(s): ". $admin_status . " ^7| Last entered: " . $admin_name . " ^7| At: " . $admin_time_online ); ENDIF ### End ### EndSub