SphereCommunity
Problem with Player Vendor System - Printable Version

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



Problem with Player Vendor System - nobody2k - 02-27-2015 06:53 PM

Hi all!

I just started to script an own Player-vendor system, nothing special, just an easy to use system for max 10 items.

Actually, it's based on an NPC "c_vendor" which I created, the Gump appears when I DClick on the NPC.
I want to place the items inside the "vendor container" (the thing that opens up when you say "stock", it's layer 26) and store the Serial of every item in an own tag (TAG is stored at the NPC, so it's "tag.item1", "tag.item2", "tag.item3",... )

Now, when the GUMP shows up I want to display all the items (their name, amount an price).
I tried that using <SERV.ITEMDEF.<TAG.item1>.NAME> ... but it only shows "0"^^
Using EVAL, gives the the same name "0", which is actually NOT the name of a mark scroll (in my example)...

Could someone please help me, I just ran out of ideas Smile

thx in advance!

greeting, Chris


RE: Problem with Player Vendor System - darksun84 - 02-27-2015 07:51 PM

Probably is caused by this:

When you dclick(@charDclick) the vendor, the gump is sent to the player and the only reference inside the gump is the player and not the vendor.
So it's actually looking in the player tags instead of looking in the vendor tags.
The solution is to pass a reference (the vendor uid) along with the gump.

Wrong Example
PHP Code:
ON=@CharDclick
dialog d_test_gump
,0,<act>   //act holds  the vendor uid,    0 is the gump page 

[DIALOG d_test_gump]
0,0
REF1
=<args>  // args holds the uid of the vendor, it will be saved inside REF1, REFx  can holds uid of  items and chars
page 0
resizepic 0 0 2620 150 100
page 1
dtext 10 50 1152 Hello 
<ref1.name//Here we show the name of the Npc dclicked
button 30 70 2473 2472 1 0 1000

[DIALOG d_test_gump BUTTON]
ON=1000
 
      SYSMESSAGE  Bye 
<ref1.name>
     
// Problem ! When the button is clicked Bye 0 will be displayed, that's because we have lost the reference to the vendor.
     //REFx "exists" only inside the block of code  in which we have declared it.
     //We can't use ref1=<args> inside the button block, because the vendor uid is actually sent only "graphic" part of the gump. 

A simple right example is to store the vendor uid inside a player tag

PHP Code:
ON=@CharDclick
tag
.vendorUID = <act>
dialog d_test_gump   //We don't have to send the uid of the vendor anymore
                             //Because we can directly access it from the player.

[DIALOG d_test_gump]
0,0
REF1
=<tag0.vendorUID>  //We save the tag in REF1, we use tag0 for precaution
page 0
resizepic 0 0 2620 150 100
page 1
dtext 10 50 1152 Hello 
<ref1.name//Here we show the name of the Npc dclicked
button 30 70 2473 2472 1 0 1000

[DIALOG d_test_gump BUTTON]
ON=1000
      REF1
= <tag0.vendorUID>
      
SYSMESSAGE  Bye <ref1.name

Anyway, this solution will create other problem that you will discover sisi


RE: Problem with Player Vendor System - nobody2k - 03-05-2015 10:42 PM

Hi!

Thank you for your answer!
I worked around my problems and solved it by using the backpack of the Vendor NPC. Smile

I had to gump a whole new "buy script" then, but it is completed and working. Smile