SphereCommunity
commerce stone help - Printable Version

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



commerce stone help - kevin465 - 05-25-2014 06:53 PM

is that it is possible to ensure that a player can not enter a number less than zero to sell their item? because they can enter a number as - $ 5000! and when he enters a negative number it never cost a number they enter

Code:
[ITEMDEF i_stone_commerce]
NAME=Stone of Commerce
ID=i_grave_stone
type=t_script

ON=@CREATE
COLOR=0810
ATTR 010
type=t_Script
timer=60*60*24            
CATEGORY=Custom Items
DESCRIPTION=Stone of Commerce

ON=@DCLICK
if <link>==04fffffff
    src.newitem=i_storage_Chest
    src.act.p=<p>
    src.act.z=-120
    src.act.timer=-1
    src.act.attr=ATTR_STATIC
    link=<src.act.uid>
endif

src.tag.forsale.stone=<uid>
SRC.dialog d_buy_sell
region.tag.forsale.count=
RETURN 1

ON=@TARGON_ITEM
if <src.targ.cont>==<src.findlayer.21.uid>
    if <src.targ.amount>==1
        src.tag.forsale.uid=<src.targ.uid>
        src.tag.forsale.name=<src.targ.name>
        src.tag.forsale.seller.uid=<src.uid>
        src.tag.forsale.seller=<src.name>
        src.tag.forsale.color=<src.targ.color>
        src.tag.forsale.id=<src.targ.id>
        src.dialog d_sellstuff
    else
        src.message You cannot sell stackables.
    endif
else
    src.message The item must be in your pack to sell it.
endif
RETURN 1

on=@timer
    region.tag.forsale.count=<more>
    f_purgeunusedtags
    timer=60*60*24
return 1


[ITEMDEF i_storage_chest]
id=09ab
type=t_container
on=@create
attr=08080

on=@dclick
if <src.isgm>
    return 0
else
    return 1
endif



////////////////////
/////Dialogs///////
//////////////////

[DIALOG d_buy_sell]
100,75
resizepic 210 175 5054 240 140
resizepic 220 185 3000 220 120
text 265 185 0 0
text 265 215 995 1
text 300 235 5 2
text 300 260 5 3
button 265 235 4005 4007 1 0 1
button 265 260 4005 4007 1 0 2

[DIALOG d_buy_sell TEXT]
Commerce Stone
I want to....
Buy
Sell-<eval salesfee> GP

[DIALOG d_buy_sell BUTTON]
ONBUTTON=0 //cancel
return 1
ONBUTTON=1 //buy
    src.tag.temp.buystuff=1
    src.dialog d_buystuff
return 1
ONBUTTON=2 //sell
    if <RESTEST <eval salesfee> i_gold>
        targ.target Choose the item you want to sell.
    ELSE
        src.message <eval salesfee> gold is required
    endif
return 1


[DIALOG d_sellstuff]
100,75
resizepic 50 50 5054 540 330
resizepic 60 60 3000 520 310
text 70 70 0 0
text 70 100 5 1
text 210 100 5 2
text 340 100 5 3
text 470 100 5 4
text 70 140 033 6
resizepic 110 140 3000 100 22
textentry 120 140 253 25 0 0 7
Group 1

text 215 140 54 8
text 240 150 900 9

tilepic 320 135 <eval <targ.id>>
resizepic 150 195 3000 270 22
text 70 195 033 10
textentry 160 195 253 25 0 0 11

Group 2
radio 70 220 210 211 0 3
radio 70 240 210 211 0 4
radio 70 260 210 211 0 5
radio 70 280 210 211 0 6
text 90 220 000 12
text 90 240 000 13
text 90 260 000 14
text 90 280 000 15
button 220 330 4030 4031 1 0 1
text 255 330 5 16

[DIALOG d_sellstuff TEXT]
Item:              UID:           Seller Name:     Seller UID:
<tag.forsale.name>
<TAG.FORSALE.uid>
<TAG.FORSALE.seller>
<TAG.FORSALE.seller.uid>
<eval <tag.forsale.price>> <tag.forsale.currency>
Price:
<eval <TAG.FORSALE.price>>
Gold
<>
Description:
<TAG.FORSALE.description>
Armor
Weapons
Jewelry
Misc/Craftables
Finished

[DIALOG d_sellstuff BUTTON]
ONBUTTON=0 //cancel
    TAG.FORSALE.seller.uid=
    TAG.FORSALE.seller=
    TAG.FORSALE.price=
    TAG.FORSALE.currency=
    TAG.FORSALE.description=
    TAG.FORSALE.color=
    TAG.FORSALE.uid=
    TAG.FORSALE.name=
    TAG.FORSALE.category=
    TAG.FORSALE.id=
    TAG.FORSALE.stone=
ONBUTTON=1 //submit
    if <SRC.RESTEST <eval salesfee> i_gold>
        //if <eval <ARGTXT[0]>>>64000
        //    SRC.SYSMESSAGE The Amount must be less than 64,000. Try a different Currency.
        //    dialog d_sellstuff
        //    RETURN 1
        //else
            TAG.FORSALE.price=<eval <ARGTXT[0]>>
            //if <ARGCHK[1]>==1
                tryp 0 TAG.FORSALE.currency=i_gold
            //else
                //tryp 0 TAG.FORSALE.currency=i_platinum_ingot
            //endif
        //endif

        TAG.FORSALE.description=<ARGTXT[0]>
        if <ARGCHK[3]>==1
            tryp 0 TAG.FORSALE.category=Armor
        elseif <ARGCHK[4]>==1
            tryp 0 TAG.FORSALE.category=Weapons
        elseif <ARGCHK[5]>==1
            tryp 0 TAG.FORSALE.category=Jewelery
        elseif <ARGCHK[6]>==1
            tryp 0 TAG.FORSALE.category=Misc
        else
            sysMessage You must choose a Category!
            dialog d_sellstuff
            return 1
        endif
        if <src.tag.forsale.price>!=0
            SRC.CONSUME <eval salesfee> i_gold
            f_loop_sales
        else
            sysMessage You must set a price.
            dialog d_sellstuff
        endif
    ELSE
         sysMessage You must have 1k gold
    ENDIF
    return 1



RE: commerce stone help - XuN - 05-25-2014 07:32 PM

ONBUTTON=1 //submit
...
..
..
..TAG.FORSALE.price=<eval <ARGTXT[0]>> <--- change this line to this
Code:
if !(<IsNum <ARGTXT[0]>>)
return 1
endif
if (<ARGTXT[0]> < 0)
ARGTXT[0] *=-1 // multiplying a negative number by -1 results in its positive value.
endif
TAG.FORSALE.price=<ARGTXT[0]>//tags are stored in hex value, no matter if you give hex or dec values, so there's no point of using <eval > in something that is going to be stored in hex anyway.



RE: commerce stone help - pinku - 05-25-2014 07:39 PM

Code:
IF STRREGEX(^[0-9]+$,<ARGTXT[0]>)
SRC.SYSMESSAGE Proceed!
...
...
...

you can check using this

edit: there we go, XuN was faster. hahaha Smile


RE: commerce stone help - kevin465 - 05-25-2014 08:08 PM

dont work know its the buyers gain money !?