RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Weapon with owner.. Nobody else can use.

darksky

Sorceror
Weapon with owner.. Nobody else can use.

Hello guys... Im working on a race system (very simply) and each race will start with an item. Like:

Elf - Elfic Bow
Human - Sword of Justice
Dwarf - Shield of Immortality
etc...

I wont the players giving, selling or trading these items, even using with another character. So, I would have something that disallow other player use the item, making it disapear or just sending a msg. I have tried somethings without success.

Thanks!
 

daat99

Moderator
Staff member
darksky said:
Hello guys... Im working on a race system (very simply) and each race will start with an item. Like:

Elf - Elfic Bow
Human - Sword of Justice
Dwarf - Shield of Immortality
etc...

I wont the players giving, selling or trading these items, even using with another character. So, I would have something that disallow other player use the item, making it disapear or just sending a msg. I have tried somethings without success.

Thanks!
If you realy want some real help then do as follows:
1. Post full script in
Code:
 tags.
2. Post errors that you got.
3. Show us that you're making an effort (simply stating that you tried something doesn't show anything).
 

darksky

Sorceror
daat99 said:
If you realy want some real help then do as follows:
1. Post full script in
Code:
 tags.
2. Post errors that you got.
3. Show us that you're making an effort (simply stating that you tried something doesn't show anything).[/QUOTE]

Im sorry, my computer isnt working, so Im using a secondary computer, anyways, here is one of the scripts:

[CODE]
using System;
using Server.Network;
using Server.Items;

namespace Server.Items
{
	[FlipableAttribute( 0x13B2, 0x13B1 )]
	public class ElficBow : BaseRanged
	{
		public override int EffectID{ get{ return 0xF42; } }
		public override Type AmmoType{ get{ return typeof( Arrow ); } }
		public override Item Ammo{ get{ return new Arrow(); } }

		public override WeaponAbility PrimaryAbility{ get{ return WeaponAbility.ParalyzingBlow; } }
		public override WeaponAbility SecondaryAbility{ get{ return WeaponAbility.MortalStrike; } }

		public override int AosStrengthReq{ get{ return 30; } }
		public override int AosMinDamage{ get{ return 16; } }
		public override int AosMaxDamage{ get{ return 18; } }
		public override int AosSpeed{ get{ return 25; } }

		public override int OldStrengthReq{ get{ return 20; } }
		public override int OldMinDamage{ get{ return 9; } }
		public override int OldMaxDamage{ get{ return 41; } }
		public override int OldSpeed{ get{ return 20; } }

		public override int DefMaxRange{ get{ return 10; } }

		public override int InitMinHits{ get{ return 255; } }
		public override int InitMaxHits{ get{ return 255; } }


		public override WeaponAnimation DefAnimation{ get{ return WeaponAnimation.ShootBow; } }

		[Constructable]
		public ElficBow() : base( 0x13B2 )
		{
			LootType = Blessed;
			Name = "Elfic Bow";
			Hue = 1109;
			Attributes.SpellChanneling = 1;
			Attributes.WeaponSpeed = 20;
			Weight = 6.0;
			Layer = Layer.TwoHanded;
		}
		public override void GetDamageTypes( Mobile wielder, out int phys, out int fire, out int cold, out int pois, out int nrgy )
		{
			phys = fire = cold = pois = 0;
			nrgy = 100;
		}


		public ElficBow( Serial serial ) : base( serial )
		{
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 0 ); // version
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			if ( Weight == 7.0 )
				Weight = 6.0;
		}
	}
}

Code:
I was thinking about something like onequip:

public Mobile Owner
		{
			get{ return m_Owner; }
			set{ m_Owner = value; }
		}

