jayates
Member
I've set my Kudos to be added to a players Bankbox every 30 mins through a reward deed. My problem is if a player is afk and allows more than 1 deed to be added to their bank the deeds stack though I have them set to be stackable = false. How can i fix this? Here's the script:
Code:
// ___|========================|___
// \ | Written by Felladrin | / [Kudos - Exchangeable Game Time Reward] - Current version: 1.3 (September 10, 2013)
// > | July 2013 | <
// /__|========================|__\ Description: An item given to players for each period of time they stay online.
using System;
using Server.Mobiles;
using Server.Network;
namespace Server.Custom.GameTimeReward
{
public class KudosTimer : Timer
{
public static class Config
{
public static int MinutesOnline = 30; // Every X minutes we give kudos to all players online.
public static bool DropOnBank = true; // Should we place the kudos on character's bankbox (true) or backpack (false)?
public static AccessLevel MaxAccessLevel = AccessLevel.Player; // Any character with this access and below receives kudos.
}
public static void Initialize()
{
new KudosTimer().Start();
}
public KudosTimer() : base(TimeSpan.Zero, TimeSpan.FromMinutes(Config.MinutesOnline))
{
Priority = TimerPriority.OneMinute;
}
protected override void OnTick()
{
foreach (NetState state in NetState.Instances)
{
Mobile m = state.Mobile;
if (m != null && m is PlayerMobile && m.AccessLevel <= Config.MaxAccessLevel)
{
if (Config.DropOnBank && m.BankBox != null)
{
Item kudosrewarddeed = m.BankBox.FindItemByType(typeof(KudosRewardDeed));
if (kudosrewarddeed != null)
{
kudosrewarddeed.Amount++;
}
else
{
//m.BankBox.DropItem(new Kudos( Utility.Random( 20, 40 )));
m.BankBox.DropItem(new KudosRewardDeed());
}
}
else if (m.Backpack != null)
{
Item kudosrewarddeed = m.Backpack.FindItemByType(typeof(KudosRewardDeed));
if (kudosrewarddeed != null)
{
kudosrewarddeed.Amount++;
}
else
{
//m.Backpack.DropItem(new Kudos( Utility.Random( 20, 40 )));
m.BankBox.DropItem(new KudosRewardDeed());
}
}
}
}
}
}
public class KudosRewardDeed : Item
{
[Constructable]
public KudosRewardDeed() : this( null )
{
}
[Constructable]
public KudosRewardDeed(string name) : base(5360)
{
Name = "A Kudos Reward Deed for a random amount of Kudos";
Hue = 1150;
Stackable = false;
}
public KudosRewardDeed ( Serial serial ) : base ( serial )
{
}
public override void OnDoubleClick( Mobile from )
{
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage(1042001);
}
else
{
switch ( Utility.Random( 1 ) )
{
case 0: from.AddToBackpack( new Kudos ( Utility.Random( 18, 25 ))); break;
}
this.Delete();
}
}
public override void Serialize ( GenericWriter writer)
{
base.Serialize ( writer );
writer.Write ( (int) 0);
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize ( reader );
int version = reader.ReadInt();
}
}
Last edited by a moderator: