Okay, the code in the post is an example of what you can add to the *.lpr files to support usergroup save/listing.
The attachment (the patch file) is what you need to use to alter the source code (this pathc file is from TortoiseSVN, but can be used with any othe SVN app or manually).
The errors that you are getting are because the source code and LPSLapper.exe has not been rebuilt yet. To do this you will need to have Visual C# Express Edition installed, and have the LFSLapper source code extracted to a directory.
The patch file lists the files that are altered in the LFSLapper/src directory, the code lines to add (+) and lines that should be removed or commented (-). Make these adjustments then open the LFSLapper.csproj file in Visual C# and hit the F6 key to recompile. You will now find a new .exe file in the Release directory. Copy that over your old LFSLapper.exe are you're away laughing
Heres a patch file that will add the ability to get a comma seperated list of users in a group, along with the ability to save a usergroup to a disk based file. I have included code below to add to the LFSLapper.lpr file to enable you to add and delete Admins while in game.
Note that Lapper can only return strings, floats or ints to the GLScript parser, so the user lists are returned in a single comma separated string. You will need to use substr or split as I have done to access each username in turn.
PS: The patch file also adds code to allow the rcae host (UCID 0) to !start, !stop and !reload lapper. This is because we use the LFS Server on a dedicated host and this way we don't have to run another instance of LFS to get it up and running.
Add this code in the main "SWITCH( $command )" CASE statement:
<?php CASE "!listgroup": IF( UserInGroup( "admin",$userName ) == 1 ) THEN IF( $argv != "" ) THEN privMsg( "^3Current members of group: " . $argv . "^8" ); PrintUserGroup ($argv); ELSE privMsg( "^3You must specify a user group to list^8" ); ENDIF ENDIF BREAK; CASE "!admins": IF( UserInGroup( "admin",$userName ) == 1 ) THEN IF( $argv != "" ) THEN $idxSpace = indexOf( $argv, " "); IF( $idxSpace != -1 ) THEN $option = subStr( $argv,0,$idxSpace ); $argv = trim( subStr( $argv,$idxSpace ) ); SWITCH( $option ) CASE "add": MoveUserToGroup( "admin" , $argv); SaveGroupToFile( "admin", "./admin.txt" ); BREAK; CASE "del": RemoveUserFromGroup( "admin" , $argv); SaveGroupToFile( "admin", "./admin.txt" ); BREAK; DEFAULT: privMsg( "No such option for this command: " . $option ); BREAK; ENDSWITCH ELSE privMsg( "Command needs more parameters" ); ENDIF ENDIF ENDIF privMsg( "^3Current Admins:^8" ); PrintUserGroup ("admin"); BREAK; ?>
Add this code after the EndEvent statement at the end of that ENDSWITCH:
<?php Sub PrintUserGroup ($UserGroup) $IsNotBlank = 1; $GroupIndex = 0; WHILE ($IsNotBlank == 1) $GroupUser=split( ListGroupUsers($UserGroup),",",$GroupIndex ); IF ( $GroupUser != "") THEN privmsg($GroupUser); $GroupIndex = $GroupIndex + 1; ELSE $IsNotBlank = 0; ENDIF ENDWHILE EndSub ?>
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.
Are you saying that you want everyone to be an admin, because if you already have a list of admin users, then just copy them into the admins.txt file in the main lapper directory and then change the line in the LFSLapper.lpr file that says:
The who and hc commands use a data array in the pitboard.lpr file so it needs to be included. There is a thread re culling these out into a separate file, but until that happens, the pitboard.lpr needs to be included.
The problem that you are experiencing looks to me like its due to latency in the lapper code itself. The doCountDown function subtracts the current time in seconds from the predicted button visible time in seconds then updates the text. The problem is that when doing time subtractions in seconds, there is some rounding going on that may cause the function to skip a second. So if you open the button the first time at 3.9 second past the minute, the text wont update till at least 1 second has passed. If the code gets executed 1.2 seconds later, then you are now at 5.1 seconds past the minute. Second 4 has effectively disappeared. This time slip will be cumulative, so I would suspec that if you have a button counting down from 20 or 30, you would see 3 or 4 numbers missed. Give it a test if you can and see what the outcome is.
So the problem could occur at any time, not just for the second number. It also depends on several other factors, like how many buttons are visible, how many of them are countdowns, and if lapper is doing some other things as well.
One possible fix may be to do the time subtractions in milliseconds rather than seconds to make it more accurate. Other things we could is to go through the code and do some tuning to see if the number of system calls, functions and other bits around the countdown stuff can be made faster.
Thanks Yisc...it's a handy piece of code for sure, as it saves a lot of cycles doing external calls back to the lapper exe.
Come to think of it, maybe we should combine it with a few other snippets to make it a ref for arrays in general. I have attached a sort of starting point, but your input would be most welcome.
EDIT: Come to think of it, let's just call it lapper_global.lpr and get everyone to put any useful globals and supporting functions in there
Since there are quite a few scripts that are using user_array, do you think it might be worth extricating the code to create/add/update user_array entries into it's own include?
The reason I'm suggesting this is that we wanted to disable the pitboard on some of our dev/test servers and it broke a few other includes.
Also, this gives us a place to add things like indexing variables so we can call it using something like "$uName = $user_array[$i,$uaUserName];" rather than an obscure index number.
I'm also wanting to add some extra fields, for info such as this track/car PB and a few others to save extra function calls, which all take proc time.
I'm not actaully sure who created the pitboard.lpr, so it would be their call, but I would hope that in the interest of wider development, they would consider to do so (or pass it back to me to implement).
Heres an update to Lapper v5844 to allow an admin to assign, save and load handicaps in-race. We use this in our league races to apply racer penalties on the fly, save them into the StoredValues DB, then reload them for next race. Admins see the buttons to add/remove weight or intake restrictions, whereas normal racers only see the settings, they cannot change them
NOTE: When you download these files, I had to add a .txt extension as the wont upload otherwise. Take the .txt off the end
To apply the patch, you will need to:
Make sure that "pitboard.lpr" is in your include list in the LFSLapper.lpr file, as this add on uses the global $user_array var
Make the changes in the attached patch file to the parseEvents.cs file and rebuild the Lapper exe
Copy the attached handicapper.lpr file into your includes directory
In the LFSLapper.lpr file, add the code below:
Add this to the LFSLapper.lpr file where you see the other includes:
include( "./includes/handicapper.lpr");
Add this to the LFSLapper.lpr file where you see the other command definitions (like !help or !top):
If we're following the letter of the law, then the GPL license that Lapper has attached to it would mean that you have to provide the source code to any project based off of it, so any intellectual property is in the public domain.
From a community point of view, secrecy and a willingness not to share will only make your development cycle a lonely one, as no one would be willing to help someone who doesn't contribute to the project as a whole.
Here is a Lapper add-on for ver 5.926b+ that allows for multiple page helps.
To install, copy the file into includes directory with the name multipage-help.lpr, then edit the addons.lpr file to include the line:
<?php include( "./multipage-help.lpr"); ?>
at the end of the file. The curent help in Lapper uses the command !help, so if you want to fully replace it, you will need to rename the !help command in the Lapper.lpr file to something else like !help2.
Note: This code includes english helps only at the moment and also requires the attached utils.lpr file to be uupdated as well