Skul
Master
Posts: 413
Likes Given: 0
Likes Received: 19 in 15 posts
Joined: Jun 2012
Reputation: 9
|
Shop Sell packet
I redid the Shop Sell packet on my server and I'm having a problem that I can't understand. When trying to buy from a provisioner NPC, I get a total packet length of 1002 characters and spheresvr.exe returns a 'Packet Too Big' error. This does not allow anyone to buy from a provisioner. Then on the other hand I can buy from an armorer even though the packet length is over 3000 characters.
Here's the code:
Code:
[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=<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<uid.<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>>>>
else
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<uid.<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>>>>
endif
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>
endfor
if (<dlocal.x> > 5)
uid.<argn2>.speak You have many items I am interested in.
else
uid.<argn2>.speak What would you like to sell?
endif
sendpacket 09e w<eval <local.packetlength> +9> d<argn2> w<local.x> <local.packet>
else
uid.<argn2>.speak Sorry you have nothing of interest.
endif
else
uid.<argn2>.speak 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=<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=<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<uid.<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>>>>
else
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<uid.<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>>>>
endif
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>
endfor
if (<dlocal.x> > 5)
uid.<argn2>.speak I have many goods for sale.
else
uid.<argn2>.speak What would you like to buy?
endif
ctag.buysell=
serv.b <eval strlen(<local.packet>)>
sendpacket 09e w<eval <local.packetlength> +9> d<argn2> w<local.x> <local.packet>
else
uid.<argn2>.speak Sorry I do not have any items in for sale at this time.
endif
endif
endif
endif
return 1
Any feedback? Looks complicated but this line here:
Code:
serv.b <eval strlen(<local.packet>)>
returns the total packet length.
How is it that 1002 characters is 'Too Big' while over 3000 characters is not?
Any feedback is much appreciated, thank you.
"I ask a question to the answer I already know."
Marchadium :: http://www.marchadium.ca/ :: Join us!
|
|
06-15-2014 11:57 AM |
|
|
Skul
Master
Posts: 413
Likes Given: 0
Likes Received: 19 in 15 posts
Joined: Jun 2012
Reputation: 9
|
RE: Shop Sell packet
Here's the whole script, it is very easy to install. The purpose of this script is to allow tag.override.value on items to alter the value of an item without having to change the script file for that item.
Code:
[comment information]
This script allows you to add 'tag.override.value' to any item in-game to modify the value of an item sold on a vendor.
Installation:
Open speakshopkeep.scp and replace the BUY command with NEW_BUY and the SELL command with NEW_SELL.
Enjoy.
[defname defnames_shop_sell]
vendor_limit_sell 32 //amount of items displayed in the sell list
vendor_limit_buy 32 //amount of items displayed in the buy list
vendor_limit_names 8 //limit of characters of item names in vendor list
[function new_buy]
if (<src.ischar>)
if (<src.isplayer>)
if !(<src.tag0.new_buysell>)
src.tag.new_buysell=1
src.timerf 1, tag.new_buysell=
buy
updatex
dorand 4
speak Yes?
speak Hmm?
Speak Hold on.
Speak One moment.
enddo
src.timerf 1, f_packet_0x09e 0, <uid>
endif
endif
endif
[function new_sell]
if (<src.ischar>)
if (<src.isplayer>)
if !(<src.tag0.new_buysell>)
src.tag.new_buysell=1
src.timerf 1, tag.new_buysell=
sell
updatex
dorand 4
speak Yes?
speak Hmm?
Speak Hold on.
Speak One moment.
enddo
src.timerf 1, f_packet_0x09e 1, <uid>
endif
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=<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<uid.<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>>>>
else
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<uid.<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>>>>
endif
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>
endfor
if (<dlocal.x> > 5)
uid.<argn2>.speak You have many items I am interested in.
else
uid.<argn2>.speak What would you like to sell?
endif
sendpacket 09e w<eval <local.packetlength> +9> d<argn2> w<local.x> <local.packet>
else
uid.<argn2>.speak Sorry you have nothing of interest.
endif
else
uid.<argn2>.speak 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=<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=<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<uid.<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>>>>
else
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<uid.<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>>>>
endif
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>
endfor
if (<dlocal.x> > 5)
uid.<argn2>.speak I have many goods for sale.
else
uid.<argn2>.speak What would you like to buy?
endif
ctag.buysell=
//serv.b <eval strlen(<local.packet>)>
sendpacket 09e w<eval <local.packetlength> +9> d<argn2> w<local.x> <local.packet>
else
uid.<argn2>.speak 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>>.amount>==<dlocal.item<dlocal.x>.amount>)
local.value += <eval <ref1.findlayer.21.finduid.<local.item<dlocal.x>>.value> * <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>)
local.value += <eval <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>)
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, 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 += <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>)
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.timerf 1, speak Here <qval <dlocal.x>==1 ?is:are> your <qval <dlocal.x>==1 ?item: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
if !(<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
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
ref2.timerf 1, speak Thank you very much!
else
ref2.timerf 1, speak Sorry but you can not afford that.
endif
endif
ref2.updatex
return 1
[eof]
Just to let you know, when I try buying from a provisioner I get: Quote:SENDPACKET too big.
yet buying from an armorer has more items and gives no error.
"I ask a question to the answer I already know."
Marchadium :: http://www.marchadium.ca/ :: Join us!
(This post was last modified: 06-16-2014 02:30 AM by Skul.)
|
|
06-16-2014 02:19 AM |
|
|
Skul
Master
Posts: 413
Likes Given: 0
Likes Received: 19 in 15 posts
Joined: Jun 2012
Reputation: 9
|
RE: Shop Sell packet
here's an example:
Code:
[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
src.targetf f_function //target
serv.newitem=i_memory_memory //your memory object
src.equip=<new.uid> //equip memory object
endif
endif
Keep in mind I just updated the Shop Sell script, you might want to update before adding your code.
"I ask a question to the answer I already know."
Marchadium :: http://www.marchadium.ca/ :: Join us!
(This post was last modified: 06-19-2014 11:11 AM by Skul.)
|
|
06-19-2014 11:11 AM |
|
|
mrkarlo
Journeyman
Posts: 160
Likes Given: 3
Likes Received: 6 in 5 posts
Joined: Mar 2012
Reputation: 1
|
RE: Shop Sell packet
thanks Skul for respond, but there is no any Target.
Code:
src.targetf f_new_buy //target
serv.newitem=i_memory_xx //your memory object
src.equip=<new.uid> //equip memory object
Code:
[ITEMDEF i_memory_xx]
ID=i_memory
lalala
ON=@Equip
TARGET Select target
(This post was last modified: 06-19-2014 06:28 PM by mrkarlo.)
|
|
06-19-2014 06:28 PM |
|
|