ID:1127261
 
(See the best response by A.T.H.K.)
Code:
client/proc
create_query(mob/mob)
var/qr="INSERT INTO `[sql_table]` ("
for(var/x=1 to mob.vars.len)
if(isclient(mob.vars[mob.vars[x]]))continue
if(ignored_vars.Find(mob.vars[x]))continue
if(x==mob.vars.len)
qr += "`[mob.vars[x]]`"
else //making the initial part of the query
qr += "`[mob.vars[x]]`"
qr += ","
qr += ") VALUES ("
var/list/VARIABLES=mob.vars
//giant mess of stuff below
for(var/x=1 to VARIABLES.len)
world.log << "[VARIABLES[x]] ([isnull(VARIABLES[VARIABLES[x]]) ? "null" : "[VARIABLES[VARIABLES[x]]]"]) = [x]/[VARIABLES.len]"
if(x==(VARIABLES.len))

if(isclient(VARIABLES[VARIABLES[x]]))continue
if(ignored_vars.Find(VARIABLES[x]))continue

if( islist(VARIABLES[VARIABLES[x]]))
qr += "'[implodetext(VARIABLES[VARIABLES[x]],"|")]'"
continue

if( istext(VARIABLES[VARIABLES[x]]) || isdatum(VARIABLES[VARIABLES[x]]) || ispath(VARIABLES[VARIABLES[x]]))
qr += "\"[VARIABLES[VARIABLES[x]]]\""
continue

if( isnum(VARIABLES[VARIABLES[x]]) )
qr += "[VARIABLES[VARIABLES[x]]]"
continue

if( isnull(VARIABLES[VARIABLES[x]]))
qr += "null"
continue

else qr += "'BROKEN'"

else

if(isclient(VARIABLES[VARIABLES[x]]))continue
if(ignored_vars.Find(VARIABLES[x]))continue

if( istext(VARIABLES[VARIABLES[x]]) || isdatum(VARIABLES[VARIABLES[x]]) || ispath(VARIABLES[VARIABLES[x]]))
qr += "'[VARIABLES[VARIABLES[x]]]',"
continue

if( isnum(VARIABLES[VARIABLES[x]]) )
qr += "[VARIABLES[VARIABLES[x]]],"
continue

if( islist(VARIABLES[VARIABLES[x]]))
qr += "'[implodetext(VARIABLES[VARIABLES[x]],"|")]',"
continue

if( isnull(VARIABLES[VARIABLES[x]]))
qr += "null"
qr += ","
continue

else
qr += "'BROKEN',"

qr += ");"
world.log << qr
return qr


Problem description:
Help?

What is your question exactly?
The code is sending temporary variables that are not needed to be saved to MySQL how do i stop it from doing this...it is even sending NPC variables for some reason.

