The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Vendor Shop HELP
Author Message
Skul
Master
**

Posts: 413
Likes Given: 0
Likes Received: 19 in 15 posts
Joined: Jun 2012
Reputation: 9



Post: #11
RE: Vendor Shop HELP
tag.override.value would be great.

this is the best script I could 'muster' up, it sendpacket doesn't work at all, not sure why exactly, here it is:
Code:
[function testbuy]
sysmessage Buy from who?
targetf f_testbuy

[function testbuy]
if (<argo.ischar>)
    if (<argo.npc>==brain_vendor)
        if (<argo.findlayer.26.rescount>)
            forcont <argo.findlayer.26>
                if (<tag0.override.value>)
                    local.x += 1
                    local.id<dlocal.x>.value=<tag0.override.value>
                    local.id<dlocal.x>.name=<name>
                elseif (<value>)
                    local.x += 1
                    local.id<dlocal.x>.value=<value>
                    local.id<dlocal.x>.name=<name>
                endif
            endfor
            if (<local.x>)
                for x 1 <local.x>
                    if (strmatch(<local.packet>,0))
                        local.packet=d<local.id<dlocal.x>.value> <eval strlen(<local.id<dlocal.x>.name>)> <char_to_asc <local.id<dlocal.x>.name>>
                    else
                        local.packet=<local.packet> d<local.id<dlocal.x>.value> <eval strlen(<local.id<dlocal.x>.name>)> <char_to_asc <local.id<dlocal.x>.name>>
                    endif
                endfor
                sendpacket 074 <totalargs 074 0 d<targ.uid> <local.x> <local.packet>> d<targ.uid> <local.x> <local.packet>
            endif
        else
            argo.speak i have nothing to sell.
        endif
    endif
endif

[function char_to_asc]
if !(<isempty <args>>)
    local.x=<eval strlen(<args>)>
    local.args=<args>
    while (<local.x>)
        if (strmatch(<local.return>,0))
            local.return=<asc <strsub 0 1 <local.args>>>
        else
            local.return=<local.return> <asc <strsub 0 1 <local.args>>>
        endif
        local.args=<strsub 1 0 <local.args>>
        local.x -= 1
    endwhile
endif
return <local.return>

[function totalargs]
if !(<isempty <args>>)
    local.args=<args>
    while !(strmatch(<local.args>,0))
        local.x += 1
        local.args=<streat <local.args>>
    endwhile
endif
return <dlocal.x>

[eof]

"I ask a question to the answer I already know."

Marchadium :: http://www.marchadium.ca/ :: Join us!
09-24-2012 02:41 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Extreme
Grandmaster Poster
***

Posts: 1,141
Likes Given: 217
Likes Received: 90 in 77 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #12
RE: Vendor Shop HELP
Yeah, sendpacket problem :/
02:13:ERROR:(test.scp,559)SENDPACKET too big.

PS: fix the function f_testbuy, it's 'testbuy' too Big Grin

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
(This post was last modified: 09-24-2012 03:15 PM by Extreme.)
09-24-2012 03:14 PM
Find all posts by this user Like Post Quote this message in a reply
Skul
Master
**

Posts: 413
Likes Given: 0
Likes Received: 19 in 15 posts
Joined: Jun 2012
Reputation: 9



Post: #13
RE: Vendor Shop HELP
ya i know lol, I'm still having problems with it... same errors too.

Well here's the amazing piece of code that doesn't crash or anything, the packet doesn't do anything, looks right to me, any guesses?

Code:
[function testbuy]
sysmessage Buy from who?
targetf f_testbuy

