SphereCommunity
mysql shop - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: mysql shop (/Thread-mysql-shop)



mysql shop - Pidrila - 01-27-2014 09:09 PM

I have an idea to make an shop in web page..
Ive seen this on other shard and i would like to get it for mee too Smile
i guess many people would like to get this, so who can help please Smile

I have a Vendor, one vendor for all players, they can set items to sell or buy items from this vendor, and all is throught mysql but only in game..

At first here is what my database looks like where all items is collected in there from vendor
[Image: rsz_1phpmyadmin.jpg]

now this is what my vendor dialog looks like in game
[Image: rsz_vendor.jpg]

and there is a scp dialog looks like when arraying the result

Code:
[DIALOG d_auction_item_list] //should be called with the bankbox of the auctioneer as default object
0,60
PAGE 0
NOMOVE
button 489 450 24 24 1 0 3 //my items
button 646 4 24 24 1 0 4 //search button
button 22 60 24 24 1 0 5 //platemail
button 22 80 24 24 1 0 6 //ringmail
button 22 100 24 24 1 0 7 //chainmail
button 22 120 24 24 1 0 8 //studded
button 30 140 24 24 1 0 9 //crystal sets
button 30 160 24 24 1 0 20 //crystal sets
button 15 180 24 24 1 0 10 //weapons
button 15 200 24 24 1 0 11 //bows
button 15 220 24 24 1 0 12 //mounts
button 349 450 24 24 1 0 13 // all items
button 419 450 24 24 1 0 14 //sell item
button 559 450 24 24 1 0 15 // cashout
button 15 240 24 24 1 0 16 //bottles
button 15 260 24 24 1 0 17 //imbues
button 13 415 24 24 1 0 18 //misc
button 15 40 24 24 1 0 19 //armors
resizepic 0 0 9300 800 480
resizepic 440 3 3000 200 22
resizepic 645 3 3000 60 22
resizepic 345 442 3000 65 35
resizepic 415 442 3000 65 35
resizepic 485 442 3000 65 35
resizepic 555 442 3000 65 35
resizepic 8 40 3000 253 400 //kreisa puse
resizepic 265 40 3000 528 400 //labaa puse
resizepic 8 26 3000 785 8 //augseja dala
dtext 8 5 6208 Uo Company Walmart
dtext 145 5 014D *
dtext 165 5 0112 - Sorting by latest Added item
dtext 650 40 014D Price (gp)
dtext 625 40 014D *
dtext 380 40 014D Name
dtext 654 3 6208 Search
dtext 300 40 014D Photo
dtext 350 448 014D All items
dtext 420 448 0112 Sell item
dtext 490 448 0225 My items
dtext 563 448 2015 Cashout
dtext 15 40 0112 Armors
dtext 25 60 6208 Platemail
dtext 25 80 6208 Ringmail
dtext 25 100 6208 Chainmail
dtext 25 120 6208 Studded/Leather
dtext 25 140 6208 Crystal
dtext 25 160 6208 Bone
dtext 15 180 0112 Weapons
dtext 15 200 0112 Bows
dtext 15 220 0112 Mounts
dtext 15 240 0112 Bottles
dtext 15 260 0112 Imbues
dtext 15 415 0112 Misc
LOCAL.VALUE=<src.tag0.cashpoints>
IF (<LOCAL.VALUE> = 0)
dtext 100 448 6208 0 Gp
ELSEIF (<LOCAL.VALUE> >= 1000) && (<LOCAL.VALUE> <= 9999)
LOCAL.NEWHALF=<dLOCAL.VALUE>>
dtext 100 448 6208 <dLOCAL.newhalf> Gp
ELSEIF (<LOCAL.VALUE> >= 10000) && (<LOCAL.VALUE> <= 99999)
LOCAL.NEWHALF=<STRSUB 0 2 <dLOCAL.VALUE>>
LOCAL.NEWHALF2=,<STRSUB 2 3 <dLOCAL.VALUE>>
dtext 100 448 6208 <dLOCAL.newhalf><LOCAL.newhalf2> Gp
ELSEIF (<LOCAL.VALUE> >= 100000) && (<LOCAL.VALUE> <= 999999)
LOCAL.NEWHALF=<STRSUB 0 3 <dLOCAL.VALUE>>
LOCAL.NEWHALF2=,<STRSUB 3 3 <dLOCAL.VALUE>>
dtext 100 448 6208 <dLOCAL.newhalf><LOCAL.newhalf2> Gp
ELSEIF (<LOCAL.VALUE> >= 1000000) && (<LOCAL.VALUE> <= 9999999)
LOCAL.NEWHALF=<STRSUB 0 1 <dLOCAL.VALUE>>
LOCAL.NEWHALF2=,<STRSUB 1 3 <dLOCAL.VALUE>>
LOCAL.NEWHALF3=,<STRSUB 4 3 <dLOCAL.VALUE>>
dtext 100 448 6208 <dLOCAL.newhalf><LOCAL.newhalf2><LOCAL.newhalf3> Gp
ELSEIF (<LOCAL.VALUE> >= 10000000) && (<LOCAL.VALUE> <= 99999999)
LOCAL.NEWHALF=<STRSUB 0 2 <dLOCAL.VALUE>>
LOCAL.NEWHALF2=,<STRSUB 2 3 <dLOCAL.VALUE>>
LOCAL.NEWHALF3=,<STRSUB 5 3 <dLOCAL.VALUE>>
dtext 100 448 6208 <dLOCAL.newhalf><LOCAL.newhalf2><LOCAL.newhalf3> Gp
ELSEIF (<LOCAL.VALUE> >= 100000000) && (<LOCAL.VALUE> <= 1000000000)
LOCAL.NEWHALF=<STRSUB 0 3 <dLOCAL.VALUE>>
LOCAL.NEWHALF2=,<STRSUB 3 3 <dLOCAL.VALUE>>
LOCAL.NEWHALF3=,<STRSUB 6 3 <dLOCAL.VALUE>>
dtext 100 448 6208 <dLOCAL.newhalf><LOCAL.newhalf2><LOCAL.newhalf3> Gp
endif
dtext 15 448 0112 Money earned:
dtextentry 443 3 255 25 0112

