|
||
|
|||||||
| Script Support Get support for modifying RunUO Scripts, or writing your own! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Account Terminated
Join Date: Jul 2008
Age: 20
Posts: 26
|
I want to check if the player has some items and enough gold to become a vampire (after double-clicking the vampire class stone) i have looked everywhere, searched the RunUO docs folder, searched in BaseVendor.cs script browsed on the forums and still i cannot find a way to check if a player has some items in his backpack, so if anyone would help it would be greatly appreciated!
|
|
|
|
|
|
#3 (permalink) |
|
Forum Master
|
can also use the consume method
this shows a bank box method, but can be converted to back pack BankBox box = from.BankBox; if ( (box == null || !box.ConsumeTotal(typeof(Gold), 100)) ) from.SendMessage("you need 100 gold in your bank to use this"); else - do what you want and if you look in on the clockwork assembly for golem making, it shows how to do it for multiple items
__________________
http://www.AoAUO.com
:) ..... Come for the Customs, Play for the Fun. Return to see your new Friends ..... :) |
|
|
|
|
|
#4 (permalink) |
|
Account Terminated
Join Date: Jul 2008
Age: 20
Posts: 26
|
Hmmm... I'm a noob, how do i use it? Just store it as a variable, and when i want to delete it, delete the variable?? I mean something like:
Code:
HeadOfPaladin item = ( from.Backpack == null ? null : m.Backpack.FindItemByType( typeof( PaladinsHead ) ) as HeadOfPaladin );
if (HeadOfPaladin!=0)
{
//Delete the items?
m.Criminal=true;
m.IsVampire=true;
m.ExpireCriminalTimer=TimeSpan.FromMonths( 500.0 );
m.SendLocalizedMessage( 1063491, "", 0x22 ); //You are now a vampire
}
Code:
CS0122: Line 60: 'Server.Mobile.ExpireCriminalTimer' is inaccessible due to its protection level Last edited by madmadmax; 07-09-2008 at 02:17 PM. |
|
|
|
|
|
#5 (permalink) |
|
Newbie
Join Date: May 2006
Location: Czech Republic
Posts: 78
|
1) Class Item has got public method Delete(). For example:
Code:
Item helm = new Helm(); helm.Delete(); Code:
m.ExpireCriminalDelay = TimeSpan.FromMinutes( 200.0 ); //changing default criminal status delay m.CriminalAction(false); //set true if you want to send localized message: "You've committed a criminal act!!" Last edited by Sixkillers; 07-09-2008 at 03:48 PM. |
|
|
|
|
|
#6 (permalink) | |
|
Account Terminated
Join Date: Jul 2008
Age: 20
Posts: 26
|
Quote:
Code:
CS0176: Line 60: Static member 'Server.Mobile.ExpireCriminalDelay.get' canno t be accessed with an instance reference; qualify it with a type name instead |
|
|
|
|
|
|
#7 (permalink) |
|
Newbie
Join Date: May 2006
Location: Czech Republic
Posts: 78
|
Sorry my fault it is static member. Here is the fix:
Code:
Server.Mobile.ExpireCriminalDelay = TimeSpan.FromMinutes( 200.0 ); So you can change your code: Code:
TimeSpan oldValue = Server.Mobile.ExpireCriminalDelay; Server.Mobile.ExpireCriminalDelay = TimeSpan.FromMinutes( 200.0 ); m.CriminalAction(false); Server.Mobile.ExpireCriminalDelay = oldValue; |
|
|
|
|
|
#8 (permalink) | |
|
Account Terminated
Join Date: Jul 2008
Age: 20
Posts: 26
|
Quote:
Server Crash Report =================== RunUO Version 2.0, Build 2959.20979 Operating System: Microsoft Windows NT 6.0.6001 Service Pack 1 .NET Framework: 2.0.50727.1434 Time: 7/9/2008 11:23:40 PM Mobiles: 7803 Items: 116681 Exception: System.NullReferenceException: Object reference not set to an instance of an object. at Server.Items.VampireClassStone.JoinClass(Mobile m) at Server.Items.VampireClassStone.OnDoubleClick(Mobil e from) at Server.Mobile.Use(Item item) at Server.Network.PacketHandlers.UseReq(NetState state, PacketReader pvSrc) at Server.Network.MessagePump.HandleReceive(NetState ns) at Server.Network.MessagePump.Slice() at Server.Core.Main(String[] args) Clients: - Count: 2 + 127.0.0.1: (account = VampireTest) (mobile = 0x6CC 'VampireTest') + 127.0.0.1: (account = Pepolshet) (mobile = 0x22 'Admin Pepolshet') |
|
|
|
|
|
|
#9 (permalink) |
|
Newbie
|
Add a function to PlayerMobile that accepts a Timespan in and sets the player's criminal status from within the PlayerMobile script. This will avoid the "protected" problem.
__________________
Chances are I'm bored, so I'll probably help you. If I'm really bored I might do a few scripts on request, but contact me by messenger if you want that. |
|
|
|
|
|
#11 (permalink) |
|
Account Terminated
Join Date: Jul 2008
Age: 20
Posts: 26
|
Code:
public bool JoinClass( Mobile m )
{
PlayerMobile from = m as PlayerMobile;
PlayerMobile combatant = from.Combatant as PlayerMobile;
if ( combatant.IsVampire )
{
m.SendLocalizedMessage( 1063490, "", 0x22 ); // You already joined the vampire class
return false;
}
else if ( combatant.IsPaladin )
{
m.SendLocalizedMessage( 1063492, "", 0x22 ); // You already joined the paladin class and cannot become a vampire!
return false;
}
else if ( m.Spell != null )
{
m.SendLocalizedMessage( 1049616 ); // You are too busy to do that at the moment.
return false;
}
else if (m.Backpack.ConsumeTotal(typeof(PaladinsHead), 1, true) && m.Backpack.ConsumeTotal(typeof(BoneOfVampire), 1, true) && m.Backpack.ConsumeTotal(typeof(Gold), 150000, true) )
{
combatant.Criminal=true;
combatant.IsVampire=true;
combatant.Kills += 20;
m.Title = "The Vampire";
m.Hue = 0;
m.CriminalAction(true); //set true if you want to send localized message: "You've committed a criminal act!!"
m.SendLocalizedMessage( 1063491, "", 0x22 ); //You are now a vampire
return true;
}
else
{
m.CloseGump( typeof( VampireClassGump ) );
m.SendGump( new VampireClassGump() ); //This is just a gump that shows what you need to join the vampire class
m.SendLocalizedMessage( 500191, "", 0x22 ); //Not enough cash :P
return false;
}
}
|
|
|
|
|
|
#17 (permalink) | |
|
Account Terminated
Join Date: Jul 2008
Age: 20
Posts: 26
|
Quote:
EDIT: If i use "m" i get errors on IsVampire variables because they were created in PlayerMobile. Last edited by madmadmax; 07-10-2008 at 11:34 AM. |
|
|
|
|
|
|
#18 (permalink) |
|
Newbie
Join Date: May 2006
Location: Czech Republic
Posts: 78
|
Sorry my fault again
You have to use:Code:
PlayerMobile from = m as PlayerMobile; Last edited by Sixkillers; 07-10-2008 at 11:54 AM. |
|
|
|
|
|
#19 (permalink) | |
|
Account Terminated
Join Date: Jul 2008
Age: 20
Posts: 26
|
Quote:
EDIT: YEY! It works perfectly! I just got 2 little tiny questions left: A). What part do i need to change in Gold.cs to make the gold pile able to get an amount higher then 64k? (so players will have say 300k in one gold pile) B). How can i make a weapon that when a player which isn't a vampire equipt it, it will fall back to the backpack? Last edited by madmadmax; 07-10-2008 at 11:59 AM. |
|
|
|
|
|
|
#20 (permalink) |
|
Newbie
Join Date: May 2006
Location: Czech Republic
Posts: 78
|
1) I think you cant change it, because for amount are reserved 2 bytes (ushort) in packet.
2) You will have to override method CanEquip in your weapon script. For example: Code:
public override bool CanEquip( Mobile from )
{
if (m.Player && !((PlayerMobile)m).IsVampire)
{
from.SendMessage("You are not vampire!!");
return false;
}
return base.CanEquip(from);
}
|
|
|
|
|
|
#21 (permalink) | |
|
Account Terminated
Join Date: Jul 2008
Age: 20
Posts: 26
|
Quote:
) it will slow down the server a lot? |
|
|
|
|
|
|
#22 (permalink) |
|
Forum Master
|
i believe it would take a core mode to change it for that, and it will effect all items that stack
__________________
http://www.AoAUO.com
:) ..... Come for the Customs, Play for the Fun. Return to see your new Friends ..... :) |
|
|
|
|
|
#24 (permalink) |
|
Newbie
Join Date: May 2006
Location: Czech Republic
Posts: 78
|
Yes, you can edit core (edit & compile) as you wish, but client you cant change (or very hardly). Client is using two bytes variable for amount. So when you send him longer variable he probably crashes.
Last edited by Sixkillers; 07-11-2008 at 05:52 AM. |
|
|
|
|
|
#25 (permalink) | |
|
Account Terminated
Join Date: Jul 2008
Age: 20
Posts: 26
|
Quote:
I made 3 custom flags in PlayerMobile.cs (IsVampire, IsPaladin and ProPack) Code:
namespace Server.Mobiles
{
#region Enums
[Flags]
public enum PlayerFlag // First 16 bits are reserved for default-distro use, start custom flags at 0x00010000
{
None = 0x00000000,
Glassblowing = 0x00000001,
Masonry = 0x00000002,
SandMining = 0x00000004,
StoneMining = 0x00000008,
ToggleMiningStone = 0x00000010,
KarmaLocked = 0x00000020,
AutoRenewInsurance = 0x00000040,
UseOwnFilter = 0x00000080,
PublicMyRunUO = 0x00000100,
PagingSquelched = 0x00000200,
Young = 0x00000400,
AcceptGuildInvites = 0x00000800,
DisplayChampionTitle = 0x00001000,
ProPack = 0x00010200,
IsVampire = 0x00010400,
IsPaladin = 0x00010600
}
Code:
[CommandProperty( AccessLevel.GameMaster )]
public bool IsPaladin
{
get{ return GetFlag( PlayerFlag.IsPaladin ); }
set{ SetFlag( PlayerFlag.IsPaladin, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool IsVampire
{
get{ return GetFlag( PlayerFlag.IsVampire ); }
set{ SetFlag( PlayerFlag.IsVampire, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool ProPack
{
get{ return GetFlag( PlayerFlag.ProPack ); }
set{ SetFlag( PlayerFlag.ProPack, value ); }
}
Code:
if ( IsVampire && Karma>0 )
{
Criminal=true;
Karma=-1000;
}
if ( IsVampire && IsPaladin )
{
IsVampire=false;
IsPaladin=false;
}
|
|
|
|
|