[function f_testbuy]
if (<argo.ischar>)
    if (<argo.npc>==brain_vendor)
        if (<argo.findlayer.26.rescount>)
            forcont <argo.findlayer.26>
                if (<tag0.override.value>) || (<value>)
                    local.x += 1
                    local.id<dlocal.x>.name=<name>
                    local.id<dlocal.x>.value=<qval <tag0.override.value> ?<tag0.override.value>:<value>>
                endif
            endfor
            if (<local.x>)
                for x 1 <local.x>
                    if (strmatch(<local.packet>,0))
                        local.packet=d<local.id<dlocal.x>.value> <eval strlen(<local.id<dlocal.x>.name>)> <asc <local.id<dlocal.x>.name>>
                    else
                        local.packet=<local.packet> d<local.id<dlocal.x>.value> <eval strlen(<local.id<dlocal.x>.name>)> <asc <local.id<dlocal.x>.name>>
                    endif
                    local.packetlength += <eval <eval strlen(<local.id<dlocal.x>.name>)> +5>
                endfor
                sendpacket 074 w<eval <local.packetlength> +10> d<argo.uid> <local.x> 0 <local.packet> 0
            endif
        else
            argo.speak i have nothing to sell.
        endif
    endif
endif

"I ask a question to the answer I already know."

Marchadium :: http://www.marchadium.ca/ :: Join us!
(This post was last modified: 09-24-2012 04:22 PM by Skul.)
09-24-2012 03:59 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Skul
Master
**

Posts: 413
Likes Given: 0
Likes Received: 19 in 15 posts
Joined: Jun 2012
Reputation: 9



Post: #14
RE: Vendor Shop HELP
Well this code sort of works, it's an item list? I don't know, maybe you can find it useful:
Code:
[function testbuy2]
sysmessage Buy from who?
targetf f_testbuy2

[function f_testbuy2]
if (<argo.ischar>)
    if (<argo.npc>==brain_vendor)
        if (<argo.findlayer.26.rescount>)
            forcont <argo.findlayer.26>
                if (<tag0.override.value>) || (<value>)
                    local.x += 1
                    local.uid<dlocal.x>=<uid>
                endif
            endfor
            if (<local.x>)
                for x 1 <local.x>
                    if (strmatch(<local.packet>,0))
                        local.packet=w<uid.<local.uid<dlocal.x>>.baseid> w<uid.<local.uid<dlocal.x>>.color> <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> <asc <uid.<local.uid<dlocal.x>>.name>>
                    else
                        local.packet=<local.packet> w<uid.<local.uid<dlocal.x>>.baseid> w<uid.<local.uid<dlocal.x>>.color> <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> <asc <uid.<local.uid<dlocal.x>>.name>>
                    endif
                    local.packetlength += <eval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> +5>
                endfor
                local.title=<argo.title> Shoppe
                local.packetlength += <eval strlen(<local.title>)>
                sendpacket 07c w<eval <local.packetlength> +11> d<argo.uid> w0870 <eval strlen(<local.title>)> <asc <local.title>> <local.x> <local.packet>
            endif
        else
            argo.speak I have nothing to sell.
        endif
    endif
endif

Here, this is the code you want, it's unfinished but at least you can view the shop list and use <tag.override.value> on any item.
Code:
[function testbuy3]
sysmessage Buy from who?
targetf f_testbuy3

[function f_testbuy3]
if (<argo.ischar>)
    if (<argo.npc>==brain_vendor)
        if (<argo.findlayer.26.rescount>)
            forcont <argo.findlayer.26>
                if (<tag0.override.value>) || (<value>)
                    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=<value>
                    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>>.baseid> w<uid.<local.uid<dlocal.x>>.color> w<uid.<local.uid<dlocal.x>>.amount> w<uid.<local.uid<dlocal.x>>.value> w<eval strlen(<uid.<local.uid<dlocal.x>>.name>)> <asc <uid.<local.uid<dlocal.x>>.name>>
                    else
                        local.packet=<local.packet> d<local.uid<dlocal.x>> w<uid.<local.uid<dlocal.x>>.baseid> w<uid.<local.uid<dlocal.x>>.color> w<uid.<local.uid<dlocal.x>>.amount> w<uid.<local.uid<dlocal.x>>.value> w<eval strlen(<uid.<local.uid<dlocal.x>>.name>)> <asc <uid.<local.uid<dlocal.x>>.name>>
                    endif
                    local.packetlength += <eval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> +14>
                endfor
                serv.log <local.packet>
                sendpacket 09e w<eval <local.packetlength> +9> d<argo.uid> w<local.x> <local.packet>
                return 1
            endif
        endif
        argo.speak I have nothing to sell.
    endif
endif