////PAGE SYSTEM
//DB.QUERY "SELECT * FROM <tag.auction_table> ORDER BY `id` DESC LIMIT 99999999";
DB.QUERY "SELECT COUNT(*) as category_allitems FROM <tag.auction_table> ORDER BY `id` DESC LIMIT 99999999";
src.ctag.totalpages=<eval (((<db.row.0.category_allitems>-1) / 8) + 1)>
dtext 715 3 0481 Items: <eval (<db.row.0.category_allitems>)>
dtext 623 448 0481 Page: [<eval <src.ctag.actualpage>>/<eval <src.ctag.totalpages>>]
if <eval (<db.row.0.category_allitems> < 1)>
        dtext 380 100 0112 There is no items in the Walmart
        endif

//Mysql query that fetches the rows from <src.ctag.dialogindex> to <src.ctag.dialogindex>+8
DB.QUERY "SELECT * FROM <tag.auction_table> ORDER BY `vip` DESC, `id` DESC LIMIT <eval (<src.ctag.dialogindex>)>,<eval (<src.ctag.dialogindex>+8)>";
FOR index 0 7
    LOCAL.VALUE=<db.row.<eval (<local.index>)>.currentbid>
    if <db.row.<eval (<local.index>)>.uid>
        local.y=(((<local.index>)*45)+65)
        local.x=(((<local.index>)*45)+55)
        local.xs=(((<local.index>)*45)+97)
        local.ys=(((<local.index>)*45)+68)
        local.ys2=(((<local.index>)*45)+58)
        local.buy=(((<local.index>)*45)+66)
        local.name=(((<local.index>)*45)+80)
        if <eval (<db.row.<eval (<local.index>)>.vip> > 0)>
        dtext 380 <local.y> 014d <uid.<db.row.<eval (<local.index>)>.uid>.name> -VIP-
        else
        dtext 380 <local.y> 0 <uid.<db.row.<eval (<local.index>)>.uid>.name>
        endif
        resizepic 640 <local.ys2> 3000 100 42 //Lai naudu redz
        button 759 <local.ys> 5224 5003 1 0 <eval (<db.row.<eval (<local.index>)>.id>+10)>
        IF (<LOCAL.VALUE> >= 1) && (<LOCAL.VALUE> <= 9999)
        LOCAL.NEWHALF=<dLOCAL.VALUE>>
        dtext 650 <local.y> 0 <dLOCAL.newhalf>
        ELSEIF (<LOCAL.VALUE> >= 10000) && (<LOCAL.VALUE> <= 99999)
                   LOCAL.NEWHALF=<STRSUB 0 2 <dLOCAL.VALUE>>
                LOCAL.NEWHALF2=,<STRSUB 2 3 <dLOCAL.VALUE>>
        dtext 650 <local.y> 0 <dLOCAL.newhalf><LOCAL.newhalf2>
        ELSEIF (<LOCAL.VALUE> >= 100000) && (<LOCAL.VALUE> <= 999999)
                   LOCAL.NEWHALF=<STRSUB 0 3 <dLOCAL.VALUE>>
                LOCAL.NEWHALF2=,<STRSUB 3 3 <dLOCAL.VALUE>>
        dtext 650 <local.y> 0 <dLOCAL.newhalf><LOCAL.newhalf2>
        ELSEIF (<LOCAL.VALUE> >= 1000000) && (<LOCAL.VALUE> <= 9999999)
                   LOCAL.NEWHALF=<STRSUB 0 1 <dLOCAL.VALUE>>
                LOCAL.NEWHALF2=,<STRSUB 1 3 <dLOCAL.VALUE>>
                LOCAL.NEWHALF3=,<STRSUB 4 3 <dLOCAL.VALUE>>
        dtext 650 <local.y> 0 <dLOCAL.newhalf><LOCAL.newhalf2><LOCAL.newhalf3>
        ELSEIF (<LOCAL.VALUE> >= 10000000) && (<LOCAL.VALUE> <= 99999999)
                   LOCAL.NEWHALF=<STRSUB 0 2 <dLOCAL.VALUE>>
                LOCAL.NEWHALF2=,<STRSUB 2 3 <dLOCAL.VALUE>>
                LOCAL.NEWHALF3=,<STRSUB 5 3 <dLOCAL.VALUE>>
        dtext 650 <local.y> 0 <dLOCAL.newhalf><LOCAL.newhalf2><LOCAL.newhalf3>
        ELSEIF (<LOCAL.VALUE> >= 100000000) && (<LOCAL.VALUE> <= 1000000000)
                   LOCAL.NEWHALF=<STRSUB 0 3 <dLOCAL.VALUE>>
                LOCAL.NEWHALF2=,<STRSUB 3 3 <dLOCAL.VALUE>>
                LOCAL.NEWHALF3=,<STRSUB 6 3 <dLOCAL.VALUE>>
        dtext 650 <local.y> 0 <dLOCAL.newhalf><LOCAL.newhalf2><LOCAL.newhalf3>
        endif
        tilepichue 300 <local.x> <eval <uid.<db.row.<eval (<local.index>)>.uid>.id>> <eval <uid.<db.row.<eval (<local.index>)>.uid>.color>>
        resizepic 275 <local.xs> 9300 507 5 <db.row.<eval (<local.index>)>.uid>
        resizepic 750 <local.buy> 9300 37 20 <db.row.<eval (<local.index>)>.uid>
        dtext 758 <local.buy> 0112 Buy
        dtext 650 <local.name> 0481 By <uid.<db.row.<eval (<local.index>)>.seller>.name>
        if (<uid.<db.row.<eval (<local.index>)>.uid>.istalisman>)
        elif (<uid.<db.row.<eval (<local.index>)>.uid>.isarmor>)
        dtext 381 <local.name> 0481 Dur: <uid.<db.row.<eval (<local.index>)>.uid>.MORE1L>/<uid.<db.row.<eval (<local.index>)>.uid>.MORE1H>
        ELif (<uid.<db.row.<eval (<local.index>)>.uid>.isjeweli>)
        dtext 500 <local.name> 0481 Plus +<uid.<db.row.<eval (<local.index>)>.uid>.MOREX>
        dtext 381 <local.name> 0481 Charges: <uid.<db.row.<eval (<local.index>)>.uid>.MOREM>
        ELif (<uid.<db.row.<eval (<local.index>)>.uid>.isjewelires>)
        dtext 381 <local.name> 0481 Charges: <uid.<db.row.<eval (<local.index>)>.uid>.MOREM>
        ELIF (<uid.<db.row.<eval (<local.index>)>.uid>.type>==t_jewelry)
        dtext 381 <local.name> 0481 Charges: <eval <uid.<db.row.<eval (<local.index>)>.uid>.tag.charge>>
        ELIF (<uid.<db.row.<eval (<local.index>)>.uid>.type>==t_charm)
        dtext 381 <local.name> 0481 Charges: <eval <uid.<db.row.<eval (<local.index>)>.uid>.morex>>
        ELIF (<uid.<db.row.<eval (<local.index>)>.uid>.baseid>==i_treature_map)
        dtext 381 <local.name> 0481 Level: <eval <uid.<db.row.<eval (<local.index>)>.uid>.tag.tlevel>>
        ELIF <uid.<db.row.<eval (<local.index>)>.uid>.isweapon>
        dtext 500 <local.name> 0481 Dmg: <uid.<db.row.<eval (<local.index>)>.uid>.DAM>
        dtext 381 <local.name> 0481 Dur: <uid.<db.row.<eval (<local.index>)>.uid>.MORE1L>/<uid.<db.row.<eval (<local.index>)>.uid>.MORE1H>
        ELIF <uid.<db.row.<eval (<local.index>)>.uid>.amount> > 1
        dtext 381 <local.name> 0481 Amount: <uid.<db.row.<eval (<local.index>)>.uid>.amount>
        ENDIF
    endif
