PDA

View Full Version : [CODE] Replacement stored var code


Krayy
3rd October 2009, 20:23
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)

Fire_optikz001
3rd October 2009, 23:18
EDIT: stupid me

EDIT2: who still dont work for me

Krayy
4th October 2009, 04:33
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

Fire_optikz001
4th October 2009, 04:58
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

Krayy
4th October 2009, 05:03
Try running the attached lapper file only to see if that works.

Fire_optikz001
4th October 2009, 06:47
thanks for all the help krayy i really appreciate it!!!

glad you found my bug :)

Krayy
4th October 2009, 20:29
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:
public void LdbUpdateUserVar(string userName, string key, string 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

Fire_optikz001
5th October 2009, 04:08
still dont work :|

Krayy
5th October 2009, 04:54
still dont work :|
Which part? The PM'ing?

Fire_optikz001
5th October 2009, 05:05
Which part? The PM'ing?
ye

Krayy
5th October 2009, 05:16
ye
thought so...this patch isnt for that problem..i'm still working on that

Fire_optikz001
5th October 2009, 05:21
thought so...this patch isnt for that problem..i'm still working on that
oh :) ok