Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Selling doesnt sell
Author Message
kn4tseb
Master
**

Posts: 392
Likes Given: 45
Likes Received: 10 in 10 posts
Joined: May 2014
Reputation: 0



Post: #1
Selling doesnt sell
Well guys, im having problems with NEW_SELL and NEW_BUY.... selling gump isnt show in some vendor brains...


i tried to make a mixup between non NEW and NEW and it might work in some brains but will not in someothers....



EDIT: okey... after looooooooot of tests, its not possible to have the PACKET159=f_packet_0x9f
activated without having issues when selling, different brains cause different behavior and even by default, by only activating this packet, vendor brains will think Buying is selling, so no matter if you are buying or selling, the NPC will sell the item, never buys it.

And this is too bad because i cant override prices.. hope someone will take a look at the packet function. Im using a 7.0.18 version of the client.
(This post was last modified: 09-02-2014 01:48 PM by kn4tseb.)
09-02-2014 12:04 PM
Find all posts by this user Like Post Quote this message in a reply
kn4tseb
Master
**

Posts: 392
Likes Given: 45
Likes Received: 10 in 10 posts
Joined: May 2014
Reputation: 0



Post: #2
RE: Selling doesnt sell
Okey guys, i ve read the script and cant figure whats the deal with it.... it's made for VENDOR BRAIN and buying works fine, but when selling two things might happen, selling gump isnt shown and player has to re-login, or when selling items to NPC, behavior will be like if you were buying your own items from them...
someone with a bit knowledge on packet code will figure so i post the script.

PD: PACKET159=f_packet_0x9f
can be put anywhere inside sphere.ini ??

THANKS!

Code:
[defname defnames_shop_sell]
vendor_limit_sell        128    //amount of items displayed in the sell list
vendor_limit_buy        128    //amount of items displayed in the buy list

vendor_limit_names        16    //limit of characters of item names in vendor list
vendor_limit_packet_size    1024    //limit of characters per packet

vendor_sell_pets_shrunk        1    //Sell pets shrunk? 1 = Yes, 0 = No

[function new_buy]
if (<src.ischar>)
    if (<src.isplayer>)
        if !(<findlayer.26.rescount>)
            restock 1
        endif
        face=<src.uid>
        src.f_packet_0x09e 0, <uid>
        //buy
    endif
endif

[function new_sell]
if (<src.ischar>)
    if (<src.isplayer>)
        if !(<findlayer.28.rescount>)
            restock 1
        endif
        face=<src.uid>
        src.f_packet_0x09e 1, <uid>
        //sell
    endif
endif

