// Holiday Gifts by Xuri (xuri@sensewave.com)
// v1.00
// Last Updated: 14. April 2005
// A script used to add holiday-gifts to players bankboxes
// Just change the hex-ids in the GiftArray, and the number of each item to be added
// in GiftAmountArray (should reflects GiftArray). Changing the GiftNameCheck variable each
// time you want to give different gifts will ensure that all players get their designated gifts only once
// The script will add gifts to the bankboxes of every single player character, it will not discriminate between
// offline or online characters, or between characters on the same account.
function CommandRegistration()
{
RegisterCommand( "addgifts", 5, true ); //Lets Admins only execute this command. Set to false to disable command.
}
// GiftArray holds an array of which items you want to give as gifts
// GiftAmountArray holds an array of the number of items (from GiftArray) you want to add.
// GiftName is only used to tell whoever uses the ADDGIFTS command what type of gift has been given.
var GiftArray = new Array( "0x0eed", "0x099f", "0x09d0" );
var GiftAmountArray = new Array( 2000, 1, 1 );
var GiftNameCheck = "GenericGifts";
function command_ADDGIFTS( pSock, execString )
{
var pUser = pSock.currentChar;
var numCharacters = IterateOver( "CHARACTER" );
pUser.SysMessage( "Number of characters given "+GiftNameCheck+": "+numCharacters );
}
function onIterate( charCheck )
{
if( !charCheck )
return false;
if( charCheck.npc )
return false;
var pUser = charCheck;
// We check the current character to see if he has the tag marking him
// as having already gotten his gifts, and drop out if he has.
var GiftCheck = pUser.GetTag( GiftNameCheck );
if( GiftCheck != null && GiftCheck != 0 )
return false;
// Create a bankbox for the player if they don't have one already.
// Bankboxes will only exist for players who have already made use of the bank once.
var bankBox = pUser.FindItemLayer( 29 );
if( !bankBox )
{
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;
var bankBox = pUser.FindItemLayer( 29 );
}
// If the bankbox exists, add the gift items to it!
if( bankBox && bankBox.isItem )
{
// This for-loop adds the gifts specified in the GiftArray near the top of this script, one by one until
// it reaches the end of the array.
for(var i = 0; i < GiftArray.length; i++)
{
var newGiftItem = CreateDFNItem( pUser.socket, pUser, GiftArray[i], GiftAmountArray[i], "ITEM", false );
newGiftItem.container = bankBox;
}
// Add a tag to this user saying he has received his gifts.
pUser.SetTag( GiftNameCheck, 1 );
}
return true;
}
// v1.00
// Last Updated: 14. April 2005
// A script used to add holiday-gifts to players bankboxes
// Just change the hex-ids in the GiftArray, and the number of each item to be added
// in GiftAmountArray (should reflects GiftArray). Changing the GiftNameCheck variable each
// time you want to give different gifts will ensure that all players get their designated gifts only once
// The script will add gifts to the bankboxes of every single player character, it will not discriminate between
// offline or online characters, or between characters on the same account.
function CommandRegistration()
{
RegisterCommand( "addgifts", 5, true ); //Lets Admins only execute this command. Set to false to disable command.
}
// GiftArray holds an array of which items you want to give as gifts
// GiftAmountArray holds an array of the number of items (from GiftArray) you want to add.
// GiftName is only used to tell whoever uses the ADDGIFTS command what type of gift has been given.
var GiftArray = new Array( "0x0eed", "0x099f", "0x09d0" );
var GiftAmountArray = new Array( 2000, 1, 1 );
var GiftNameCheck = "GenericGifts";
function command_ADDGIFTS( pSock, execString )
{
var pUser = pSock.currentChar;
var numCharacters = IterateOver( "CHARACTER" );
pUser.SysMessage( "Number of characters given "+GiftNameCheck+": "+numCharacters );
}
function onIterate( charCheck )
{
if( !charCheck )
return false;
if( charCheck.npc )
return false;
var pUser = charCheck;
// We check the current character to see if he has the tag marking him
// as having already gotten his gifts, and drop out if he has.
var GiftCheck = pUser.GetTag( GiftNameCheck );
if( GiftCheck != null && GiftCheck != 0 )
return false;
// Create a bankbox for the player if they don't have one already.
// Bankboxes will only exist for players who have already made use of the bank once.
var bankBox = pUser.FindItemLayer( 29 );
if( !bankBox )
{
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;
var bankBox = pUser.FindItemLayer( 29 );
}
// If the bankbox exists, add the gift items to it!
if( bankBox && bankBox.isItem )
{
// This for-loop adds the gifts specified in the GiftArray near the top of this script, one by one until
// it reaches the end of the array.
for(var i = 0; i < GiftArray.length; i++)
{
var newGiftItem = CreateDFNItem( pUser.socket, pUser, GiftArray[i], GiftAmountArray[i], "ITEM", false );
newGiftItem.container = bankBox;
}
// Add a tag to this user saying he has received his gifts.
pUser.SetTag( GiftNameCheck, 1 );
}
return true;
}