Raised This Month: $ Target: $400
 0% 

[ANY] tLevelMod v0.1.3 (2010-04-05)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 03-17-2010 , 13:19   Re: [ANY] tLevelMod v0.1.2 (2010-03-14)
Reply With Quote #10

Quote:
For some reason, levels for players (other than bots) don't seem to be saving, so if you disconnect and reconnect, you'll be back at Level 0. Maybe I missed a cvar somewhere. (And yeah, Clientprefs *is* installed.)
huhm, thats weird. can't reproduce this.
does your serverlog say sth like this when a player connects:
DB: <playername> has xp: <value>
and is xp > 0 ?
your clientprefs db is configured correctly? is there a clientprefs-sqlite.sq3 in your sourcemod/data/sqlite folder? are you using mysql as a clientprefs backend?
or am i having some race condition in my code - when i think about it, this could be the case.

Maybe some one else can help as i am no expert for clientprefs:
PHP Code:
public OnPluginStart()
{
    
db_level RegClientCookie("levelmod_level""Current player level"CookieAccess_Private);
    
db_xp RegClientCookie("levelmod_xp""Current player experience points"CookieAccess_Private);
}


/////////////////////////
//L O A D  F R O M  D B//
/////////////////////////
public OnClientCookiesCached(client) {
    
loadValues(client);
}

stock loadValues(client) {
    if (!
AreClientCookiesCached(client))
        return;

    new 
String:sLevel[20];
    
GetClientCookie(clientdb_levelsLevelsizeof(sLevel));
    new 
iLevel StringToInt(sLevel);

    if(
iLevel >= 0) {
        
lm_SetClientLevel(clientiLevel);
        
LogMessage("DB: %N is level %i"clientiLevel);
    }

    new 
String:sXP[20];
    
GetClientCookie(clientdb_xpsXPsizeof(sXP));
    new 
iXP StringToInt(sXP);

    if(
iXP >= 0) {
        
lm_SetClientXP(clientiXP);
        
LogMessage("DB: %N has xp: %i"clientiXP);
    }
}


/////////////////////
//S A V E  T O  D B//
/////////////////////
public OnClientDisconnect(client)
{
    new 
iXP lm_GetClientXP(client);
    new 
iLevel lm_GetClientLevel(client);

    if(
iLevel >= 0) {
        new 
String:sXP[20];
        
Format(sXPsizeof(sXP), "%i"iXP);

        new 
String:sLevel[6];
        
Format(sLevelsizeof(sLevel), "%i"iLevel);

        
LogMessage("Writing client cookie: level %i, xp: %i"iLeveliXP);
        
SetClientCookie(clientdb_levelsLevel);
        
SetClientCookie(clientdb_xpsXP);
    }

Facts:
OnClientConnected(client) is setting xp to 0. (the core does this)
OnClientCookiesCached(client) loads the values from the db.
The latter will always be called after the former, right?

Last edited by Thrawn2; 03-17-2010 at 13:24.
Thrawn2 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:17.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode