ID:1127535
 
(See the best response by Super Saiyan X.)
Code:
        Save(mob/m)

for(var/x=1 to m.vars.len)
Query(client.update_query(m,m.vars[x]))

Load(player)

var/DBQuery/qry = Query("SELECT * FROM `[sql_table]` where `name`='[player]';")
qry.Execute()
if(qry.RowCount() > 0)
while(qry.NextRow())
var/list/row_data = qry.GetRowData()
for(var/D in row_data)
if(!vars.Find(D) || ignored_vars.Find(D)) continue
if(findtext(row_data[D],"|"))
vars[D]=explodetext(row_data[D],"|",limit=0)
world.log << "[vars[D]] <-> [row_data[D]]"
else
vars[D]=row_data[D]
world.log << "[vars[D]] <-> [row_data[D]]"

else src << "Sorry, your character never existed."


Problem description:

Okay so I'm trying to get MySQL Loading/Saving finished up on my creation...

Anyways creating the characters and saving to the database seems to work fine.. however Saving without creating and loading doesn't seem to be working properly..

I can load in with most of my variables correct but for some reason some of my variables get messed up and it bugs out the game

My character works fine upon first creating but if i logout and back in it is bugged and some things don't work such as combat...

for example in the log file i see these errors and i have no idea what could be causing them..

runtime error: type mismatch: cannot compare "100" to 24
proc name: CheckColorEnergy (/mob/proc/CheckColorEnergy)
source file: ZProcs.dm,1692
runtime error: type mismatch: cannot compare "100" to 24
proc name: CheckColorEnergy (/mob/proc/CheckColorEnergy)
source file: ZProcs.dm,1692
runtime error: type mismatch: cannot compare "100" to 24
proc name: CheckColorEnergy (/mob/proc/CheckColorEnergy)
source file: ZProcs.dm,1692
runtime error: type mismatch: cannot compare "250" to 5
proc name: Process (/Command/sense_world/Process)
source file: ZCommands.dm,283
runtime error: type mismatch: cannot compare "100" to 24
proc name: CheckColorEnergy (/mob/proc/CheckColorEnergy)
source file: ZProcs.dm,1692

        CheckColorEnergy()
if(CurrEnergy <= 24)
return "{R"
else if(CurrEnergy <= 49)
return "{Y"
else if(CurrEnergy >= 50)
return "{B"


So saving messes up and im not sure why..

also another issue i have noticed..saving wont work im using the library from here

http://www.byond.com/developer/DivineTraveller/ MySQLmobsaving
Best response
The saved/loaded values get converted to text. You should convert the number variables back for them to work properly. Check out isnum and text2num.

Maybe the library actually has some capability to do this already. Have you looked at all the documentation?
You cannot compare CurrEnergy (text) with 24 (number). Use text2num to convert CurrEnergy into a number.

EDIT: Yea, what SSX said.
thanks it worked..now if only i could figure out why the variables arent saving >.< then im good to go :|