Skip to content

Commit

Permalink
Another try to fix the losing of attribute points. I guess if OnClien…
Browse files Browse the repository at this point in the history
…tCookiesCached gets called not every plugin has to be loaded yet. So it could happen that a clients loads his attribute points, but there are none registered, so as soon as those get registered he would still be at level 0 and the db never gets asked twice... This fix should circumvent this issue by trying to load the attributes on every spawn, if they havent already.
  • Loading branch information
davenonymous committed Apr 4, 2010
1 parent 8faf0ac commit 020905c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 0 additions & 2 deletions scripting/attributes.cmds.sp
Expand Up @@ -134,8 +134,6 @@ public Action:Command_SetPlayerAttribute(client, args)
return Plugin_Handled;
}



public Action:Command_GetPlayerInfos(client, args)
{
if(!att_IsEnabled()) {
Expand Down
18 changes: 16 additions & 2 deletions scripting/attributes.permanent.clientprefs.sp
Expand Up @@ -10,6 +10,7 @@ new Handle:db_Attribute[ATTRIBUTESIZE];
new Handle:db_points;

new bool:g_bValuesLoaded[MAXPLAYERS+1] = {false,...};
new bool:g_bDBRegistered = false;

////////////////////////
//P L U G I N I N F O//
Expand All @@ -36,21 +37,34 @@ public OnAllPluginsLoaded() {
}

db_points = RegClientCookie("attributes_available", "Available attribute points to the player ", CookieAccess_Private);

g_bDBRegistered = true;
HookEvent("player_spawn", Event_Player_Spawn);
}

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

public Event_Player_Spawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));

if(att_IsEnabled())
loadValues(client);
}


public OnClientPutInServer(client) {
g_bValuesLoaded[client] = false;
}

stock loadValues(client) {
if (!AreClientCookiesCached(client) || g_bValuesLoaded[client])
if (!AreClientCookiesCached(client) || g_bValuesLoaded[client] || !g_bDBRegistered)
return;

new count = att_GetAttributeCount();
Expand Down

0 comments on commit 020905c

Please sign in to comment.