Full Version : Donation Statue
xmlspawner >>Q&A >>Donation Statue
<< Prev | Next >>
Hanse46- 03-22-2008
I wanted to spawn a Static (12278) and use the GETONNEARBY to take gold the player drops and give them a item, so I did the following:
Static,12278/GETONNEARBY,1,gold,true,amount=1000;spyglass
When I did this I have the message:
GETONNEARBY,1,gold,true,amount=1000;spyglass : Property not found.
What did I do wrong?
ArteGordon- 03-23-2008
The syntax for a spawn entry looks like this
object/property/value/property/value/...
so in your case, the GETONNEARBY keyword is in the position that would normally have the name of a property a keyword like ADD that can used in the same position. The error message is telling you that it doesnt recognize GETONNEARBY as a valid property name or keyword for that position.
The GETONNEARBY keyword returns a property value (in this case the amount property from nearby gold items) that can be used in conditional tests, or as a value to be assigned to a property. It is not going to actually take any gold. You would want to use the TAKE or TAKEBYTYPE keywords to do that. You could also use the GIVE keyword to actually give them the reward.
Here is an example from xmlspawner2.txt

QUOTE
- added the new "TAKEN" keyword, which can be used wherever an item keyword like ARMOR could be used. It will refer to the most recent item obtained via the TAKE or TAKEBYTYPE keyword. This allows you to take items and then test properties on them, manipulate them, give them back, or even spawn them.
For example, to take some gold and then test to see if you actually got the proper amount, you can do
1 TAKEBYTYPE,1,100,false/Gold
1 IF/GETONTAKEN,Amount < 100/33/44
2 GOTO/1
33 SAY/Sorry, you do not have enough gold
33 GIVE/TAKEN
44 SAY/Very good. Here is your armor
44 TAKEN/DELETE
44 GIVE/ARMOR,1,2

If you didnt want to actually take the gold first, you could use the AMOUNTCARRIED keyword to check first instead of taking it and then checking the amount with GETONTAKEN

QUOTE
- added the new "AMOUNTCARRIED,itemtype" keyword that will return the total amount of the specified type of item being carried in the backpack of the triggering mob. You can use this to test for carried items like IF/AMOUNTCARRIED,gold < 100/33
or add it to a Condition field in xmldialogs or in a triggering condition test on spawners
AMOUNTCARRIED,bandage>100

