SphereCommunity
Vendor Supply - Printable Version

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



Vendor Supply - Van Glan Bloom - 06-13-2015 01:25 PM

Hi guys,

What i make wrong in this script? I try make a vendor suplly where the player can choose the number of itens for buy. However the script is not to check if the player has the necessary money in the bag

I have this :

Code:
if (src.findlayer(21).rescount i_gold> < (<EVAL(<ARGTXT[0]>) *100>)
src.sysmessage @09c1 You do not have enought gold coins to trade.
else
serv.newitem i_log, <eval(<argtxt[0]>)>,<src.findlayer.21.uid>
src.consume i_gold (<eval(<argtxt[0]>) *100)
src.act.bounce
return 1
endif




This problem is solved.
Now i have other bug, if I Enter a value that is not numeric it gives error in sphere

Code:
04:49:ERROR:(System - NPC Vendor Supply.scp,505)Undefined symbol '' ['<a']

I can indicate that the script can only enter numeric values?




The problem is Solved, thx


RE: Vendor Supply - Van Glan Bloom - 06-13-2015 11:08 PM

Hi again,

Is there any function to which the items are not left in steaks? For example when I buy more than one pick, they do not see to the bag as two individual items whenever an item comes with the following settings "to 2 pickaxe"


Can you define the script, so will the number of items ordered but as individual items?


RE: Vendor Supply - Coruja - 06-15-2015 07:23 AM

there's a missing < on the first line
if (<src.findlayer(21).rescount i_gold> < (<EVAL(<ARGTXT[0]>) *100>)


RE: Vendor Supply - Van Glan Bloom - 06-15-2015 07:53 AM

Hi coruja,

I have fixed the problem, but thanks anyway =) But I wonder if it is possible buy some itens in vendor ( type pickaxes ) and the same itens come for bag separate and no in steacks?!


RE: Vendor Supply - JohnVeritas - 06-15-2015 09:38 AM

Try this one;

after every check is ok

serv.newitem i_bag
src.bounce <new>
ref1=<new.uid>
serv.newitem i_blabla
new.cont <ref1>


RE: Vendor Supply - XuN - 06-15-2015 04:28 PM

Pickaxes should not stack, if they are stacking you should have something wrong in your tiledata.mul.
As aditional fix you can set MaxAmount=1 in their ITEMDEF


RE: Vendor Supply - Van Glan Bloom - 06-15-2015 10:46 PM

In my vendor supply i have this

Code:
on=7
if (0<ISEMPTY <ARGTXT[0]>>)||(STRMATCH(*[a-z]*,<ARGTXT[0]>))||!(STRMATCH(*[0-9]*,<ARGTXT[0]>))
src.sysmessage @09c1 This is not a real value!!
return 1
elseif <src.findlayer(21).rescount i_gold> < (<ARGTXT[0]>) *100)
src.sysmessage @09c1 You do not have enought gold coins to trade.
else
serv.newitem i_pickaxe, <eval(<argtxt[0]>)>,<src.findlayer.21.uid>
src.consume i_gold (<argtxt[0]>) *100
src.sysmessage @09c1 You have buy <eval(<argtxt[0]>)> pickaxe's and pay <eval(<argtxt[0]>) *100)> gold's
return 1
endif

And i have add in the pickaxe the maxamount=1, but the pickaxes continue stacking =/


RE: Vendor Supply - darksun84 - 06-15-2015 11:48 PM

It's happening because the 2nd argument of serv.newitem is the amount value, so Sphere set the amount value of the pickaxe to: <eval(<argtxt[0]> (in the screenshot the amount value is 2). So you have to check if the item is actually a "stackable item".
but you already know that the pickaxe is not a stackable item, so you have to put each item in the backpack by bouncing it.

PHP Code:
on=7
if (0<ISEMPTY <ARGTXT[0]>>)||(STRMATCH(*[a-z]*,<ARGTXT[0]>))||!(STRMATCH(*[0-9]*,<ARGTXT[0]>))
src.sysmessage @09c1 This is not a real value!!
return 
1
elseif <src.findlayer(21).rescount i_gold> < (<ARGTXT[0]>) *100)
src.sysmessage @09c1 You do not have enought gold coins to trade.
else
FOR <eval(<
argtxt[0]>)>
serv.newitem i_pickaxe
new.bounce
ENDFOR
src.consume i_gold (<argtxt[0]>) *100
src
.sysmessage @09c1 You have buy <eval(<argtxt[0]>)> pickaxe's and pay <eval(<argtxt[0]>) *100)> gold's
return 1
endif