Newbie Bank-Items (v1.00 - 15 April 2005)

Got any custom JavaScript additions/tweaks you think other people would like to see? Post 'em here!
Post Reply
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Newbie Bank-Items (v1.00 - 15 April 2005)

Post by Xuri »

// Newbie Bank-Items
// by Xuri (xuri@sensewave.com)
// v1.01
// Last Update: 17. April 2005

// This script allows you to add specific items to all newbie players' bankboxes upon char-creation.
// By default, the script adds 2000 gold - but you can tweak that and add more items
// by copying & pasting the two last lines (excluding the brackets) and editing the
// hex-id & amount.

// To use this script, save it in your UOX3\JS\CUSTOM folder as (for instance) newbieBankItems.js,
// then open JSE_FILEASSOCIATIONS.SCP and add a new line saying 0=custom/newbieBankItems.js just
// below [SCRIPT LIST] and the first bracket. Alternatively, merge the script into any existing
// script you have listed with scriptID 0.

function onCreateDFN( objMade, objType )
{
   if( objType == 1 && !objMade.npc ) // Make sure it's a new player
   {
      var pUser = objMade;

      var bankBox = pUser.FindItemLayer( 29 );
      if( bankBox == null || !bankBox.isItem )
      {
         // Create a new bankbox for the player
         var newBankBox = CreateDFNItem( pUser.socket, pUser, "0x09ab", 1, "ITEM", false );
         newBankBox.name = pUser.name + "'s bank box";    
         newBankBox.layer = 29;
         newBankBox.owner = pUser;
         newBankBox.container = pUser;
         newBankBox.type = 1;
         newBankBox.morex = 1;
         bankBox = newBankBox;
      }

      if( bankBox && bankBox.isItem )
      {
         var newBankItem = CreateDFNItem( pUser.socket, pUser, "0x0eed", 2000, "ITEM", false ); //Add 2000 gold
         newBankItem.container = bankBox; //Move the gold to player's bankbox
      }
   }
}
Last edited by Xuri on Sun Apr 17, 2005 12:29 am, edited 1 time in total.
-= Ho Eyo He Hum =-
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Some revisions for you, Xu

This code will ensure it's a new player not an NPC, and not re-create the bankbox if they (in some odd scenario) already had a bankbox.

Code: Select all

function onCreateDFN( objMade, objType )
{
	if( objType == 1 && !objMade.npc ) // Make sure it's a new player
	{
		var pUser = objMade;

		var bankBox = pUser.FindItemLayer( 29 );
		if( bankBox == null || !bankBox.isItem )
		{
			// Create a new bankbox for the player
			var newBankBox = CreateDFNItem( pUser.socket, pUser, "0x09ab", 1, "ITEM", false );
			newBankBox.name = pUser.name + "'s bank box";   
			newBankBox.layer = 29;
			newBankBox.owner = pUser;
			newBankBox.container = pUser;
			newBankBox.type = 1;
			newBankBox.morex = 1;
			bankBox = newBankBox;
		}

		if( bankBox && bankBox.isItem )
		{
			var newBankItem = CreateDFNItem( pUser.socket, pUser, "0x0eed", 2000, "ITEM", false ); //Add 2000 gold
			newBankItem.container = bankBox; //Move the gold to player's bankbox
		}
	}
}
Scott
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Thanks, giwo :)
Script updated.
-= Ho Eyo He Hum =-
Hitman
UOX3 Newbie
Posts: 3
Joined: Sun Feb 05, 2006 3:15 am
Has thanked: 0
Been thanked: 0

Post by Hitman »

I put the js file in my custom directory and added the line to the jsassoc file but when I make a new character, there is still nothing in his bank box, do I need to do something else?


Thanks

Hitman
JDigital
UOX3 Newbie
Posts: 18
Joined: Sun Aug 31, 2008 6:50 am
Has thanked: 0
Been thanked: 0

Post by JDigital »

what does this do?
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

It's basically a script for automatically creating certain items in the bankbox of all new characters that are made on your server.
/ This script allows you to add specific items to all newbie players' bankboxes upon char-creation.
// By default, the script adds 2000 gold - but you can tweak that and add more items
// by copying & pasting the two last lines
(excluding the brackets) and editing the
// hex-id & amount.
i.e. these lines:
(I removed the comments from behind the following lines to make them easier to read, btw)

Code: Select all

         var newBankItem = CreateDFNItem( pUser.socket, pUser, "0x0eed", 2000, "ITEM", false );
         newBankItem.container = bankBox;
For each new item you want to add to all newbie characters' bankboxes, you need another set of those two lines, with a new variable-name for each one, with the hex-id of the item you'd like to add, as well as the number to add, like so:

Code: Select all

         var newBankItem = CreateDFNItem( pUser.socket, pUser, "0x0eed", 2000, "ITEM", false );
         newBankItem.container = bankBox;
         var newBankItem2 = CreateDFNItem( pUser.socket, pUser, "0x04a9", 1, "ITEM", false );
         newBankItem2.container = bankBox;
-= Ho Eyo He Hum =-
Post Reply