"I ask a question to the answer I already know."

Marchadium :: http://www.marchadium.ca/ :: Join us!
(This post was last modified: 09-26-2012 02:39 PM by Skul.)
09-26-2012 02:13 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Skul
Master
**

Posts: 413
Likes Given: 0
Likes Received: 19 in 15 posts
Joined: Jun 2012
Reputation: 9



Post: #15
RE: Vendor Shop HELP
This is the packet you'll need to buy an item from a vendor
Code:
[comment sphere]
in sphere.ini add:
packet159=f_packet_0x9f

[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
for x 1 <local.x>
    if (<uid.<local.item<dlocal.x>>.tag0.override.value>)
        local.cost += <uid.<local.item<dlocal.x>>.tag0.override.value>)
    else
        local.cost += <uid.<local.item<dlocal.x>>.value>
    endif
endfor
if (<eval <ref1.findlayer.21.rescount i_gold> +<ref1.findlayer.29.rescount i_gold>> >= <dlocal.cost>) || (<ref1.isgm>)
    if !(<ref1.isgm>)
        forcont <ref1.findlayer.21>
            if (<local.cost>)
                if (<type>==t_gold)
                    if (<amount> > <local.cost>)
                        amount -= <local.cost>
                        update
                        local.cost=
                    else
                        local.cost -= <amount>
                        remove
                    endif
                endif
            endif
        endfor
        if (<local.cost>)
            forcont <ref1.findlayer.29>
                if (<local.cost>)
                    if (<type>==t_gold)
                        if (<amount> > <local.cost>)
                            amount -= <local.cost>
                            update
                            local.cost=
                        else
                            local.cost -= <amount>
                            remove
                        endif
                    endif
                endif
            endfor
        endif
    endif
    for x 1 <local.x>
        if (<uid.<local.item<dlocal.x>>.amount>==<dlocal.item<dlocal.x>>.amount>)
            ujd.<local.item<dlocal.x>>.cont=<ref1.findlayer.21>
        else
            uid.<local.item<dlocal.x>>.amount -= <local.item<dlocal.x>.amount>
            serv.newitem=<uid.<local.item<dlocal.x>>.baseid>
            new.amount=<local.item<dlocal.x>.amount>
            new.cont=<ref1.findlayer.21>
        endif
    endfor
    ref2.speak That will be <dlocal.cost> gold.  Thank you very much!
else
    ref2.speak You can not afford that.
endif    
ref1.sendpacket 09e w24 d<ref2.uid> w0 d0 w0 w0 w0 w0 w0 0 //I was hoping this line will close the vendor list, but it doesn't do anything.

"I ask a question to the answer I already know."

Marchadium :: http://www.marchadium.ca/ :: Join us!
09-26-2012 08:18 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Extreme
Grandmaster Poster
***

Posts: 1,141
Likes Given: 217
Likes Received: 90 in 77 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #16
RE: Vendor Shop HELP
Thanks Skul!
I will try it later, I'm very busy at university... lot of exams :/

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
09-27-2012 01:22 AM
Find all posts by this user Like Post Quote this message in a reply
Skul
Master
**

Posts: 413
Likes Given: 0
Likes Received: 19 in 15 posts
Joined: Jun 2012
Reputation: 9



Post: #17
RE: Vendor Shop HELP
OK Extreme, here's the code.
Code:
[comment information]
Add PACKET159=f_packet_0x9f to sphere.ini

[function testbuy]
sysmessage Buy from who?
targetf f_testbuy

[function f_testbuy]
if (<argo.ischar>)
    argn1=<argo.uid>
