logo
Main

Forums

Downloads

Unreal-Netiquette

Donate for Oldunreal:
Donate

borderline

Links to our wiki:
Wiki

Walkthrough

Links

Tutorials

Unreal Reference

Usermaps

borderline

Contact us:
Submit News
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic SQLite3 for Unreal 227i (Read 3865 times)
[]KAOS[]Casey
Developer Team
Betatester
Offline


nedm

Posts: 3196
Joined: Aug 7th, 2011
Gender: Male
SQLite3 for Unreal 227i
Mar 17th, 2014 at 5:46am
Print Post  
http://www.klankaos.com/SQLite.zip

The Sequel to the MySQL API wrapper appears!

This one doesn't need external software & automatically creates databases locally, no need to run extra garbage.

Enjoy your storing tons & tons of data without annihilating your .ini files with too much data! Make a database of anything, "Experience", kills, currency, weapon loadouts and more!

It comes with an example embedded in the .u: Actor->info->USQLite.

The example is simple, but if you know/want to learn about sqlite 3 you can easily make a server side mod that can store whatever you want.

I plan to make some more useful mods in the future with this, currently i'm just releasing what I've got. It may have bugs as I only lightly tested it, but it seems to work.

Linux binary support is coming soon: my compiler is being garbage.
  
Back to top
 
IP Logged
 
Hyper
Board Moderator
Betatester
*****
Offline


It's Unreal.

Posts: 2995
Joined: Oct 11th, 2002
Re: SQLite3 for Unreal 227i
Reply #1 - Mar 17th, 2014 at 9:14am
Print Post  
Sounds like a good addition to the game. Especially for some server mods that store data about each player.
  
Back to top
WWW  
IP Logged
 
[]KAOS[]Casey
Developer Team
Betatester
Offline


nedm

Posts: 3196
Joined: Aug 7th, 2011
Gender: Male
Re: SQLite3 for Unreal 227i
Reply #2 - May 28th, 2014 at 3:42am
Print Post  
Updated SQLite.zip:

Changes:

Fix potential memory leak upon map change.
SQL transactions are now asynchronous by default. You can change this behavior with a PRAGMA query. This means that unreal will not hang anymore when a query is storing to disk.

Fix the .u so the example is commented out by default.

Add 227i linux .so binary(Might work with 227j test builds..) and a codeblocks project file to build.

Also, I made a cool work-in-progress example with what you can do with sql.

http://www.klankaos.com/MonsterKillStatistics.u

What this does is gather player/monster kills, so you can find out what monster or player kills what the most. IT also stores weapon kills, so you could find what a player uses the most, or how effective a monster is with say.. a rifle. It stores it all locally to MonsterKillStatistics.sqlite3db, which you can query with a database viewer, such as http://sourceforge.net/projects/sqlitebrowser/

  
Back to top
 
IP Logged
 
BobIsUnreal
God Member
*****
Offline


Guy who has too much time
invested to quit now

Posts: 757
Joined: Apr 12th, 2010
Gender: Male
Re: SQLite3 for Unreal 227i
Reply #3 - Jan 27th, 2015 at 7:49pm
Print Post  
i started to use this to save some data, after moving back to 227i from j builds

whats the most Practical way to get data back from the database in unreal?
using select etc would likely return a giant mass of data in a single string.??
if that would have to be phrased tho and seperated it would be a mess

for instance if i save a table of performed  commands to a database
string cmd , string user , string value
and want to return the last entry or somthing,
and of course i want to know the line number etc to alter/delete the entry later..

also just sinply working tho a table's data etc... dont even know how that would not be ugly


and also a  example ho to get say per monsterclass kills return in you example even

i know almost nothing about sql , i am trying to use this as a guide
http://www.w3schools.com/sql/default.asp


edit: nevermind mostly
figured out from the usql example how to pull data , but i still think its gonna be a mess with multi element tables, and i dont understand completly
« Last Edit: Jan 28th, 2015 at 1:44am by BobIsUnreal »  

[REM_img]http://i.imgur.com/V3OSsDu.gif.disable[/img]http://i.imgur.com/JOu38Gs.gif
Back to top
IP Logged
 
[]KAOS[]Casey
Developer Team
Betatester
Offline


nedm

Posts: 3196
Joined: Aug 7th, 2011
Gender: Male
Re: SQLite3 for Unreal 227i
Reply #4 - Jan 28th, 2015 at 5:17am
Print Post  
Yeah, everything is strings.

I could make C++ end functions that converts to every type you'd want {class<actor>, bool, name, etc}, it'd be some work.

