Holiday Gifts (v1.00 - 14 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:

Holiday Gifts (v1.00 - 14 April 2005)

Post by Xuri »

// 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;
}
-= Ho Eyo He Hum =-
Rain
UOX3 Newbie
Posts: 4
Joined: Thu May 31, 2007 8:12 am
Has thanked: 0
Been thanked: 0

Post by Rain »

'addgifts brings up a targetting curor, but nothing happens when i target a player. Sometimes i hear a bank box being created, but it doesn't actually put anything in it.
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 »

Hm it's not supposed to bring up a targeting cursor at all, just automatically add whatever gifts you've specified to each player-character's bank box. Tried the command locally here with UOX3 0.98-3.7o (from CVS), and it seems to work; "Number of characters given GenericGifts: 9". Try upgrading from 0.98-3.7 to the latest available "experimental build" and see if it still doesn't work correctly.
-= Ho Eyo He Hum =-
Post Reply