public override void OnEquip( Mobile from )
		{
			if ( from != m_Owner )
			{
				from.SendLocalizedMessage( "This Weapon isnt your!" );
			}
			else
			{
				
			}

But I dont know how to write it...
 

Joeku

Lord
For one, you can't send a localized message and have it return custom text. It would just be SendMessage. Second, you would put under else
return true;
(I think).
Post your errors here and we will see what we can do.
 

Kireko

Wanderer
Dunno I just was messing around plugged it in and got this error on a test start....

RunUO - [www.runuo.com] Version 1.0.0, Build 36918
Scripts: Compiling C# scripts...failed (1 errors, 0 warnings)
- Error: Scripts\Customs\Class Sword.cs: CS0508: (line 63, column 22) 'Server.I
tems.ElficBow.OnEquip(Server.Mobile)': cannot change return type when overriding
inherited member 'Server.Items.BaseWeapon.OnEquip(Server.Mobile)'
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

Like I said all I did was plug it in....

script is:

Code:
using System;
using Server.Network;
using Server.Items;

namespace Server.Items
{
	[FlipableAttribute( 0x13B2, 0x13B1 )]
	public class ElficBow : BaseRanged
	{
		public override int EffectID{ get{ return 0xF42; } }
		public override Type AmmoType{ get{ return typeof( Arrow ); } }
		public override Item Ammo{ get{ return new Arrow(); } }

		public override WeaponAbility PrimaryAbility{ get{ return WeaponAbility.ParalyzingBlow; } }
		public override WeaponAbility SecondaryAbility{ get{ return WeaponAbility.MortalStrike; } }

		public override int AosStrengthReq{ get{ return 30; } }
		public override int AosMinDamage{ get{ return 16; } }
		public override int AosMaxDamage{ get{ return 18; } }
		public override int AosSpeed{ get{ return 25; } }

		public override int OldStrengthReq{ get{ return 20; } }
		public override int OldMinDamage{ get{ return 9; } }
		public override int OldMaxDamage{ get{ return 41; } }
		public override int OldSpeed{ get{ return 20; } }

		public override int DefMaxRange{ get{ return 10; } }

		public override int InitMinHits{ get{ return 255; } }
		public override int InitMaxHits{ get{ return 255; } }


		public override WeaponAnimation DefAnimation{ get{ return WeaponAnimation.ShootBow; } }

		[Constructable]
		public ElficBow() : base( 0x13B2 )
		{
			LootType = Blessed;
			Name = "Elfic Bow";
			Hue = 1109;
			Attributes.SpellChanneling = 1;
			Attributes.WeaponSpeed = 20;
			Weight = 6.0;
			Layer = Layer.TwoHanded;
		}
		public override void GetDamageTypes( Mobile wielder, out int phys, out int fire, out int cold, out int pois, out int nrgy )
		{
			phys = fire = cold = pois = 0;
			nrgy = 100;
		}


		public ElficBow( Serial serial ) : base( serial )
		{
		}

[COLOR="Blue"]public Mobile Owner
		{
			get{ return m_Owner; }
			set{ m_Owner = value; }
		}

public override void OnEquip( Mobile from )
		{
			if ( from != m_Owner )
			{
				from.SendLocalizedMessage( "This Weapon isnt yours!" );
			}
			else
			{
				return true;
			}
		}[/COLOR]
		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 0 ); // version
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			if ( Weight == 7.0 )
				Weight = 6.0;
		}
	}
}

Blue is what I added....

NOTE IM NOT OWNER OF SCRIPT, lol just took a chance and plugged it in....
 

darksky

Sorceror
Code:
Scripts: Compiling C# scripts...failed (1 errors, 0 warnings)
 - Error: Scripts\ElficBow.cs: CS0508: (line 63, column 22) 'Server.Items.ElficB
ow.OnEquip(Server.Mobile)': não é possível alterar tipo de retorno ao substituir
 membro herdado 'Server.Items.BaseWeapon.OnEquip(Server.Mobile)'
Scripts: One or more scripts failed to compile or no script files were found.
 - Press return to exit, or R to try again.

Thanks you guys but I got this error now, I dont know what it mean, after the Service Pack 1 of .NET Framework everything is in portuguese now, anyway Ill try translate.

Code:
Is not possible to modify type of return when substituting a member "Server.Items.BaseWeapon.OnEquip(Server.Mobile)
 

arul

Sorceror
Code:
public override [B][COLOR="Red"]bool[/COLOR][/B] OnEquip( Mobile from )
		{
			if ( from != m_Owner )
			{
				from.SendLocalizedMessage( "This Weapon isnt your!" );
                                return false;
			}
			else
			         return true
                }
 

darksky

Sorceror
Now:

- Error: Scripts\ElficBow.cs: CS0103: (line 38, column 12) Nome 'Blessed' não e
xiste na classe ou no espaço para nome 'Server.Items.ElficBow'
- Error: Scripts\ElficBow.cs: CS0103: (line 59, column 13) Nome 'm_Owner' não e
xiste na classe ou no espaço para nome 'Server.Items.ElficBow'
- Error: Scripts\ElficBow.cs: CS0103: (line 60, column 6) Nome 'm_Owner' não ex
iste na classe ou no espaço para nome 'Server.Items.ElficBow'
- Error: Scripts\ElficBow.cs: CS0103: (line 65, column 14) Nome 'm_Owner' não e
xiste na classe ou no espaço para nome 'Server.Items.ElficBow'
- Error: Scripts\ElficBow.cs: CS1502: (line 67, column 1) Melhor método sobreca
rregado compatível com 'Server.Mobile.SendLocalizedMessage(int)' tem alguns argu
mentos inválidos
- Error: Scripts\ElficBow.cs: CS1503: (line 67, column 28) Argumento '1': não p
ode converter de 'string' em 'int'
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
 

daat99

Moderator
Staff member
If you changed anything in the script then we need to see what you changed.
Full script is always good thing to post along with errors.
 

darksky

Sorceror
Code:
using System;
using Server.Network;
using Server.Items;

namespace Server.Items
{
[FlipableAttribute( 0x13B2, 0x13B1 )]
public class ElficBow : BaseRanged
{
public override int EffectID{ get{ return 0xF42; } }
public override Type AmmoType{ get{ return typeof( Arrow ); } }
public override Item Ammo{ get{ return new Arrow(); } }

public override WeaponAbility PrimaryAbility{ get{ return WeaponAbility.ParalyzingBlow; } }
public override WeaponAbility SecondaryAbility{ get{ return WeaponAbility.MortalStrike; } }

public override int AosStrengthReq{ get{ return 30; } }
public override int AosMinDamage{ get{ return 16; } }
public override int AosMaxDamage{ get{ return 18; } }
public override int AosSpeed{ get{ return 25; } }

public override int OldStrengthReq{ get{ return 20; } }
public override int OldMinDamage{ get{ return 9; } }
public override int OldMaxDamage{ get{ return 41; } }
public override int OldSpeed{ get{ return 20; } }

public override int DefMaxRange{ get{ return 10; } }

public override int InitMinHits{ get{ return 255; } }
public override int InitMaxHits{ get{ return 255; } }


public override WeaponAnimation DefAnimation{ get{ return WeaponAnimation.ShootBow; } }

[Constructable]
public ElficBow() : base( 0x13B2 )
{
LootType = Blessed;
Name = "Elfic Bow";
Hue = 1109;
Attributes.SpellChanneling = 1;
Attributes.WeaponSpeed = 20;
Weight = 6.0;
Layer = Layer.TwoHanded;
}
public override void GetDamageTypes( Mobile wielder, out int phys, out int fire, out int cold, out int pois, out int nrgy )
{
phys = fire = cold = pois = 0;
nrgy = 100;
}


public ElficBow( Serial serial ) : base( serial )
{
}

public Mobile Owner
{
get{ return m_Owner; }
set{ m_Owner = value; }
}

public override bool OnEquip( Mobile from )
{
if ( from != m_Owner )
{
from.SendLocalizedMessage( "This Weapon isnt yours!" );
return false;
}
else
{
return true;
}
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );

writer.Write( (int) 0 ); // version
}

public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );

int version = reader.ReadInt();

if ( Weight == 7.0 )
Weight = 6.0;
}
}
}
 

daat99

Moderator
Staff member
Blessed isn't declared in your script.
You Blessed is a property of the LootType so you need to do:
Code:
LootType = LootType.Blessed;
 

darksky

Sorceror
- Error: Scripts\ElficBow.cs: CS0103: (line 59, column 13) Nome 'm_Owner' não e
xiste na classe ou no espaço para nome 'Server.Items.ElficBow'
- Error: Scripts\ElficBow.cs: CS0103: (line 60, column 6) Nome 'm_Owner' não ex
iste na classe ou no espaço para nome 'Server.Items.ElficBow'
- Error: Scripts\ElficBow.cs: CS0103: (line 65, column 14) Nome 'm_Owner' não e
xiste na classe ou no espaço para nome 'Server.Items.ElficBow'
- Error: Scripts\ElficBow.cs: CS1502: (line 67, column 1) Melhor método sobreca
rregado compatível com 'Server.Mobile.SendLocalizedMessage(int)' tem alguns argu
mentos inválidos
- Error: Scripts\ElficBow.cs: CS1503: (line 67, column 28) Argumento '1': não p
ode converter de 'string' em 'int'.



Does not exist in the class or in the space for the name "Server.Items.ElficBow"
"" """ """ """"" """ """ """"" """ """ """"" """ """ """"" """ """ """
"" """ """ """"" """ """ """"" """ """ """"" """ """ """"" """ """ """
Best method super loaded compatible with 'Server.Mobile.SendLocalizedMessage(int)' have some invalid arguments.
 

-Nox-

Wanderer
Create a serial property called m_Owner, then in the OnEquip bool, have the bool check to see if the weapon has a specified owner... if not, then assign the equipper's serial to the m_Owner property. If there is a property already assigned, have it return false and send a non-localized message. By the way... the term "localized" only applies to numbers that use an interger like "106660", not strings like "You cannot equip that!". :)

Follow my standard instrurction above, and your bow should work fine. Also, personally... I think "Elven" or "an Elven" sounds better than "Elfic". I doubt "Elfic" is even a word. :p
 

darksky

Sorceror
daat99, This error happened independent of LottType problem, so I dont saw reasons to post the code again.

-Nox-, Im sorry but my knowledge about scripting is very restricted, how I can do this ?

About the Elfic bow, I Agree perfectly, Elven is much better...
 

daat99

Moderator
Staff member
darksky said:
daat99, This error happened independent of LottType problem, so I dont saw reasons to post the code again.

-Nox-, Im sorry but my knowledge about scripting is very restricted, how I can do this ?

About the Elfic bow, I Agree perfectly, Elven is much better...
My post stated:
If you changed anything in the script then we need to see what you changed.
Full script is always good thing to post along with errors.
Since you fixed an error it's clear that you changed something hence the reason to repost the new code.

If you don't want to then it's your call, this is the last time I'm going to ask this from you, from now on if you post then I'll go over it, otherwise I'll just skip to the next thread.
We are not getting paid to help you know...
 

Axle

Wanderer
darksky said:
Hello guys... Im working on a race system (very simply) and each race will start with an item. Like:

Elf - Elfic Bow
Human - Sword of Justice
Dwarf - Shield of Immortality
etc...

I wont the players giving, selling or trading these items, even using with another character. So, I would have something that disallow other player use the item, making it disapear or just sending a msg. I have tried somethings without success.

Thanks!

I'm a bit confused, you want this item to be specific to the mobile it was given to or specific to the race?
 

darksky

