The online racing simulator
Quote from Yisc[NL] :As soon as any event within Lapper is triggered, you can use the several variables within that event, to do different things.

I may have made the connection few years ago, but my scripts tend to be simple and don't use these Event variables.

I thought they were only used because you couldn't use $UserName, $Keyflags, $ID, etc., or you made up your own variables.

As in
$myShortTrackName = getLapperVar( "ShortTrackName" );
IF ( $myShortTrackName == "BL1".....

which is just shorthand way of writing getLapperVar( " ...
as in
IF( getConfigVar("ShortTrackName") ....

At least now, I've got it more straight in my head. Thanks for confirmation.

Quote from Yisc[NL] :You can do that as in your example, but it's even possible to combine variables and do different things.

Yes, as in your Pitboard.lpr script for using || as OR, as in

IF ( $myShortTrackName == "BL1" || $myShortTrackName == "BL1R" || ......
With that program I can compile the source code of LFSLapper? Visual Studio? I just want to learn how to create functions in C#
hi,
While working on a simple(should be simple) adminchat script. i Discovered a annoying issue i cannot solve.

The script stores the messages in a textfile.
After typing a message or entering the adminchat it loads the messages from the file. This works as it should be.

But the right sequence of those messages are totally lost.

Example: When you write a message : "2". and the next message is "1". That message will load above the previous message "2". And the message after that: "3". Load below "2".

Could someone give me a helping hand?

Fun fact: I have created a AdminLog system and i cannot solve this LOL.

Edit: Fixed something in the code. Same result.
Attached images
adminchat.jpg
adminlogsystem.jpg
Attached files
adminchatOLD.txt - 2.4 KB - 317 views
This should do the trick Smile
Solution was to add a unique message ID and store that in the database (used the same trick in another project).
Attached files
adminchat.txt - 3 KB - 331 views
Thanks for solving it and for the trick.
Ill gonna save this trick.
Quote from Bass-Driver :hi,
While working on a simple(should be simple) adminchat script. i Discovered a annoying issue i cannot solve.

The script stores the messages in a textfile.
After typing a message or entering the adminchat it loads the messages from the file. This works as it should be.

But the right sequence of those messages are totally lost.

Example: When you write a message : "2". and the next message is "1". That message will load above the previous message "2". And the message after that: "3". Load below "2".

Could someone give me a helping hand?

Here's the code i made so far.


CatchEvent OnMSO( $userName, $text ) # Player event

$idxOfFirtsSpace = indexOf( $text, " ");

IF( $idxOfFirtsSpace == -1 ) THEN
$command = $text;
$argv = "";
ELSE
$command = subStr( $text,0,$idxOfFirtsSpace );
$argv = trim( subStr( $text,$idxOfFirtsSpace ) );
ENDIF

SWITCH( $command )

CASE "!adminchat":
CASE "!adchat":
AdminChatWindow(0,0);
BREAK;
ENDSWITCH
EndCatchEvent

Sub AdminChatWindow($keyflags,$id)
UserGroupFromFile( "AdminChat", "User/AdminLog/AdminChat.txt" ); # Load File
#Design
openPrivButton( "bgd",60,50,80,64,1,-1,16,"");
openPrivButton( "Title",61,51,78,5,1,-1,32,"^3AdminChat Interface");
openPrivButton( "Close",134,51,5,5,1,-1,128,"^1X",CloseAdminChat);
openPrivButton( "Chatbgd",61,56,75,50,1,-1,32,"");
openPrivButton( "Scroll",136,61,3,40,1,-1,16,"");
openPrivTextButton( "WriteMessage",61,106,78,7,1,32,"^0Write Message","^2Write Message",50,WriteAdminMessage);

LoadAdminChatFromFile(0,0);#Load messages from file.
EndSub

Sub WriteAdminMessage( $KeyFlags,$argv )

$ListAdminChat = GetListOfUsersGroup(AdminChat);
MoveUserToGroup( "AdminChat", getLapperVar( "ShortDate" )."-".getLapperVar( "ShortTime" ) ."|". GetCurrentPlayerVar( "UserName" )."|".$argv);
UserGroupToFile( "AdminChat", "User/AdminLog/AdminChat.txt" );

LoadAdminChatFromFile(0,0); #Load messages from file.
EndSub

Sub CloseAdminChat($keyflags,$id)
closePrivButton("bgd&Title&Close&Chatbgd&WriteMessage&ScrollUp&Scroll&ScrollDown");
closePrivButton($CloseAdminChat);
EndSub

Sub LoadAdminChatFromFile($keyflags,$id)

$ListAdminChat = GetListOfUsersGroup(AdminChat);
$MaxOfMessages= arrayCount($ListAdminChat);
$CloseAdminChat = "&Close";
$HT = 57; #Height of first message

#$Record[0] = Date/Time;
#$Record[1] = Username;
#$Record[2] = Message;

FOR ($ShowMessage=$MaxOfMessages-13;$ShowMessage<=$MaxOfMessages;$ShowMessage=$ShowMessage+1) #Last Message on bottomline.
$Record = SplitToArray($ListAdminChat[$ShowMessage], "|");
openPrivButton( "aploglist_".$ShowMessage,62,$HT,74,4,4,-1,64,"^6".$Record[0].": ^7".$Record[1]." >>> ^6".$Record[2]); #Show Message
$HT = $HT+4; #ButtonHeight+4
$CloseAdminChat = $CloseAdminChat ."&aploglist_".$ShowMessage;
ENDFOR
EndSub

Fun fact: I have created a AdminLog system and i cannot solve this LOL.

Edit: Fixed something in the code. Same result.

as I put it to use with a command?
EJ: !logsystem
hi, i have a weird issue with getting data from the array's.
I have convert some Var's with ToNum(). But somehow it doesnt save/get the data from the previous Var from the array i've set.

Has it something todo with the For - EndFor loop?? Because the previous projects with array works flawless.

Here is a example of the code.



<?php 
CatchEvent OnLapperStart
()
    
GlobalVar $Rule#Have Set $Rule[1] - $Rule[16]
    
GlobalVar $CloseServerRulesOne#ButtonRow 1
    
GlobalVar $CloseServerRulesTwo#ButtonRow 2
    
    
$CloseServerRulesOne "&Close";
    
$CloseServerRulesTwo "&Close";
EndCatchEvent

Sub SetServerRules
($keyflags,$id)
    
$AP_HT 52#Local Var
    
closeadminpanelother2(); #A close function
    
openPrivButton"ServerRulesChangeTitle",70,$AP_HT+10,60,4,4,-1,96"^2blablahblah %nl%^2WAAAW new line blablabnla!");
    FOR(
$i=1;$i<17;$i=$i+1)
        
openPrivButton"ServerRule_".$i,70,$AP_HT+18,55,4,5,-1,96"^3".$i.". ".$Rule[ToNum($i)]); #Line of rule
        
openPrivTextButton"ServerRuleSet_".$i,125,$AP_HT+18,5,4,5,16"^3Set ServerRule","^0Set",60,ServerRuleSet); #Set button
        
$AP_HT=$AP_HT+4#Buttonheight + 4

        #closing vars
        
$CloseServerRulesOne $CloseServerRulesOne "&ServerRule_".$i;
        
$CloseServerRulesTwo $CloseServerRulesTwo "&ServerRuleSet_".$i;
        
    ENDFOR
    
openPrivButton"ServerRulesClose",70,$AP_HT+19,60,5,5,-1,16"^3OK",AdminPanelOther2); #This doesnt work if you copy this code hahah
EndSub