ENDFOR

And there is the mysql code that inserts info in database
Code:
DB.EXECUTE "INSERT INTO <topobj.tag.auction_table>(uid, amount, category, name, currentbid, step, minimum_price, saletime, seller) VALUES('<link.uid>','<link.amount>','<eval <tag.category>>','<link.name>','<eval (<argtxt[1]>)>','0','0','99999999999','<src.uid>');"
DB.query "SELECT saletime FROM <topobj.tag.auction_table> WHERE uid='<link.uid>'"

How i can transfer all this, to set this vendor dialog appears on website??

1. i need all pictures get from server and host them to website, okey i can do that.. but i need each color to be hosted of each armor,weapon ect? or just 1 and then i can change color like ingame <hue> ??

If somebody knows about this then please give me advice Smile Cheers.


RE: mysql shop - admin phoenix - 01-29-2014 01:06 AM

make own columns for color, gumppic ids and so on Smile


RE: mysql shop - Pidrila - 01-29-2014 01:20 AM

(01-29-2014 01:06 AM)admin phoenix Wrote:  make own columns for color, gumppic ids and so on Smile

yes, but how do i appear these gumppic on html page??


RE: mysql shop - Feeh - 01-29-2014 04:14 AM

Since sphere does not allow the user to deal with images, you have these options:

1-Export every item+hue image creating a incredible large image database on your website, then export the item id and hue to the SQL table then loading these values on PHP/ASP/whatever

2-Create a custom application, to be started from scripts with SYSCMD, that export the requested item image as base64 string, then storing it to the SQL table and loading the string as image from the web part

3-Export the item id/hue to the SQL and create a PHP/ASP/whatever that is capable of reading the mul files on your web folder, generating the image and caching it


RE: mysql shop - admin phoenix - 01-29-2014 10:09 PM

http://forum.spherecommunity.net/Thread-UPDATED-Paperdoll-Web
there is a helpful php include


RE: mysql shop - Pidrila - 02-05-2014 09:26 PM

how i can send sysmessage to play that says which item he buys.. cant get it.. doesnt work..

Code:
[PLEVEL 1]
f_status_add_fire_lord


[function f_status_add_fire_lord]
db.connect
if ( <DB.connected> )
DB.QUERY "SELECT * FROM ibf_members WHERE status_fire_lord='1'"
    if (<DB.ROW.NUMROWS> > 0)
        for R 0 <eval <DB.ROW.NUMROWS>-1>
        if (<DB.ROW.<eval <LOCAL.R>>.status_fire_lord> = 1)
        serv.newitem=i_fames
        DB.EXECUTE "UPDATE ibf_members SET status_fire_lord='0' WHERE name='<DB.ROW.<eval <LOCAL.R>>.name>'"
        new.cont=<uid.<DB.ROW.<eval <LOCAL.R>>.uid>.findlayer.21.uid>
        serv.<DB.ROW.<eval <LOCAL.R>>.uid>.sysmessage eee // this dont work..
        serv.log Succesfull!!
        endif
        end
    endif
endif



RE: mysql shop - XuN - 02-05-2014 11:15 PM

ref1=<db.row.<dlocal.r>.uid>
ref1.sysmessage eee


RE: mysql shop - Pidrila - 02-06-2014 12:03 AM

i did this other way, But thanks Wink

Code:
try uid.<db.row.<eval <LOCAL.R>>.uid>.sysmessage @55 You just bought Fire Lord from Chaos Web Shop!



RE: mysql shop - XuN - 02-06-2014 12:31 AM

You are wellcome, however, if you are using 0.56x you don't need the TRY in this, and you can change <eval <local.r>> with <dlocal.r> (<dwhatever> just evals what you specify).


RE: mysql shop - Pidrila - 02-06-2014 05:05 AM

(02-06-2014 12:31 AM)XuN Wrote:  You are wellcome, however, if you are using 0.56x you don't need the TRY in this, and you can change <eval <local.r>> with <dlocal.r> (<dwhatever> just evals what you specify).

hmm, weird, i tryed to use without try before and it debuged me a error that cant resolve.. and im using 0.56b Wink