[function f_packet_0x09e]
if (<uid.<argn2>.ischar>)
    if (<uid.<argn2>.npc>==brain_vendor)
        ctag.buysell=<argn1>
        if (<dargn1>==1)
            if (<uid.<argn2>.findlayer.28.rescount>)
                forcont <findlayer.21>
                    if (<uid.<argn2>.findlayer.28.findid.<baseid>>)
                        if (<tag0.override.value>) || (<value>)
                            if (<dlocal.x> < <ddef0.vendor_limit_sell>)
                                local.x += 1
                                local.uid<dlocal.x>=<uid>
                                local.uid<dlocal.x>.amount=<amount>
                                if (<tag0.override.value>)
                                    local.uid<dlocal.x>.value=<tag0.override.value>
                                else
                                    local.uid<dlocal.x>.value=<strarg <value>>
                                endif
                            endif
                        endif
                    endif
                endfor
                if (<local.x>)
                    for x 1 <local.x>
                        if (strmatch(<local.packet>,0))
                            local.packet=d<local.uid<dlocal.x>> w<uid.<local.uid<dlocal.x>>.dispiddec> w<uid.<local.uid<dlocal.x>>.color> w<uid.<local.uid<dlocal.x>>.amount> w<local.uid<dlocal.x>.value> w<qval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> < <ddef0.vendor_limit_names> ? <eval strlen(<uid.<local.uid<dlocal.x>>.name>)>:<ddef0.vendor_limit_names>> <qval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> < <ddef0.vendor_limit_names> ? <asc <uid.<local.uid<dlocal.x>>.name>>:<strsub 0 <eval <eval <ddef0.vendor_limit_names> *4> +-1> <asc <uid.<local.uid<dlocal.x>>.name>>>>
                            local.packetlength += <eval <qval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> < <ddef0.vendor_limit_names> ? <eval strlen(<uid.<local.uid<dlocal.x>>.name>)>:<ddef0.vendor_limit_names>> +14>
                            local.items += 1
                        else
                            if (<eval strlen(<local.packet> d<local.uid<dlocal.x>> w<uid.<local.uid<dlocal.x>>.dispiddec> w<uid.<local.uid<dlocal.x>>.color> w<uid.<local.uid<dlocal.x>>.amount> w<local.uid<dlocal.x>.value> w<qval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> < <ddef0.vendor_limit_names> ? <eval strlen(<uid.<local.uid<dlocal.x>>.name>)>:<ddef0.vendor_limit_names>> <qval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> < <ddef0.vendor_limit_names> ? <asc <uid.<local.uid<dlocal.x>>.name>>:<strsub 0 <eval <eval <ddef0.vendor_limit_names> *4> +-1> <asc <uid.<local.uid<dlocal.x>>.name>>>>)> < <ddef0.vendor_limit_packet_size>)
                                local.packet=<local.packet<dlocal.packetx>> d<local.uid<dlocal.x>> w<uid.<local.uid<dlocal.x>>.dispiddec> w<uid.<local.uid<dlocal.x>>.color> w<uid.<local.uid<dlocal.x>>.amount> w<local.uid<dlocal.x>.value> w<qval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> < <ddef0.vendor_limit_names> ? <eval strlen(<uid.<local.uid<dlocal.x>>.name>)>:<ddef0.vendor_limit_names>> <qval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> < <ddef0.vendor_limit_names> ? <asc <uid.<local.uid<dlocal.x>>.name>>:<strsub 0 <eval <eval <ddef0.vendor_limit_names> *4> +-1> <asc <uid.<local.uid<dlocal.x>>.name>>>>
                                local.packetlength += <eval <qval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> < <ddef0.vendor_limit_names> ? <eval strlen(<uid.<local.uid<dlocal.x>>.name>)>:<ddef0.vendor_limit_names>> +14>
                                local.items += 1
                            endif
                        endif
                    endfor
                    if (<dlocal.x> > 5)
                        uid.<argn2>.say You have many items I am interested in.
                    else
                        uid.<argn2>.say What would you like to sell?
                    endif
                    sendpacket 09e w<eval <local.packetlength> +9> d<argn2> w<local.items> <local.packet>
                else
                    uid.<argn2>.say Sorry you have nothing of interest.
                endif
            else
                uid.<argn2>.say Sorry I am not buying any items at this time.
            endif
        else
            if (<uid.<argn2>.findlayer.26.rescount>)
                forcont <uid.<argn2>.findlayer.26>
                    if (<tag0.override.value>) || (<value>)
                        if (<dlocal.x> < <ddef0.vendor_limit_buy>)
                            local.x += 1
                            local.uid<dlocal.x>=<uid>
                            if (<tag0.override.value>)
                                local.uid<dlocal.x>.value=<tag0.override.value>
                            else
                                local.uid<dlocal.x>.value=<strarg <value>>
                            endif
                        endif
                    endif
                endfor
            endif
            if (<uid.<argn2>.findlayer.27.rescount>)
                forcont <uid.<argn2>.findlayer.27>
                    if (<tag0.override.value>) || (<value>)
                        if (<dlocal.x> < <ddef0.vendor_limit_buy>)
                            local.x += 1
                            local.uid<dlocal.x>=<uid>
                            if (<tag0.override.value>)
                                local.uid<dlocal.x>.value=<tag0.override.value>
                            else
                                local.uid<dlocal.x>.value=<strarg <value>>
                            endif
                        endif
                    endif
                endfor
            endif
            if (<local.x>)
                for x 1 <local.x>
                    if (strmatch(<local.packet>,0))
                        local.packet=d<local.uid<dlocal.x>> w<uid.<local.uid<dlocal.x>>.dispiddec> w<uid.<local.uid<dlocal.x>>.color> w<uid.<local.uid<dlocal.x>>.amount> w<local.uid<dlocal.x>.value> w<qval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> < <ddef0.vendor_limit_names> ? <eval strlen(<uid.<local.uid<dlocal.x>>.name>)>:<ddef0.vendor_limit_names>> <qval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> < <ddef0.vendor_limit_names> ? <asc <uid.<local.uid<dlocal.x>>.name>>:<strsub 0 <eval <eval <ddef0.vendor_limit_names> *4> +-1> <asc <uid.<local.uid<dlocal.x>>.name>>>>
                        local.packetlength += <eval <qval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> < <ddef0.vendor_limit_names> ? <eval strlen(<uid.<local.uid<dlocal.x>>.name>)>:<ddef0.vendor_limit_names>> +14>
                        local.items += 1
                    else
                        if (<eval strlen(<local.packet> d<local.uid<dlocal.x>> w<uid.<local.uid<dlocal.x>>.dispiddec> w<uid.<local.uid<dlocal.x>>.color> w<uid.<local.uid<dlocal.x>>.amount> w<local.uid<dlocal.x>.value> w<qval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> < <ddef0.vendor_limit_names> ? <eval strlen(<uid.<local.uid<dlocal.x>>.name>)>:<ddef0.vendor_limit_names>> <qval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> < <ddef0.vendor_limit_names> ? <asc <uid.<local.uid<dlocal.x>>.name>>:<strsub 0 <eval <eval <ddef0.vendor_limit_names> *4> +-1> <asc <uid.<local.uid<dlocal.x>>.name>>>>)> < <ddef0.vendor_limit_packet_size>)
                            local.packet=<local.packet> d<local.uid<dlocal.x>> w<uid.<local.uid<dlocal.x>>.dispiddec> w<uid.<local.uid<dlocal.x>>.color> w<uid.<local.uid<dlocal.x>>.amount> w<local.uid<dlocal.x>.value> w<qval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> < <ddef0.vendor_limit_names> ? <eval strlen(<uid.<local.uid<dlocal.x>>.name>)>:<ddef0.vendor_limit_names>> <qval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> < <ddef0.vendor_limit_names> ? <asc <uid.<local.uid<dlocal.x>>.name>>:<strsub 0 <eval <eval <ddef0.vendor_limit_names> *4> +-1> <asc <uid.<local.uid<dlocal.x>>.name>>>>
                            local.packetlength += <eval <qval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> < <ddef0.vendor_limit_names> ? <eval strlen(<uid.<local.uid<dlocal.x>>.name>)>:<ddef0.vendor_limit_names>> +14>
                            local.items += 1
                        endif
                    endif
                endfor
                if (<dlocal.x> > 5)
                    uid.<argn2>.say I have many goods for sale.
                else
                    uid.<argn2>.say What would you like to buy?
                endif
                ctag.buysell=
                sendpacket 09e w<eval <local.packetlength> +9> d<argn2> w<local.items> <local.packet>
            else
                uid.<argn2>.say Sorry I do not have any items in for sale at this time.
            endif
        endif
    endif