Sub ServerRuleSet
$id$argv )
    
$Rule[ToNum(trim(subStr$id,14 )))] = $argv#ToNum(trim(subStr( $id,14 ))) = trim first 14 chars and convert it to ToNum()
    
SetServerRules(0,0);
EndSub
?>


I know it is something easy, but i cannot find it. LOL
Attached images
SetServerRules01.jpg
Looked at it, scratched my head a few times, had a couple of goes at it, scratched my head a bit more and then came up with the solution.
It turned out that the array was cleared every time a value was added (I used dumpvar(name_of_the_array)) to monitor that.
Adding a simple "". before the $argv was added, solved that issue.

Have a go with this:


CatchEvent OnLapperStart()
GlobalVar $Rule; #Have Set $Rule[1] - $Rule[16]
GlobalVar $CloseServerRulesOne; #ButtonRow 1
GlobalVar $CloseServerRulesTwo; #ButtonRow 2

$CloseServerRulesOne = "&Close";
$CloseServerRulesTwo = "&Close";
EndCatchEvent

Sub SetServerRules($keyflags,$id)
$AP_HT = 52; #Local Var
closeadminpanelother2(); #A close function
openPrivButton( "ServerRulesChangeTitle",70,$AP_HT+10,60,4,4,-1,96, "^2blablahblah %nl%^2WAAAW new line blablabnla!");

FOR($i=1;$i<17;$i=$i+1)
openPrivButton( "ServerRule_".$i,70,$AP_HT+18,55,4,5,-1,96, "^3".$i.". ".$Rule[$i] ); #Line of rule
openPrivTextButton( "ServerRuleSet_".$i,125,$AP_HT+18,5,4,5,16, "^3Set ServerRule","^0Set",60,ServerRuleSet); #Set button
$AP_HT=$AP_HT+4; #Buttonheight + 4

#closing vars
$CloseServerRulesOne = $CloseServerRulesOne . "&ServerRule_".$i;
$CloseServerRulesTwo = $CloseServerRulesTwo . "&ServerRuleSet_".$i;
ENDFOR

openPrivButton( "ServerRulesClose",70,$AP_HT+19,60,5,5,-1,16, "^3OK",AdminPanelOther2); #This doesnt work if you copy this code hahah
EndSub

Sub ServerRuleSet( $id, $argv )
$Rule[ToNum(trim(subStr( $id,14 )))] = "".$argv; #ToNum(trim(subStr( $id,14 ))) = trim first 14 chars and convert it to ToNum()
SetServerRules(0,0);
EndSub

Thanks Yisc[NL],
Never thought that something small like this could cause headaches.

Also i learning something new. Using dumpvar();
adminchat code?
This thread is closed

Config help
(1112 posts, closed, started )
FGED GREDG RDFGDR GSFDG