Also, you cannot separate spawn multiple spawn entries on a single line using the semicolon. That only works with XmlDialogs and other things that allow you to specify a spawnable action.
So the spyglass must be in a separate spawner entry from the static.
With a spawner, to spawn two separate things at once, put them into separate entries and then assign them to the same subgroup (that's what the little numbers in the left-hand column of the first example refer to).
This will cause them to be spawned together as a group.
To assign the subgroup number, open the expanded spawner gump with the little arrow button in the lower right corner of the main spawner gump.
Then for each entry, go to the 'Sub' column and enter in a number. The number must be the same for the things that you want to group together. The value will be used to order the subgroups if you use sequential spawning.
Once you have done that, the entries should change color to indicate their membership in the group.
Now, you might actually want to do this using the XmlUse attachment that will allow you to assign custom double-click functionality to items such as your static stone.
from xmlspawner2.txt

QUOTE
- added the new XmlUse attachment that allows you to control the use of any object. By adding this attachment to any object you can specify the conditions required to use the object as well as add new use functions to the object that will be executed on double clicks.
Properties:
Condition
A test string that is the same as any xmlspawner condition test. It will be tested whenever the object with the attachment is used (double clicked). If it returns true, then the object can be used. This can be used to control the built-in use functions of an object or the custom use functions that you add on the fly.
MaxUses
An integer value that restricts the maximum number of uses allowed. (default = unlimited)
Refractory
An integer that restricts the minimum time in seconds between uses. (default = 0)
MaxRange
An integer that restricts the maximum distance in tiles allowed from the target object (default = 3)
RequireLOS
A bool that determines whether line-of-sight between the user and the object is required (default = false)
SuccessAction
Assign this string to specify custom actions (in addition to the default OnUse functionality) that will be taken when the conditions for use of the object are met. The action string can be any spawnable entry string and supports multiple actions separated by semicolons.
FailureAction
This action will be executed when the conditions for use of the object are NOT met.
MaxUsesAction
This action will be executed when someone tries to use the object after the max uses has been exceeded.
RefractoryAction
This action will be executed when someone tries to use the object before the refractory period is over.
BlockDefaultUse
Setting this property to true will allow you to completely disable the default scripted RunUO method called when the object is used. This can be used to replace existing default use functions with your custom use actions.
Constructors:
public XmlUse()
public XmlUse(int maxuses)
public XmlUse(int maxuses, double refractory)
Examples:
For example, to make any object usable only once, just issue this command and target the object
[addatt xmluse 1
Note that you can always just remove the attachment and the object will go back to its default behavior. The attachment makes no changes to the object.
To spawn a metal box that can only be opened 3 times with a minimum delay of 10 seconds between openings and delivers a message if someone tries to use it more than the maximum number of times use a spawn entry like
metalbox/ATTACH/<xmluse,3,10/maxusesaction/@SENDMSG/Max uses exceeded.>
To spawn a stone static that pops open a gump when double clicked
static,3796/ATTACH/<xmluse/successaction/@GUMP,Wicked woods,0/Enter here and despair!>
you could also add this manually to any existing static by simply adding the attachment with
[addatt xmluse
and then opening up the props on the attachment with
[getatt
and assigning the SuccessAction property the value of "GUMP,Wicked woods,0/Enter here and despair!"
To spawn a door that can only be opened by players named "Bob"
metaldoor,1/ATTACH/<xmluse/condition/@GETONTRIGMOB,name="Bob">
or by players that havent yet completed an objective of a quest
metaldoor,1/ATTACH/<xmluse/condition/@GETONCARRIED,Bunglers quest,questholder,completed1=false>
To prevent a player from using any metal doors for 2 minutes, create a triggered spawner that will add an xmluse attachment to the player lasting 2 minutes with the following entry
SETONTRIGMOB/ATTACH/<xmluse/expiration/00:02/condition/@GETONTHIS,TYPE!#MetalDoor>
Note that GETONTRIGMOB will always refer to the player doing the using, and GETONTHIS will always refer to the object being used.
- added an example of the new XmlUse attachment in customuse.xml. Just do an "[xmlloadhere customuse.xml" and respawn it.
Examples:
1. Creates a metalbox that can only be opened by someone with positive karma, and after opening it sends a message, opens a gump, and changes the players karma to evil. If someone with negative karma tries to open it, they are refused and a gump pops up.
2. Creates a door that can only be opened by someone with enough strength (>70). If a player is too weak, they will be blocked and a gump will be displayed.
3. Spawns a horse that can only be mounted by someone with high enough chivalry (>90). If a player lacking the skill attempts to use it, they will be blocked and a message will be displayed.
4. Creates a brazier that will spawn a daemon when double clicked if the player has enough fame (>1000).
5. Spawns a stone that will deliver a bag of regs when double-clicked with a waiting time between uses of 10 seconds.
6. Creates a magic portal that teleports the user to a site in Ilshenar when double clicked.
Note that examples 4,5, and 6 are done using simple statics that have no default use scripted.

Hanse46- 04-10-2008
Took me a bit and alot of re reading and looking the example over and this is the information I needed, thank you
Hanse46- 04-10-2008
I have 1 question:
I used the box and tried this:
setonspawn,1/attachment,xmluse,,succesation/@bag/Add/myitem/ADD/myitem>
works well, but how do I get the bag to appear in the box, not next to it?
ArteGordon- 04-11-2008
the successaction that you now have is just
bag/Add/myitem/ADD/myitem
If you want an action that adds it to the container, try this
SETONTHIS/ADD/<bag/ADD/myitem/ADD/myitem>
so the whole spawn entry would look like
SETONSPAWN,1/ATTACHMENT,xmluse,,successaction/@SETONTHIS/ADD/<bag/ADD/myitem/ADD/myitem>
The SETONTHIS should refer to the object that the xmluse attachment is attached to. If that is the container, then that is what you want.
If you have the container near the object that is actually going to be double clicked, then use SETONNEARBY instead of SETONTHIS to refer to the nearby container, with something like
SETONSPAWN,1/ATTACHMENT,xmluse,,successaction/@SETONNEARBY,5,*,container/ADD/<bag/ADD/myitem/ADD/myitem>