endif
return 1

[function f_packet_0x9f]
ref1=<local.char>
ref2=((<local.6> | (<local.5> * 256)) | (( <local.4> | (<local.3> * 256)) * 65536))
for x 1 <local.8>
    local.item<dlocal.x>=((<local.<eval <local.item> +12>> | (<local.<eval <local.item> +11>> * 256)) | (( <local.<eval <local.item> +10>> | (<local.<eval <local.item> +9>> * 256)) * 65536))
    local.item<dlocal.x>.amount=(<local.<eval <local.item> +13>> | <local.<eval <local.item> +14>>)
    local.item += 6
endfor
if (<ref1.ctag0.buysell>)
    for x 1 <local.x>
        if (<ref1.findlayer.21.finduid.<local.item<dlocal.x>>>)
            if (<ref1.findlayer.21.finduid.<local.item<dlocal.x>>.tag0.override.value>)
                local.value += <eval <ref1.findlayer.21.finduid.<local.item<dlocal.x>>.tag0.override.value> *<dlocal.item<dlocal.x>.amount>>
            else
                local.value += <eval <strarg <ref1.findlayer.21.finduid.<local.item<dlocal.x>>.value>> *<dlocal.item<dlocal.x>.amount>>
            endif
        endif
    endfor
    if (<local.value>)
        if (<ref2.findlayer.29.more1> >= <local.value>)
            for x 1 <local.x>
                if (<ref1.findlayer.21.finduid.<local.item<dlocal.x>>>)
                    if (<ref1.findlayer.21.finduid.<local.item<dlocal.x>>.amount>==<dlocal.item<dlocal.x>.amount>)
                        ref1.findlayer.21.finduid.<local.item<dlocal.x>>.remove
                    elseif (<ref1.findlayer.21.finduid.<local.item<dlocal.x>>.amount> >= <dlocal.item<dlocal.x>.amount>)
                        ref1.findlayer.21.finduid.<local.item<dlocal.x>>.amount -= <local.item<dlocal.x>.amount>
                        ref1.findlayer.21.finduid.<local.item<dlocal.x>>.update
                    endif
                endif
            endfor
            ref2.timerf 1, speak I have bought your items for <dlocal.value> gold pieces.
            if (<dlocal.value>==1)
                ref2.sound=53
            elseif (<dlocal.value> < 5)
                ref2.sound=54
            else
                ref2.sound=55
            endif
            ref2.findlayer.29.more1 -= <local.value>
            while (<dlocal.value> >= 65535)
                serv.newitem=i_gold
                new.amount=65535
                new.cont=<ref1.findlayer.21>
                local.value -= 65535
            endwhile
            if (<local.value> > 0)
                serv.newitem=i_gold
                new.amount=<local.value>
                new.cont=<ref1.findlayer.21>
            endif
            ref2.timerf 1, speak Thank you.
        else
            ref2.timerf 1, speak I can not afford to purchase that from  you.
        endif
    else
        ref2.timerf 1, speak Sorry, your items have no value to me.
    endif