Sorceror
Yes, I changed two lines, and of course Im not paying who helps me, Im just saying THANK YOU VERY MUCH!.

Right, if this helps, it is bellow...


Code:
using System;
using Server.Network;
using Server.Items;

namespace Server.Items
{
[FlipableAttribute( 0x13B2, 0x13B1 )]
public class ElvenBow : BaseRanged
{
public override int EffectID{ get{ return 0xF42; } }
public override Type AmmoType{ get{ return typeof( Arrow ); } }
public override Item Ammo{ get{ return new Arrow(); } }

public override WeaponAbility PrimaryAbility{ get{ return WeaponAbility.ParalyzingBlow; } }
public override WeaponAbility SecondaryAbility{ get{ return WeaponAbility.MortalStrike; } }

public override int AosStrengthReq{ get{ return 30; } }
public override int AosMinDamage{ get{ return 16; } }
public override int AosMaxDamage{ get{ return 18; } }
public override int AosSpeed{ get{ return 25; } }

public override int OldStrengthReq{ get{ return 20; } }
public override int OldMinDamage{ get{ return 9; } }
public override int OldMaxDamage{ get{ return 41; } }
public override int OldSpeed{ get{ return 20; } }

public override int DefMaxRange{ get{ return 10; } }

public override int InitMinHits{ get{ return 255; } }
public override int InitMaxHits{ get{ return 255; } }


public override WeaponAnimation DefAnimation{ get{ return WeaponAnimation.ShootBow; } }

[Constructable]
public ElvenBow() : base( 0x13B2 )
{
LootType = LootType.Blessed;
Name = "Elven Bow";
Hue = 1109;
Attributes.SpellChanneling = 1;
Attributes.WeaponSpeed = 20;
Weight = 6.0;
Layer = Layer.TwoHanded;
}
public override void GetDamageTypes( Mobile wielder, out int phys, out int fire, out int cold, out int pois, out int nrgy )
{
phys = fire = cold = pois = 0;
nrgy = 100;
}


public ElvenBow( Serial serial ) : base( serial )
{
}

public Mobile Owner
{
get{ return m_Owner; }
set{ m_Owner = value; }
}


public override bool OnEquip( Mobile from )
{

if ( from != m_Owner )
{
from.SendMessage( "Just the owner of this weapon can equip it!" );
return false;
}
else
{
return true;
}
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );

writer.Write( (int) 0 ); // version
}

public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );

int version = reader.ReadInt();

if ( Weight == 7.0 )
Weight = 6.0;
}
}
}

The error:
- Error: Scripts\ElficBow.cs: CS0103: (line 59, column 13) Nome 'm_Owner' não e
xiste na classe ou no espaço para nome 'Server.Items.ElvenBow'
- Error: Scripts\ElficBow.cs: CS0103: (line 60, column 6) Nome 'm_Owner' não ex
iste na classe ou no espaço para nome 'Server.Items.ElvenBow'
- Error: Scripts\ElficBow.cs: CS0103: (line 67, column 14) Nome 'm_Owner' não e
xiste na classe ou no espaço para nome 'Server.Items.ElvenBow'
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
Code:
In english:
"Name 'm_owner' does not exist in the classe or the space for the name 'Server.Items.ElvenBow' "
 

darksky

Sorceror
Axle said:
I'm a bit confused, you want this item to be specific to the mobile it was given to or specific to the race?

I didnt change the playermobile to this race sys, (im planning) so it will me specific of the mobile. When a character is created, a race gump show up and they must select a race, it change the color, beard, hair and its working ok, I want add a weapon for each race when the player push the button... but I wont players trading or giving these weapons, so this weapon can just be used for this player.
 

daat99

Moderator
Staff member
If you want each bow to be useable by a specific player then you need to declare a private property named m_Owner from type Mobile.

If you want each bow to be useable by each race (can be traded between elves) then you need to check the property that define each race (we need to see the script that define the races to know how to do it in your shard).
 
Top