Really, all you'd need is Name conversion, since you can convert everything from string to something else except Name... unless my StringToName did actually make it into 227? I forget if it did...


The thing returns an array (through an iterator) of all columns.

So "select Name,Exp from PLayerTable where Name = 'Nedmmaster'" (psuedo code)

would return only one row if Nedmmaster is the key. So you'd get back both "Name" and "Exp", being column 0, and 1.

fyi, this doesn't work very well under 227j since it's built for 227i. It got a lot of crashy madness.

There's not a whole lot else to say about how to use this since it's a very thin interface to sqlite. I don't really do anything special except that iterator.
  
Back to top
 
IP Logged
 
Smirftsch
Forum Administrator
*****
Offline



Posts: 7935
Location: at home
Joined: Apr 30th, 1998
Gender: Male
Re: SQLite3 for Unreal 227i
Reply #5 - Jan 28th, 2015 at 6:55am
Print Post  
// Convert string to name (name length is limited to 63 chars).
static native(391) final function name StringToName( string S );


that one?
  

Sometimes you have to lose a fight to win the war.
Back to top
WWWICQ  
IP Logged
 
BobIsUnreal
God Member
*****
Offline


Guy who has too much time
invested to quit now

Posts: 757
Joined: Apr 12th, 2010
Gender: Male
Re: SQLite3 for Unreal 227i
Reply #6 - Jan 28th, 2015 at 8:51am
Print Post  
i made a mesage logger to test saving opening data
it seems horrible to have to find one or more matching lines ( your relevant player etc),
and then piece together the rows to get the rest of the elements
doing it this way , you would essentailly have to save all the data you want to deal with to a temporary array...

local string Value,a,b,c;
local int Column, Row;
foreach SQLDB.GetQueries("select player,Chat,DateTime from ChatDB where Player = 'names';",Column,Row,Value)
         {
         
          if (string(row) == "0") {a = Value;}      
          if (string(row) == "1") {b = Value;}
          if (string(row) == "2") {
            c = Value;
            log (c$" "$a$" "$b); //date / player / message
            }
           

          }

doing this for alot of elements is messy ( and probably not the right way)
idealy the table would have dozens of elements , not just 2 of 3



the mod didnt work at all in 227j (crashed upon loaded the dll /saving data), thats why i am only beginging to look at it now.
  

[REM_img]http://i.imgur.com/V3OSsDu.gif.disable[/img]http://i.imgur.com/JOu38Gs.gif
Back to top
IP Logged
 
BobIsUnreal
God Member
*****
Offline


Guy who has too much time
invested to quit now

Posts: 757
Joined: Apr 12th, 2010
Gender: Male
Re: SQLite3 for Unreal 227i
Reply #7 - Feb 12th, 2015 at 3:52am
Print Post  
i dont like to keep asking bs, but i want to do something usfull with this ...
but i cant grasp sql queries well but i came up with a simple method of storing data by value

i init the db as
CREATE TABLE if NOT EXISTS configDB(Player STRING,property STRING,value STRING, PRIMARY KEY(player,property));


what I want to do is if player name = %pm% and property = %pr%  then we set related property $value$

getting property is easy(sort of i a said ) , but updating/create if exist is where i am kinda stuck.

the provided example is close , but only increments value instead of setting property and combines values somhow

i need to know how to update/create entry "value" field when "player" and "property"  match some uscript variables.

this way i can create/ammend.access  endless virtual variables related to a player / class /  or some hash etc.


of course directly finding the matchign values would also be ideal

player  property  value
-----------------------
player  setiing1 , value
player  setting2,  value
player2 setting1   value
etc



um ;; after thought
i could just do this in a 3 element dynamic array with probably better efficiency.. cry
still interested i this tho...


essentaily this
http://pastebin.com/yii356DZ
« Last Edit: Feb 12th, 2015 at 6:07am by BobIsUnreal »  

[REM_img]http://i.imgur.com/V3OSsDu.gif.disable[/img]http://i.imgur.com/JOu38Gs.gif
Back to top
IP Logged
 
[]KAOS[]Casey
Developer Team
Betatester
Offline


nedm

Posts: 3196
Joined: Aug 7th, 2011
Gender: Male
Re: SQLite3 for Unreal 227i
Reply #8 - Feb 12th, 2015 at 5:13am
Print Post  
Quote:
INSERT OR REPLACE INTO configDB (Player, property, value)
  VALUES ('nedmmaster', 'amazingproperty', '666');


should do it
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint
Bookmarks: del.icio.us Digg Facebook Google Google+ Linked in reddit StumbleUpon Twitter Yahoo