Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-15-2009, 11:34 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Question RequestSQL Ideas

The support for SQL has been added a few days ago, restart your npcserver for using requestsql() if you have not done it already.

If you have already tried the SQL things, may be post some ideas about what you plan to do with it
Reply With Quote
  #2  
Old 04-18-2009, 07:08 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
I've converted the entire player data system on Maloria from using .ini files to SQLite.

Quite easy to query all items from an account, and a lot faster and less demanding then constant loading of files.

SELECT * FROM items WHERE account = '" @ player.account @ "'"

In the items table, I have the variables account, entryIndex, item_id, item_data where account shows who owns the item (d'uh), entryIndex is an auto increasing variable for registry index, item_id the actual item's id (more on that here) and finally, item_data is an array containing all the data for the particular item.


However, when I finished the code, I got the brilliant idea to loop through 3500+ files and convert them to SQLite, instead of dealing with each individual player when he/she logs on, and got this - think it's a new record!

PHP Code:
Top 10 of npcs taken most CPU time:
1. 803.54333169 SQLDebug (in level onlinestartlocal.nw at pos (30.530)) 
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #3  
Old 04-18-2009, 11:15 AM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by xXziroXx View Post
However, when I finished the code, I got the brilliant idea to loop through 3500+ files and convert them to SQLite, instead of dealing with each individual player when he/she logs on, and got this - think it's a new record!

PHP Code:
Top 10 of npcs taken most CPU time:
1. 803.54333169 SQLDebug (in level onlinestartlocal.nw at pos (30.530)) 
Sure as hell is. Most I've seen was 216 % from a /stats query on Zodiac once.
Reply With Quote
  #4  
Old 04-18-2009, 06:00 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
I'm considering redoing the MUD on Valikorlia to use SQL and stuff, but I don't want to use SQL unless I'm willing to make a nice GUI for managing the system since you can no longer edit by text file, but I think I will.
__________________
Reply With Quote
  #5  
Old 04-18-2009, 06:06 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Crow View Post
Sure as hell is. Most I've seen was 216[percent] from a /stats query on Zodiac once.
Wow, I thought I hit a record yesterday when running a level scanner that got to 112[percent].
__________________
Reply With Quote
  #6  
Old 04-18-2009, 06:43 PM
WanDaMan WanDaMan is offline
Master Tux
WanDaMan's Avatar
Join Date: Aug 2002
Location: England, United Kingdom
Posts: 5,571
WanDaMan is a jewel in the roughWanDaMan is a jewel in the rough
Send a message via MSN to WanDaMan
oh coool

What're the SQL functions, and is it really better for storing items that way? lol
Reply With Quote
  #7  
Old 04-19-2009, 04:39 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Me and Chompy are currently in the planning process of a new MUD for Zodiac, we will definitely consider using it for data storage.

If all the important information is consolidated into the SQL Database should make it ALOT easier on the server to do character backups and so forth.
__________________
Quote:

Last edited by fowlplay4; 04-19-2009 at 05:03 AM..
Reply With Quote
  #8  
Old 04-19-2009, 03:17 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by fowlplay4 View Post
If all the important information is consolidated into the SQL Database should make it ALOT easier on the server to do character backups and so forth.
That's what made me rework the system on Maloria to use SQLite
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #9  
Old 04-20-2009, 06:24 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Ideally, I'd like to make some kind of phpMyAdmin-like administration tool. I just have to find the time and inspiration...
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #10  
Old 05-16-2009, 10:08 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
I plan to change a lot of GK's logging system to use SQLite for easy log management (especially for trade tables, etc). Era Dev is also using this idea to bring logs into SQLite as well.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #11  
Old 05-16-2009, 10:24 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Tigairius View Post
I plan to change a lot of GK's logging system to use SQLite for easy log management (especially for trade tables, etc). Era Dev is also using this idea to bring logs into SQLite as well.
That isn't a bad idea at all. I'll probably end up doing the same thing .
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #12  
Old 05-17-2009, 12:03 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by napo_p2p View Post
That isn't a bad idea at all. I'll probably end up doing the same thing .
It's pretty cool. We can make queries like this:

NPC Code:
SELECT * FROM logs_jail WHERE account = 'cbk1994'



or

NPC Code:
SELECT * FROM logs_jail WHERE jailer = 'Tigairius'



or even

NPC Code:
SELECT * FROM logs_jail WHERE time > 60



without having countless files in logs/*
__________________
Reply With Quote
  #13  
Old 08-18-2009, 08:48 PM
firefighter firefighter is offline
Registered User
Join Date: Jan 2009
Location: Germany
Posts: 70
firefighter is on a distinguished road
We on Zenox are using the SQLite database for our item system now. Maybe I will rescript some other systems to use SQLite. Its a great idea I think because its much faster and cleaner than using flat files (normal DB NPC's).

A good feature would be if I can convert defined row results directly into an array without using a for loop. For example:
PHP Code:
public function GetPlayerItems(placc) {
  
temp.items = {};
  
temp.req GetSQL("SELECT ItemDB_Items.name AS itemname FROM ItemDB_Items INNER JOIN ItemDB_PlayerItems ON ItemDB_Items.ID=ItemDB_PlayerItems.item WHERE ItemDB_PlayerItems.player=(SELECT ID FROM Players WHERE account LIKE '"@SQLEscape(placc)@"')",true);
  if (
temp.req!=null && temp.req.error=="") {
    for (
temp.row temp.req.rows)
      
temp.items.add(temp.row.itemname);
  }
  return 
temp.items;

Okay its not a big problem with a for loop but I think it can be solved more optimized
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:15 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.