Lets say I make a gump menu with with options:
brownhorse ON [OFF]
When I'd click ON, it'd do something like this:
http://www.uox3.org/jsdocs/characterm.html#SpawnNPC
My question is, when I click OFF (maybe days later), how do I get rid of that particular brownhorse assuming other unrelated brownhorses exist?
I was thinking something like storing the serial when the horse is spawned and deleting it by the serial?
Thanks!
Remove NPC/Item without targetting?
-
Mindless Automaton
- UOX3 Apprentice
- Posts: 189
- Joined: Wed May 10, 2006 3:48 am
- Has thanked: 0
- Been thanked: 1 time
- Contact:
Remove NPC/Item without targetting?
Mindless Automaton
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)
- Xuri
- Site Admin
- Posts: 3704
- Joined: Mon Jun 02, 2003 9:11 am
- Location: Norway
- Has thanked: 48 times
- Been thanked: 8 times
- Contact:
That's the way. You can save a character's serial using for instance:
then retrieve it later using
and then optionally delete it by using
myObject can be a character or an item (you need to save the tag somewhere).
Code: Select all
myObject.SetTag( "BrownHorseSerial", ( myBrownHorse.serial & 0x00FFFFFF ) );Code: Select all
var myBrownHorse = CalcCharFromSer( myObject.GetTag( "BrownHorseSerial" ) );Code: Select all
myBrownHorse.Delete();-= Ho Eyo He Hum =-
-
Mindless Automaton
- UOX3 Apprentice
- Posts: 189
- Joined: Wed May 10, 2006 3:48 am
- Has thanked: 0
- Been thanked: 1 time
- Contact:
So far then:
Is there a property index for gumps? I am not sure what the property is for a pressed button. Is it something like OtherButton.pressed or .value?
Ultimately I'd like to have a few quests set up and be able to enable/disable them with the gump.
Thanks
Code: Select all
// Quest Command
// Script no: 3014
function CommandRegistration()
{
RegisterCommand( "quest", 2, true ); //Talk to a targeted character or item
}
function command_QUEST( pSock, execString )
{
var pUser = pSock.currentChar;
var myGump = new Gump; // create a new gump
myGump.AddBackground( 0, 0, 300, 300, 2600 ); // add an automic scaled background
myGump.AddButton( 300, 5, 0xa50, 1, 0, 0); // Add a close-gump button
myGump.AddPicture( 20, 40, 0x12D8 ); // add tile art
myGump.AddText( 85, 135, 5, "Activate!" ); // add text, gets assigned TextID 0
myGump.AddText( 85, 165, 7, "Deactivate!" ); // add text, gets assigned TextID 1
myGump.AddRadio( 50, 130, 2152, 0, 0 ); //RadioButton with ID 0
myGump.AddRadio( 50, 160, 2152, 0, 1 ); //RadioButton with ID 1
myGump.AddButton( 160, 265, 0xF7, 1, 0, 1 ); // add the "okay" button
myGump.Send( pUser.socket ); // send this gump to client now
myGump.Free(); // clear this gump from uox-memory
return false;
}
function onGumpPress( pSock, pButton, gumpData )
{
var pUser = pSock.currentChar;
switch(pButton)
{
case 0:
// abort and do nothing
break;
case 1:
var OtherButton = gumpData.getButton(0);
switch(OtherButton)
{
case 0:
nSpawned = SpawnNPC( "brownhorse", pUser.x, pUser.y, pUser.z, pUser.worldnumber ); //add this npc
if( nSpawned != null )
nSpawned.SetTag( "nSpawnedSerial", ( nSpawned.serial & 0x00FFFFFF ) ); //get the serial number for the npc
pUser.SysMessage( "Wheee - a brown horse just spawned at my location!" ); //confirm
break;
case 1:
var nSpawnedObj = CalcCharFromSer( nSpawned.GetTag( "nSpawnedSerial" ) ); //figure out the serial number
nSpawnedObj.Delete(); // delete the npc
pUser.SysMessage( "Wheee - a brown horse is deleted!" ); //confirm
break;
}
break;
}
}
Ultimately I'd like to have a few quests set up and be able to enable/disable them with the gump.
Thanks
Mindless Automaton
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)
-
Grimson
- Developer
- Posts: 802
- Joined: Sat Jun 04, 2005 1:52 am
- Location: Germany
- Has thanked: 0
- Been thanked: 0
Code: Select all
nSpawned.SetTag( "nSpawnedSerial", ( nSpawned.serial & 0x00FFFFFF ) ); Code: Select all
case 1:
var nSpawnedObj = CalcCharFromSer( nSpawned.GetTag( "nSpawnedSerial" ) ); //figure out the serial number
nSpawnedObj.Delete(); // delete the npc
pUser.SysMessage( "Wheee - a brown horse is deleted!"
You should also make shure you have a valid object before trying to perform any operations on them, like Delete().
-
Mindless Automaton
- UOX3 Apprentice
- Posts: 189
- Joined: Wed May 10, 2006 3:48 am
- Has thanked: 0
- Been thanked: 1 time
- Contact:
Ok, what about if you have GM#1 online & he creates the horse and then leaves. Later, GM#2 comes online and uses the menu to destroy the horse. I was assuming it wouldn't happen if the serial was stored on GM#1 since he left the game. Of course I'm assuming GM#2 could come on and nuke the horse as I haven't tested it that far yet.Grimson wrote: Storing the serial of the horse on the horse doesn't make any sense.
Again, store and read the serial from the char that used the gump.
Thanks!
Mindless Automaton
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)