ex:
INSERT INTO `Characters` (`password`,`email`,`Class`,`ClassX`,`ClassY`,`ClassZ`,`Locati on`,`ClassColor`,`GenderColor`,`AlignmentColor`,`Alignment`, `Gender`,`ignorelist`,`Energy`,`Powerlevel`,`Zenni`,`DamageRe duction`,`Speed`,`FlySpeed`,`upgradePoints`,`PvEPoints`,`PKi lls`,`PDeaths`,`EKills`,`EDeaths`,`ArenaWin`,`ArenaLoss`,`We ight`,`playtime`,`DRPEN`,`HighestPL`,`KillTimer`,`LearnBlast `,`LearnKamehameha`,`LearnRocketPunch`,`LearnHellFlash`,`LearnE yeLaser`,`LearnElbow`,`LearnTravel`,`LearnRegen`,`LearnDestr ucto`,`LearnTriBeam`,`LearnSolarFlare`,`LearnSpiritBurst`,`L earnDodonRay`,`LearnKaioken`,`LearnScattershot`,`LearnRenzok u`,`LearnNamekFuse`,`LearnSpiritBomb`,`LearnGalickGun`,`Lear nAbsorb`,`LearnMasenko`,`LearnSBC`,`LearnPunch`,`LearnSweep` ,`LearnRoundhouse`,`LearnDuck`,`LearnDodge`,`LearnJump`,`Learn Block`,`LearnFly`,`LearnLightningAura`,`LearnOozaru`,`LearnP owerball`,`LearnOozaruBlast`,`LearnIT`,`LearnDeathCannon`,`L earnEyeBeam`,`LearnThrow`,`LearnOverload`,`LearnTailwhip`,`L earnDeathBeam`,`LearnBFB`,`TeachesSpiritBurst`,`TeachesTriBe am`,`TeachesSSJ`,`TeachesSSJ2`,`TeachesKamehameha`,`TeachesM asenko`,`TeachesElbow`,`TeachesTravel`,`TeachesSBC`,`Teaches Blast`,`TeachesRegen`,`TeachesNamekFuse`,`TeachesLightningAu ra`,`TeachesGalickGun`,`TeachesKaioken`,`TeachesRenzoku`,`Te achesScattershot`,`TeachesPowerball`,`TeachesDestructo`,`Tea chesDodonpa`,`TeachesSolarFlare`,`TeachesIT`,`TeachesThrow`, `TeachesTailwhip`,`TeachesDeathBeam`,`TeachesBFB`,`TeachesFor m2`,`TeachesForm3`,`TeachesForm4`,`nearby`,`fighting`,`skill s`,`combolist`,`friezaform`,`Flying`,`loggedIn`,`position`,` AdminPrompt`,`cansave`,`stunTimer`,`IsGregory`,`IsBubbles`,` IsRaditz`,`IsGoz`,`IsMez`,`IsGoodBoss`,`IsHellBoss`,`InGeroS hop`,`AmPiccolo`,`chargingKi`,`charge_tick`,`SafeTimer`,`qui t`,`sent_blast`,`tick_map`,`doing_kamehameha`,`charging_kame hameha`,`attack_mod`,`actionCount`,`actionStarted`,`Moving`, `Flying_Direction`,`Flying_Target`,`Safe`,`sleeping`,`resting `,`Powering`,`inFight`,`movingnorth`,`movingsouth`,`movingwest` ,`Absorbing`,`movingnorthwest`,`movingnortheast`,`movingsouthw est`,`movingsoutheast`,`movingtotarget`,`failedlastparry`,`c ombatTimer`,`movingeast`,`parryHigh`,`parryLow`,`parryFail`, `Jump`,`Duck`,`DodgeRight`,`DodgeLeft`,`Deflect`,`Faking`,`Ju mping`,`Ducking`,`InAction`,`InDefense`,`Sweeping`,`cantmove `,`onwater`,`ScouterOff`,`stunned`,`linkdead`,`unconscious`,`ac tionblocked`,`countnearby`,`Reset`,`fighttime`,`blockchance` ,`deflectchance`,`gravitygain`,`deleteitems`,`fixscouters`,`co mbocount`,`start_x`,`start_y`,`isRoshi`,`isKidGoku`,`isKidVe geta`,`countcombo`,`maxcombo`,`thecombo`,`spectating`,`MapUp date`,`beingthrown`,`hittree`,`hitwall`,`hitmountain`,`lastx `,`lasty`,`lastz`,`onWater`,`maxfightgain`,`fightgain`,`inArena Fight`,`dir_text`,`rever_dir`,`hair_text`,`hair_color`,`hair _style`,`hair_length`,`eye_color`,`height`,`skin_color`,`ski n_text`,`build`,`traveling`,`destination`,`spiritGain`,`ligh tAura`,`overLoading`,`lightTimer`,`overLTimer`,`lightGain`,` overGain`,`spiritTimer`,`senzuCD`,`kaiokenTimer`,`spiritBurs ting`,`oldDR`,`oldSpeed`,`isSpirit`,`KaiokenGain`,`NamekFusi ons`,`Command`,`Scouter`,`cansense`,`Admin`,`Gravity`,`displ ay_name`,`IsPlanet`,`ssjtimer`,`ssj2timer`,`ssj3timer`,`ssj4 timer`,`MasterSSJ`,`MasterSSJ2`,`MasterSSJ3`,`MasterSSJ4`,`M asterForm2`,`MasterForm3`,`MasterForm4`,`Form2MasterTime`,`F orm3MasterTime`,`Form4MasterTime`,`AllowScouter`,`invis`,`ne wPlayer`,`PowerGain`,`Dead`,`OOC`,`KaiokenLevel`,`Oozaru`,`M asterOozaru`,`PowerBallCD`,`OozaruTimer`,`OozaruGain`,`Oozar uMasterTime`,`solarflarecd`,`AdvancedScouter`,`ITCD`,`enable map`,`throwCD`,`challengeCD`,`challenge_x`,`challenge_y`,`ch allenge_z`,`jailtime`,`jail_x`,`jail_y`,`jail_z`,`LearnSSJ`, `LearnSSJ2`,`LearnSSJ3`,`LearnSSJ4`,`ssj`,`superadmin`,`trans formgain`,`LearnForm2`,`LearnForm3`,`LearnForm4`,`LearnForm5 `,`form`,`killerTick`,`lastKiller`,`equipment`,`AI`,`AIStart`,` planetmobs`,`keywords`,`moving`,`tag`,`name`,`desc`,`suffix` ,`text`,`icon`,`icon_state`,`overlays`,`underlays`,`dir`,`visi bility`,`luminosity`,`opacity`,`density`,`layer`,`gender`,`m ouse_over_pointer`,`mouse_drag_pointer`,`mouse_drop_pointer` ,`mouse_drop_zone`,`invisibility`,`infra_luminosity`,`pixel_x` ,`pixel_y`,`mouse_opacity`,`pixel_z`,`override`,`maptext`,`map text_width`,`maptext_height`,`loc`,`x`,`y`,`z`,`sight`,`ckey `,`key`,`see_in_dark`,`see_invisible`,`see_infrared`,`pixel_ste p_size`,`animate_movement`,`screen_loc`,`bounds`,`locs`,`ste p_x`,`step_y`,`step_size`,`bound_x`,`bound_y`,`bound_width`, `bound_height`,`glide_size`) VALUES ('Saiyan',180,193,1,'Earth','{c','{c','{B','Good','Male','','/ null,0,0,0,0,0,0,0,0,0,0,0,0,0,null,'|||||||||||||||||||','/ mob/NPC/proc/GlobalAI',0,null,null,null,null,'IJSdijas',null ,null,'{c*{x','BROKEN','player','','',2,1,0,0,0,4,'neuter',nu ll,null,1,0,0,0,0,0,1,0,0,null,32,32,'The water',180,193,1,0,null,null,2,0,0,0,1,null,'32,32','The water',0,0,32,0,0,32,32,0);
Use the issaved() procedure to check if the variable can and should be saved.
Best response
The issue is

var/list/VARIABLES=mob.vars

It's grabbing everything, you'll need to manually set what you want saved.
In response to LordAndrew
LordAndrew wrote:
Use the issaved() procedure to check if the variable can and should be saved.

True, but if the table isn't set up in MySQL then it's going to throw an error.
i tried adding if(!issaved(mob.vars[x]))continue it just stops making all variables o.o
Rather than checking is mob.vars[x] is saved, check if x is saved.
mob.vars[x] is the actual value, x is the variable.
So, if(!issaved(x))
I just decided to add them manually anyways i got past creating the sql mobs but another issue has arrised im trying to load them and when i try to check data in a row i get an error..

        GetRowData()
var/list/columns = Columns()
var/list/results
if(columns.len)
results = list()
for(var/C in columns)
results+=C
var/DBColumn/cur_col = columns[C]
results[C] = src.item[(cur_col.position+1)]
return results


                var/tmp/DBQuery/Q1 = Query("SELECT * FROM `[sql_table]` where `name`='[name]';")
Q1.Execute()
if(Q1.RowCount() > 0)
var/list/Row= Q1.GetRowData()
world.log << "\[[time2text(world.timeofday,"MM/DD/YY hh:mm:ss")]\] (CLIENT) [client.address] - [name] FOUND."
var/tmp/userPass=input("Password: ") as password
if(userPass==Row[2])
//parser.Parse("jeorijafojdiovniojadsasd [name] [client.address]", src)
LoadMob(client, name, userPass)
else
mb_msgout("{YWrong password.{x")
goto login

runtime error: list index out of bounds
proc name: GetRowData (/DBQuery/proc/GetRowData)
source file: core.dm,116
usr: the thun (/mob/new_player)
src: /DBQuery (/DBQuery)
call stack:
/DBQuery (/DBQuery): GetRowData()
the thun (/mob/new_player): UserLogin()
the thun (/mob/new_player): Login()

http://puu.sh/1OIWZ
this is what the query returns.. so it should not be empty ^
nevermind i figured out that part.. now to get mob to load in game and done! yey.