else
    for x 1 <local.x>
        if (<uid.<local.item<dlocal.x>>.tag0.override.value>)
            local.cost += <eval <uid.<local.item<dlocal.x>>.tag0.override.value> *<local.item<dlocal.x>.amount>>
        else
            local.cost += <eval <strarg <uid.<local.item<dlocal.x>>.value>> *<local.item<dlocal.x>.amount>>
        endif
    endfor
    if !(<ref1.isgm>)
        if (<serv.payfrompackonly>)
            if (<ref1.findlayer.21.rescount i_gold> >= <dlocal.cost>)
                ref2.findlayer.29.more1 += <local.cost>
                if (<ref2.findlayer.29.more1> > <ref2.findlayer.29.more2>)
                    ref2.findlayer.29.more1=<ref2.findlayer.29.more2>
                endif
                local.costx=<local.cost>
                forcont <ref1.findlayer.21>
                    if (<local.costx>)
                        if (<type>==t_gold)
                            if (<amount> > <local.costx>)
                                amount -= <local.costx>
                                update
                                local.costx=
                            else
                                local.costx -= <amount>
                                remove
                            endif
                        endif
                    endif
                endfor
            endif
        else
            if (<eval <ref1.findlayer.21.rescount i_gold> +<ref1.findlayer.29.rescount i_gold>> >= <dlocal.cost>) || (<ref1.isgm>)
                ref2.findlayer.29.more1 += <local.cost>
                if (<ref2.findlayer.29.more1> > <ref2.findlayer.29.more2>)
                    ref2.findlayer.29.more1=<ref2.findlayer.29.more2>
                endif
                local.costx=<local.cost>
                forcont <ref1.findlayer.21>
                    if (<local.costx>)
                        if (<type>==t_gold)
                            if (<amount> > <local.costx>)
                                amount -= <local.costx>
                                update
                                local.costx=
                            else
                                local.costx -= <amount>
                                remove
                            endif
                        endif
                    endif
                endfor
                if (<local.costx>)
                    forcont <ref1.findlayer.29>
                        if (<local.costx>)
                            if (<type>==t_gold)
                                if (<amount> > <local.costx>)
                                    amount -= <local.costx>
                                    update
                                    local.costx=
                                else
                                    local.costx -= <amount>
                                    remove
                                endif
                            endif
                        endif
                    endfor
                endif
            endif
        endif
    else
        local.costx=
    endif
    if (<dlocal.costx> < 1)
        for x 1 <local.x>
            if (<uid.<local.item<dlocal.x>>.type>==t_figurine)
                if !(<def0.vendor_sell_pets_shrunk>)
                    for <local.item<dlocal.x>.amount>
                        serv.newnpc=<uid.<local.item<dlocal.x>>.tdata3>
                        local.uid=<new.uid>
                        serv.newitem=i_memory
                        new.color=memory_ipet
                        new.link=<ref1.uid>
                        new.cont=<local.uid>
                        uid.<local.uid>.p=<ref2.p>
                        uid.<local.uid>.update
                        uid.<local.uid>.bark 1
                    endfor
                elseif ( <uid.<local.item<dlocal.x>>.can> & 0100 )
                    serv.newitem=<uid.<local.item<dlocal.x>>.baseid>
                    new.amount=<local.item<dlocal.x>.amount>
                    new.cont=<ref1.findlayer.21>
                else
                    for <local.item<dlocal.x>.amount>
                        serv.newitem=<uid.<local.item<dlocal.x>>.baseid>
                        new.cont=<ref1.findlayer.21>
                    endfor
                endif
            else
                if ( <uid.<local.item<dlocal.x>>.can> & 0100 )
                    serv.newitem=<uid.<local.item<dlocal.x>>.baseid>
                    new.amount=<local.item<dlocal.x>.amount>
                    new.cont=<ref1.findlayer.21>
                else
                    for <local.item<dlocal.x>.amount>
                        serv.newitem=<uid.<local.item<dlocal.x>>.baseid>
                        new.cont=<ref1.findlayer.21>
                    endfor
                endif
            endif
            if (strmatch(<local.items>,0))
                local.items=<uid.<local.item<dlocal.x>>.name>
            else
                if !(<local.item<eval <local.x> +1>>)
                    local.items=<local.items>, and <uid.<local.item<dlocal.x>>.name>
                else
                    local.items=<local.items>, <uid.<local.item<dlocal.x>>.name>
                endif
            endif
            uid.<local.item<dlocal.x>>.amount -= <local.item<dlocal.x>.amount>
            if (<uid.<local.item<dlocal.x>>.amount> < 1)
                uid.<local.item<dlocal.x>>.remove
            endif
        endfor
        ref2.timerf 1, speak Here <qval <dlocal.x>==1 ?is:are> <qval <dlocal.x>==1 ?your:your items> <local.items>.
        ref2.timerf 1, speak That will be <dlocal.cost> gold.
        if (<dlocal.value>==1)
            ref2.sound=53
        elseif (<dlocal.value> < 5)
            ref2.sound=54
        else
            ref2.sound=55
        endif
        ref2.timerf 1, speak Thank you very much!
    else
        if (<serv.payfrompackonly>)
            ref2.timerf 1, speak Sorry but you can not afford that.  You are missing <eval <local.cost> +-<ref1.findlayer.21.rescount i_gold>> gold pieces.
        else
            ref2.timerf 1, speak Sorry but you can not afford that.  You are missing <eval <local.cost> +-<eval <ref1.findlayer.21.rescount i_gold> +<ref1.findlayer.29.rescount i_gold>>> gold pieces.
        endif
    endif
endif
ref2.updatex
return 1
SO the thing is no matter if NEW_BUY or NEW_SELL functions are enable or not, by only activating the packet handling 159 inside sphere.ini there's a wrong behavior when selling, it just acts like if you were buying your own items..
(This post was last modified: 09-03-2014 10:47 AM by kn4tseb.)
09-03-2014 09:42 AM
Find all posts by this user Like Post Quote this message in a reply
kn4tseb
Master
**

Posts: 392
Likes Given: 45
Likes Received: 10 in 10 posts
Joined: May 2014
Reputation: 0



Post: #3
RE: Selling doesnt sell
this is the gump i get after waiting a while when selling.


Attached File(s) Thumbnail(s)
   
09-03-2014 11:29 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)