Page 1 of 1

Might be a problem in wc3_givexp

Posted: Thu Aug 11, 2005 12:06 pm
by juKay
I know it's a give XP command but I tried to remove XP from a user and it worked. However it never got save to the database, mysql, so when he rejoined he had all the original XP. We tried this three times without success. However if I gave him more XP it got saved without any problem.

Maybe adding write_xp_to_file(id,"") at the end of the function would solve it?

Btw what is the second argument to write_xp_to_file for? givenline[128], it's never used.

Posted: Thu Aug 11, 2005 2:41 pm
by ferret
Its left over from the old flat-flat method of saving.

I'll put a write_xp_to_file into wc3_givexp ... However.. This shouldn't be necessary. Disconnecting and/or finishing a round should cause a write_xp_to_file (Unless you turned off end round saving)

I know disconnecting will save correctly because I use ENDROUND_SAVE 0 to cut CPU usage on round restart.

I'll also review the SQL statements. I wonder if the issue is there, because I know this works with VAULT.

Posted: Fri Aug 12, 2005 3:41 pm
by juKay
Are you talking about ROUNDEND_SAVEALL or did I miss something? I've left that to the default and if I'm correct the default is enabled.

Looked at the code now and you are correct, it's a SQL statement error.

In write_xp_to_file() you have this. So if the players XP is lower than before it won't get saved.

Code: Select all

format(mquery, 1023, "UPDATE `%s` SET playername='%s',xp=%d,skill1=%d,skill2=%d,skill3=%d,skill4=%d WHERE \
playerid='%s' AND race=%d AND xp<%d", mysqltablename, playername, playerxp[id], p_skills[id][1], \
p_skills[id][2], p_skills[id][3], p_skills[id][4], playerid, p_skills[id][0], playerxp[id])

Posted: Fri Aug 12, 2005 4:11 pm
by ferret
Can you give me the correct statement? SQL isn't my strong suit and I didn't write those queries.

Posted: Sat Aug 13, 2005 2:35 am
by juKay
The problem is here:
format(mquery, 1023, "UPDATE `%s` SET playername='%s',xp=%d,skill1=%d,skill2=%d,skill3=%d,skill4=%d WHERE \
playerid='%s' AND race=%d AND xp<%d", mysqltablename, playername, playerxp[id], p_skills[id][1], \
p_skills[id][2], p_skills[id][3], p_skills[id][4], playerid, p_skills[id][0], playerxp[id])

Can't quite figure out why it's checking so that your old xp is smaller than the new value. Must be some saftey net if the xp system would bug or something like it.

Simply just remove the "AND xp<%d" and problem should be solved.

Posted: Sat Aug 13, 2005 2:50 am
by Lazarus Long
Hello, ferret:
juKay wrote:Simply just remove the "AND xp<%d" and problem should be solved.
Yep, perfectly safe.

Posted: Sun Sep 11, 2005 5:41 pm
by Lazarus Long
done - it's part of 2.6.1