endif
if (<uid.<argn1>.ischar>)
    if (<uid.<argn1>.npc>==brain_vendor)
        if (<uid.<argn1>.findlayer.26.rescount>)
            forcont <uid.<argn1>.findlayer.26>
                if (<tag0.override.value>) || (<value>)
                    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=<value>
                    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>>.dispid> w<uid.<local.uid<dlocal.x>>.color> w<uid.<local.uid<dlocal.x>>.amount> w<uid.<local.uid<dlocal.x>>.value> w<eval strlen(<uid.<local.uid<dlocal.x>>.name>)> <asc <uid.<local.uid<dlocal.x>>.name>>
                    else
                        local.packet=<local.packet> d<local.uid<dlocal.x>> w<uid.<local.uid<dlocal.x>>.dispid> w<uid.<local.uid<dlocal.x>>.color> w<uid.<local.uid<dlocal.x>>.amount> w<uid.<local.uid<dlocal.x>>.value> w<eval strlen(<uid.<local.uid<dlocal.x>>.name>)> <asc <uid.<local.uid<dlocal.x>>.name>>
                    endif
                    local.packetlength += <eval <eval strlen(<uid.<local.uid<dlocal.x>>.name>)> +14>
                endfor
                if !(<argn2>)
                    if (<dlocal.x> > 5)
                        uid.<argn1>.speak I have many goods for sale.
                    else
                        uid.<argn1>.speak What would you like yo buy?
                    endif
                endif
                sendpacket 09e w<eval <local.packetlength> +9> d<argn1> w<local.x> <local.packet>
                return 1
            endif
        endif
        if !(<argn2>)
            argo.speak I have nothing to sell.
        endif
    endif
endif

[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
for x 1 <local.x>
    if (<uid.<local.item<dlocal.x>>.tag0.override.value>)
        local.cost += <uid.<local.item<dlocal.x>>.tag0.override.value>)
    else
        local.cost += <uid.<local.item<dlocal.x>>.value>
    endif
endfor
if (<eval <ref1.findlayer.21.rescount i_gold> +<ref1.findlayer.29.rescount i_gold>> >= <dlocal.cost>) || (<ref1.isgm>)
    if !(<ref1.isgm>)
        forcont <ref1.findlayer.21>
            if (<local.cost>)
                if (<type>==t_gold)
                    if (<amount> > <local.cost>)
                        amount -= <local.cost>
                        update
                        local.cost=
                    else
                        local.cost -= <amount>
                        remove
                    endif
                endif
            endif
        endfor
        if (<local.cost>)
            forcont <ref1.findlayer.29>
                if (<local.cost>)
                    if (<type>==t_gold)
                        if (<amount> > <local.cost>)
                            amount -= <local.cost>
                            update
                            local.cost=
                        else
                            local.cost -= <amount>
                            remove
                        endif
                    endif
                endif
            endfor
        endif
    endif
    for x 1 <local.x>
        if (<uid.<local.item<dlocal.x>>.amount>==<dlocal.item<dlocal.x>.amount>)
            uid.<local.item<dlocal.x>>.cont=<ref1.findlayer.21>
        else
            uid.<local.item<dlocal.x>>.amount -= <local.item<dlocal.x>.amount>
            serv.newitem=<uid.<local.item<dlocal.x>>.baseid>
            new.amount=<local.item<dlocal.x>.amount>
            new.cont=<ref1.findlayer.21>
        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
    endfor
    ref2.speak Here <qval <dlocal.x>==1 ?is:are> your <qval <dlocal.x>==1 ?item:items> <local.items>.
    ref2.speak That will be <dlocal.cost> gold.
    ref2.speak Thank you very much!
    ref2.findlayer.29.more1 += <local.cost>
    if (<ref2.findlayer.29.more1> > <ref2.findlayer.29.more2>)
        ref2.findlayer.29.more1=<ref2.findlayer.29.more2>
    endif
else
    ref2.speak You can not afford that.
endif
ref1.f_testbuy <ref2.uid>, 1
return 1

"I ask a question to the answer I already know."

Marchadium :: http://www.marchadium.ca/ :: Join us!
09-27-2012 10:33 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Extreme
Grandmaster Poster
***

Posts: 1,141
Likes Given: 217
Likes Received: 90 in 77 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #18
RE: Vendor Shop HELP
Alright, worked very nice, but if have many items, the sendpacket is blocked as "too big".
Thats sucks we need to remake the whole system because it got changed...

I remember that every item bought by the vendor, he sell it later.
But the restock timer is very small so the items also disappear.
And of course it doesn't show in list.

Thank you very much Skul!
Thanks for your help, make this script had spent a lot of time.

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
09-27-2012 12:36 PM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


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