Hey All
I've been working on this problem for a while now... Right now it's midnight, and I started around 21:00 (9:00PM). I can't figure it out, and i'm going to bed; but maybe someone can help me. The problem I think is something to do with vault. It ocuurs hen I load someones exp. The save debug messages look fine. But when I load it the debugs are bad. (e.x. "Exp data () loaded for user: (username)" "Current exp = 0" )
I cannot figure this out, because the code seems perfect to me. Here it is, there's a lot but i'll try only to post what's relevant.
Code:
//Admin Function To Give User Exp.
public SetExp(id, lvl, cid)
{
//authenticicate
if(!cmd_access(id,lvl,cid,2) )
return PLUGIN_CONTINUE
//read parameters from command
new strTargetID[2], strExp[8]
new TargetID, Exp
read_argv(1, strTargetID, 2)
read_argv(2, strExp, 8)
TargetID = str_to_num (strTargetID)
Exp = str_to_num (strExp)
//set and save player's exp
PlayerExp[TargetID] = Exp
SaveExp(TargetID)
//debug
client_print(id, print_console, "Set user's exp to %i", PlayerExp[TargetID])
CheckLevel(TargetID)
return PLUGIN_HANDLED
}
//Admin Procedure To Load Someone's Exp
public GetExp(id,lvl,cid)
{
//authenticicate
if(!cmd_access(id,lvl,cid,1) )
return PLUGIN_CONTINUE
//read parameters from command
new strTargetID[2]
new TargetID
read_argv(1, strTargetID, 2)
TargetID = str_to_num(strTargetID)
//get name
new TargetName[34]
get_user_name(TargetID, TargetName, 33)
//show exp
LoadExp(TargetID)
client_print(id, print_console, "%s (%i) currenty has %i exp!", TargetName, TargetID, PlayerExp[TargetID])
return PLUGIN_HANDLED
}
//Save Exp Procedure
public SaveExp(id)
{
//get user AuthID
new AuthID[34], key[99], data[99]
get_user_authid(id, AuthID, 33)
format(key, 98, "%s_exp", AuthID)
format(data, 98, "%s", PlayerExp[id])
set_vaultdata (key, data)
//Debug
client_print (0, print_console, "Exp data saved for user: %s", AuthID)
}
//Load Exp Procedure
public LoadExp(id)
{
//get user AuthID
new AuthID[34], value[9]
new key[99]
get_user_authid(id, AuthID, 33)
format(key, 98, "%s_exp", AuthID)
get_vaultdata(key, value, 8)
PlayerExp[id] = str_to_num(value)
//Debug
client_print (0, print_console, "Exp data (%s) loaded for user: %s", value, AuthID)
client_print (0, print_console, "Current exp = %i", PlayerExp[id])
}
I always get () as the data in the debug message, which sets exp to 0.
For interests sake, I can save and load the players alliance fine:
Code:
//Save Alliance
public SaveAlliance(id)
{
//get user AuthID
new AuthID[34]
new key[99], data[99]
get_user_authid(id, AuthID, 33)
format(key, 98, "%s_alliance", AuthID)
format(data, 98, "%i", PlayerAlliance[id])
set_vaultdata (key, data)
//Debug
client_print (0, print_console, "Alliance data (%s) saved for user: %s", data, AuthID)
}
//Load Alliance
public LoadAlliance(id)
{
//get user AuthID
new AuthID[34], value[9]
new key[99]
get_user_authid(id, AuthID, 33)
format(key, 98, "%s_alliance", AuthID)
get_vaultdata(key, value, 8)
PlayerAlliance[id] = str_to_num(value)
//Debug
client_print (0, print_console, "Alliance data (%s) loaded for user: %s", value, AuthID)
}
//Menu to choose new alliance (shows old alliance too)
public SetAlliance(id, key)
{
//key will start at zero
if (key == 0)
{
PlayerAlliance[id] = 1
client_print(id, print_chat, "You will now train for the Zionists!")
SaveAlliance(id)
}
else if (key == 1)
{
PlayerAlliance[id] = 2
client_print(id, print_chat, "You will now train for the Machines!")
SaveAlliance(id)
} else if (key == 2)
{
PlayerAlliance[id] = 3
client_print(id, print_chat, "You will now train for the Exiles!")
SaveAlliance(id)
}
else if (key == 3)
{
return PLUGIN_HANDLED
}
SaveAlliance(id)
return PLUGIN_HANDLED
}
The alliance code works fine, saves, loads and displays like it should. The experience code at the top does not. Can someone tell me why?
OFFTOPIC:
How does the set_hudmessage function work?
This code displays the message at the top left of the screen:
Code:
set_hudmessage(255, 255, 255, 2, 1, 0, 6.0, 25.0, 0.1, 0.2, 4)
While this code displays it at the bottom right
Code:
set_hudmessage(255, 255, 255, 2.0, 1.0, 1, 6.0, 25.0, 0.1, 0.2, 4)
The only difference I see is the latter one has decimals, and has the effect set to 1. That shouldn't make such a huge difference should it?
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.
-Friedrich Nietzsche