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.

daat99

Moderator
Staff member
Elf is a property of the Enum Race (or RaceType).
You need to access it as such:
Code:
Race.Elf // (or RaceType.Elf)
 

Joeku

Lord
Code:
if (p.RaceType =! Elf) {
Try to change "Elf" to "RaceType.Elf"

***EDIT***
Damnit, daat99 beat me :p
 

darksky

Sorceror
I think it is:

Code:
if (p.RaceType =! Race.Elf) {

"worked" but I got a new error on this line:

Code:
 - Error: Scripts\ElvenBow.cs: CS0023: (line 59, column 17) Operador '!' não pod
e ser aplicado a operando do tipo 'Server.Mobiles.Race'

Code:
Operator '!' cant be applied a operating of type 'Server.Mobiles.Race'
 

darksky

Sorceror
New error:

Code:
 - Error: Scripts\ElvenBow.cs: CS0161: (line 54, column 22) 'Server.Items.ElvenB
ow.OnEquip(Server.Mobile)': nem todos os caminhos de código retornam um valor
Scripts: One or more scripts failed to compile or no script files were found.
 - Press return to exit, or R to try again.
Code:
'Server.Items.ElvenBow.OnEquip(Server.Mobile)': not all the ways of the code return a valoue.

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

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;
}


[COLOR="Red"]public override bool OnEquip( Mobile from )[/COLOR]
{
if ( from is PlayerMobile )
{
PlayerMobile p = from as PlayerMobile;
if (p.RaceType != Race.Elf) {
from.SendMessage( "Only elves may use this weapon." );
return false;
}
else
{
return true;
}
}
}
		public ElvenBow( 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;
		}
	}
}
 

daat99

Moderator
Staff member
Code:
public override [COLOR="Blue"]bool[/COLOR] OnEquip( Mobile from )
{
if ( from is PlayerMobile )
{
PlayerMobile p = from as PlayerMobile;
if (p.RaceType != Race.Elf) {
from.SendMessage( "Only elves may use this weapon." );
return [COLOR="#ff0000"]false[/COLOR];
}
else
{
return [COLOR="Red"]true[/COLOR];
}
}
}
The word bool at the line that start the method means that this method need to return a value of boolean type.
That means true\false.
In the OnEquip method it means if the item will be equiped or not (true is yes, false is no).
The error means that there are chances that it won't return any value.
What you need is to move the return true to the end of the method and delete the else { } block so it'll look like this:
Code:
public override bool OnEquip( Mobile from )
{
if ( from is PlayerMobile )
{
PlayerMobile p = from as PlayerMobile;
if (p.RaceType != Race.Elf) {
from.SendMessage( "Only elves may use this weapon." );
return false;
}
}
return true;
}
 

darksky

Sorceror
It worked!!!!!!!!!!!!!!!!!!!!!!!!!

Thank you a lot!

After 5 pages it worked... I cant believe...

Thanks again
And again!
 

daat99

Moderator
Staff member
darksky said:
It worked!!!!!!!!!!!!!!!!!!!!!!!!!

Thank you a lot!

After 5 pages it worked... I cant believe...

Thanks again
And again!
I'm realy glad that it worked and I realy hope that you learned how to create a new property and how to access it ;)
You showed motivation and willingness to learn which made me personaly want to help you out, keep it up and you'll get a lot from this community ;)
 

Kireko

Wanderer
I think you should post it when you get it done. Id like to use it rather than the one I have!

Just a thought.:D
 

daat99

Moderator
Staff member
Kireko said:
I think you should post it when you get it done. Id like to use it rather than the one I have!

Just a thought.:D
I think he shouldn't.
He edited playermobile and most of the admins will use it and then will end up wiping their entire shard because 90% of the people that download pre-made scripts doesn't know how to solve those problems (the other 10% won't need his script because they probably made their own version already).
 

Heartless

Wanderer
daat99 said:
I think he shouldn't.
He edited playermobile and most of the admins will use it and then will end up wiping their entire shard because 90% of the people that download pre-made scripts doesn't know how to solve those problems (the other 10% won't need his script because they probably made their own version already).



First time i agreed with you daat :p


Just like your daat99 pack, 99% of all shards use it,
so that why i DONT use it :D
 

daat99

Moderator
Staff member
Heartless said:
First time i agreed with you daat :p


Just like your daat99 pack, 99% of all shards use it,
so that why i DONT use it :D
2 major differences.
1. My OWLTR won't cause a shard wipe.
2. My OWLTR have custom settings that 100% of the shards can change to be uniqe ;)
 

Kireko

Wanderer
If you knew what you where doing you could change the names on that and have it "unique" also. and even add a class or two...
 

darksky

Sorceror
Well... Im not good at scripting.. I start having a shard in january of 2004, but I closed it, had a lot of things that I got in RunUO Forums (I was using beta 36). Now Im working on a Shard called Faerun Gof (almost 5 years old, im not the owner), we closed the shard few months ago because had somethings runing the shard. Such as Gateroom with all dungeons/cities/quests/events/custom spawn, skillstone (with 270 start skills) players getting maxxed too fast and a lot of things that was killing a lil the Ultima Online Soul.

I want be unique, I know my limits about scripting knowledge but I always try to broke it. So im currently working on my own scripts, my own gumps and ideas, Im just sick of shards using just done scripts (30% Of PvP shards looks the same...). We have some scripts from RunUO, great scripts and we are very thankful.

We got a lot of shards in UOG, if you have creativity and use it on ur shard, u probally will get a very nice shard.

The shard is coming back in november, so I have a lot of time to spent on my crazy ideas.

I will probally post all my scripts in this forum when these scripts get unuseful. (A lot of creatures, gumps, quests, etc)

You have a lot of advantages building your own script.

I may changes these races or add more things.

;)

(Sorry about my english)
 
Top