Jump to content
  • 0

Proper SQL syntax


Question

Posted (edited)

Hey, so I'm currently, trying to have an item insert somethings into the inventory table of my inventory sql database, but i'm having some issues could someone help me out?

query_sql"INSERT INTO 'equip_count' VALUES='"+(.@equip_count + 1)+"' FROM 'inventory' WHERE 'char_id'='"+getcharid(0)+"' AND 'nameid'='"+getequipid(2)+"'"

The above query, is going to be activated when ever they equip an item. Also, every 10seconds an item is equipped.

I already got the SELECT part down to pull data, but adding info eludes me.

Should I be using the UPDATE command instead? (Not sure if it requires a re-log).

Note - I've been away from scripting for quite a few years now @.@

Edited by GmOcean

6 answers to this question

Recommended Posts

Posted

every query command the character needs to be logged out in order to works (corretly) AFAIK, and you should use UPDATE to update a value if char_id exists already, or use insert into if you want to insert a new value for a new char_id

Posted
I already got the SELECT part down to pull data, but adding info eludes me.

Should I be using the UPDATE command instead? (Not sure if it requires a re-log).

Yes, if you edit the `inventory` table when they are logged in, changes won't take effect until they relog (and depending on what you changed, it might be overwritten when they logout).

Could what you are trying to do be done with script commands instead?

Posted

I could for equipcount, but there are uses i was going to branch into from figguring this out. Is there a way to edit the src file so that the Inventory is updated live? Or updated everytime Inventory is saved?

Posted

i think this is the part that configure the save time...

trunk/conf/map_athena.conf

// Database autosave time
// All characters are saved on this time in seconds (example:
// autosave of 60 secs with 60 characters online -> one char is saved every
// second)
autosave_time: 300

// Min database save intervals (in ms)
// Prevent saving characters faster than at this rate (prevents char-server
// save-load getting too high as character-count increases)
minsave_time: 100

// Apart from the autosave_time, players will also get saved when involved
// in the following (add as needed):
// 1: after every successful trade
// 2: after every vending transaction
// 4: after closing storage/guild storage.
// 8: After hatching/returning to egg a pet.
// 16: After successfully sending a mail with attachment
// 32: After successfully submitting an item for auction
// 64: After successfully get/delete/complete a quest
// NOTE: These settings decrease the chance of dupes/lost items when there's a
// server crash at the expense of increasing the map/char server lag. If your
// server rarely crashes, but experiences interserver lag, you may want to set
// these off.
save_settings: 127

Posted (edited)

your insert syntax is wrong and use backticks not apostraphes

it may look like this.

"UPDATE `inventory` SET `equip_count`=" +.@equip_count+ " WHERE `char_id`='" +getcharid(0)+ "' AND `nameid`='" +getequipid(2)+ "' AND `equip`=16"

just change the equip value to their values, 16 for armor

how do you get equip column values? what function do you use?

Edited by mleo1
Posted (edited)

Well, you can't actually use the `equip` since, the Inventory Table doesn't update often enough. Err, you can't use it to see if something is equipped atleast, however you SHOULD be able to use it to force equip an item, not sure though.

But on a side note, I figured it out, and decided to drop the idea, as it poses too much trouble for its usefulness. Considering not many would use it lol. Thanks for the help though. I"ll just go to a second idea.

Edited by GmOcean

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...