The online racing simulator
[Solved] OpenTextButton/OpenPrivTextButton
openPrivTextButton( "dopm_message",61,56,78,8,5,80,"^3Type message (up to 50 chars)","^3Click here to edit message",50,pm_text_input );

^^^
Found that in Gai-Luron's who.lpr.txt.
- The missing variable happens to be duration.

Problem:
I need a ban button for my admin panel that asks for "How many days?" which requires user input of up to 3 digits, before executing the cmdLFS function.

After looking through examples and some testing I can't figure out what the "5" means.

Also can anyone guide me onto the full format and values of a openPrivTextButton/opentextbutton?

It's not as similar to openPrivButton as I thought it was...
This information can be found in "changes.txt" which is located in folder 'doc'

+---------------------------------------+
|Changes from v5.824 to 5.825|
+---------------------------------------+

Add new command openPrivTextButton, to open a button who query an input string
openPrivTextButton( "ref2",103,140,20,10,10,32,"Caption","Toto",30,saisTxt );

Open a button for the current player, args are
1 - Unique id for this button
2 - Left coordinate for this button ( 0-200 )
$origL = (value between 0-200); - when this value is used, every next value can be made relative to this one ( example: $origL + 5; )
3 - Top coordinate for this button ( 0-200 )
$origT = (value between 0-200); - when this value is used, every next value can be made relative to this one ( example: $origT + 5; )
4 - Width of the button ( 0-200 )
5 - Heigth of the button ( 0-200 )
6 - Space between line in multiline button
7 - Format of the button, look at insim.txt for values
8 - Caption displayed in the input box
9 - Button Text
10 - Number char to be input
11 - Backcalled sub

+----------------------------------------+
|Changes from v5.919 to 5.920 |
+----------------------------------------+

openPrivTextButton now call the callBack subRoutine with 2 arg,
first = idOfButton
Second = Text

+----------------------------------------+
|Changes from v5.924 to 5.925 |
+----------------------------------------+

Add new command openTextButton, to open a button who query an input string for a specified player
openTextButton( "username","ref2",103,140,20,10,10,32,"Caption","Toto",30,saisTxt );

Open a button for the current player, args are
1 - UserName of the player who want open a text button
2 - Unique id for this button
3 - Left coordinate for this button ( 0-200 )
$origL = (value between 0-200); - when this value is used, every next value can be made relative to this one ( example: $origL + 5; )
4 - Top coordinate for this button ( 0-200 )
$origT = (value between 0-200); - when this value is used, every next value can be made relative to this one ( example: $origT + 5; )
5 - Width of the button ( 0-200 )
6 - Heigth of the button ( 0-200 )
7 - Space between line in multiline button
8 - Format of the button, look at insim.txt for values
9 - Caption displayed in the input box
10 - Button Text
11 - Number char to be input
12 - Backcalled sub

Backcalled function receive 2 args
first = idOfButton
Second = Text
A little over 2 years ago I made a system to ban/unban players and check the bans (which do not expire until ban is manually lifted!) when someone connects.
Maybe it's useful to you are anyone else.
Save the file in your 'includes' folder and rename it to: ban_system.lpr
Add a line to 'addonsused.lpr' saying: include( "./ban_system.lpr");
Feel free to use it, work it over or not use it at all Wink
Attached images
ban_unban_players.png
ban_unban_players_2.png
Attached files
ban_system.txt - 8 KB - 118 views
Thanks, so far I have:
openPrivTextButton( "BAN_UI_Days",90,100,20,10,5,16,"^3Input: No. of Days","^7###",3, BanPanel_Ban );

Sub BanPanel_Ban ( $KeyFlags, $Days )

$Cash = ToNum( ToString( $Days ) );
$userName = GetCurrentPlayerVar("UserName");
SetPlayerVar( GetPlayerVarByUCID( $Ucid , "UserName" ) , "Cash" , Round((ToNum( GetPlayerVarByUCID( $Ucid , "Cash" ) + $Cash )),2) );
GlobalMsg( "Test $Days: ^6" . $Days );
PrivMsg( GetPlayerVarByUCID( $Ucid , "UserName" ), "Value: " . $Cash );
Cruise_HUD( $userName );
Cruise_HUD( GetPlayerVarByUCID( $Ucid , "UserName" ) );
ModPanel_Close ();
BanPanel_Close ();
EndSub

Problem 1:
The private button doesn't close even with closebuttonregex. It has infinite duration...

Problem 2:
Nothing happens after I enter text.

P.S. I read your ban script but the problem is I can't create new files in the directory (LFS hosting). This means I can't retrieve offline banned players... so I have to do it under the original ban system. The openprivtextbutton should allow user input for # days for execute by cmdLFS.
Problem 1:

