The online racing simulator
#1 - Krayy
[CODE] Replacement stored var code
Hi guys,

Well I was having a problem with the setuserstoredvalue and getuserstoredvalue functions in that the code in parseevent would only handle ints, and you were limited to storing data for the current user only.

The supplied patch will add the code to allow a lapper sub to set or retrieve a var for any user. All vars are stored as string, but can be retirevd as nums or vars using the appropriate calls. It will store these in a new DB called LapperDB.dbs. The updated functions have the syntax:

GetStoredUserNum( userName, varKey);
GetStoredUserStr( userName, varKey);
SetStoredUserVar( userName, varKey, value);
* NOTE: The userName is OPTIONAL in all of these commands and will apply to the current user if omitted. This allows setting a var for ANY user.

The other advantage of this system is that in a command that needs to track button values (like !ctrack, or the attached replacement for !who), you can use this new DB as storage space rather than setting a global var which may get overwritten by another instance of the command while you're using it. Have a look at the code in the !who command to send a PM to see how to use it. The Pitboard code could also be modified to use this.

I have also attached a copy of my base Lapper.lpr file because there is a lot of stuff in the OnConnect and OnLapperStart that the !who command relies on.

Any suggestions or questions, please post here.
NB: This patch is for version 5.8.4.6

PS: See post #7 for an update too (http://www.lfsforum.net/showthread.php?p=1277027#post1277027)
Attached files
krayy_LapperDB_.patch.txt - 18.7 KB - 196 views
who.lpr.txt - 5.4 KB - 192 views
LFSLapper.lpr.txt - 80.1 KB - 165 views
EDIT: stupid me

EDIT2: who still dont work for me
Attached images
whoo-bug.jpg
#3 - Krayy
Have you copied the RcaerArray code from the attached lapper file into your one in the right place? Also any vars that have the prefix $ra*

Entries need to be copied from OnLapperStart, OnConnect, OnDisconnect
Quote from Krayy :Have you copied the RcaerArray code from the attached lapper file into your one in the right place? Also any vars that have the prefix $ra*

Entries need to be copied from OnLapperStart, OnConnect, OnDisconnect

i actually added all my code to ur file
#5 - Krayy
Try running the attached lapper file only to see if that works.
thanks for all the help krayy i really appreciate it!!!

glad you found my bug
#7 - Krayy
Found a bug already...that'll pay me to read Gai-Lurons code more thoroughly.

We need to strip out any single quotes and blanks from any stored var, so the following line with the + next to it needs to be added to the storeddbs.cs file:

<?php 
        
public void LdbUpdateUserVar(string userNamestring keystring value)
        {
            
long idUserData;
            if (
userName != "")
            {
                
lockBase(); // Lock the database for write

                
userName userName.ToLower(); // Store usrename in lower case
+                value value.Replace("'""").Replace("\0"""); // Replace any invalid chars in value string
?>

still dont work :|
#9 - Krayy
Quote from Krayy :thought so...this patch isnt for that problem..i'm still working on that

oh ok

FGED GREDG RDFGDR GSFDG