This button won't close on its own, so you have to close it using:
closePrivButton( "BAN_UI_Days" );

Problem 2:

I added a debug line (to be written to Lapper console) to see if $Days is filled when a value is entered into the button and that is happening.
This line isn't wrong, but doesn't make sense to me: $Cash = ToNum( ToString( $Days ) );
Why convert something to both Num and String?
I do get an error in this line: SetPlayerVar( GetPlayerVarByUCID( $Ucid , "UserName" ) , "Cash" , Round((ToNum( GetPlayerVarByUCID( $Ucid , "Cash" ) + $Cash )),2) );

The log-file is showing this error:

3/27/2019 8:09:13 PM -> Syntax error: in file ".\AB-configs\.\..\includes\.\test\test_ban.lpr" at line #35
'GetPlayerVarByUCID' parameter #0() is wrong type at line #
Function 'banpanel_ban' script aborted

Maybe this error happens because I am now running DCon and Lapper on my pc, but this could be the reason nothing is happening (as Lapper stops this script after that error).
Let me know if you have that error as well in your log-file.
Log-file can be found in: LFSLapper V7.0.6.3\bin\default\logs
Where the filename ends with ERR.txt


Sub BanPanel_Ban ( $KeyFlags, $Days )
writeline ( "DEBUG: " . $Days );
$Cash = ToNum( ToString( $Days ) );
$userName = GetCurrentPlayerVar("UserName");
SetPlayerVar( GetPlayerVarByUCID( $Ucid , "UserName" ) , "Cash" , Round((ToNum( GetPlayerVarByUCID( $Ucid , "Cash" ) + $Cash )),2) );
GlobalMsg( "Test $Days: ^6" . $Days );
PrivMsg( GetPlayerVarByUCID( $Ucid , "UserName" ), "Value: " . $Cash );
Cruise_HUD( $userName );
Cruise_HUD( GetPlayerVarByUCID( $Ucid , "UserName" ) );
ModPanel_Close ();
BanPanel_Close ();
EndSub

I can confirm that I get the same error with GetPlayerVarByUcid. I removed it, and it returns the $Days value. The second problem is that it needs to execute a command that bans a specific user, which is where the Ucid of the player comes in...

WHILE ( $plyNum < $mCount )
$thisPlayer = GetPlayerInfo($mList[$plyNum]);
$uName = $mList[$plyNum];
$uUCID = $thisPlayer["UCID"];
$uNick = $thisPlayer["NickName"];
$uUser = $thisPlayer["UserName"];
$PanelRowHeight = 5;
$Prefix = $uUCID . "_";
openPrivTextButton( "BAN_" . $Prefix ,$ModBtnX+80,$ModBtnY + 2 + ( $PanelRowHeight * ( $plyNum+1 ) ),20,$PanelRowHeight,5,16,"^3No. of Days?","",3, BanPanel_Ban );


It works for 1 step buttons, such as Pitlane and Kick... because I don't need to input 2 arguments to execute the cmdLFS, 1 being the username and 2 being the number of days.

It also doesn't help that the backcalled sub for executing the text button can only contain 2 arguments, I can't add more than:

BanPanel_Ban ( $KeyFlags, $Days) or ($KeyFlags, $id).

The current state of the sub:

Sub BanPanel_Ban ( $KeyFlags, $Days ) #If >2 arguments, Error: Incorrect number of arguments.
#$Ucid = ToNum(split( $id,"_",1 )); # Error: empty string in ToNum function.
writeline ( "DEBUG: " . $Days );
$Cash = ToNum( ToString( $Days ) );
$userName = GetCurrentPlayerVar("UserName");
closePrivButton( "BAN_" . $Prefix );
#SetPlayerVar( GetPlayerVarByUCID( $Ucid , "UserName" ) , "Cash" , Round((ToNum( GetPlayerVarByUCID( $Ucid , "Cash" ) + $Cash )),2) ); # Error: Parameter is wrong.
GlobalMsg( "Test $Days: ^6" . $Days );
PrivMsg( GetPlayerVarByUCID( $Ucid , "UserName" ), "Value: " . $Cash ); # Error: Parameter is wrong.
Cruise_HUD( $userName );
#Cruise_HUD( GetPlayerVarByUCID( $Ucid , "UserName" ) );
BanPanel_Close ();
EndSub

(I put a # where it doesn't execute or generates an error in the log file.)
I have tested this and it's working:

Sub BanPanel_Ban ( $id, $Days )

$id = the name of the button that was clicked to get to this sub
$Days = the number of days you want to ban a player

So if you would strip "BAN_" out of the $id, you have the $uUCID remaining and that should then you have the two needed arguments to execute the ban.
This thread is closed

FGED GREDG RDFGDR GSFDG