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
Currently, I didnt change the player mobile, so I have no props to specify a race, just at appearece, so I need work on the mobile, Ill need specify the m_Mobile on the race script, but I need get the weapon script working first and I get those errors :(
 

Kireko

Wanderer
Because there is no m_Mobile yet.....

Its a system that would have to be made almost simeltaniously (sp?) for it to work.
 

daat99

Moderator
Staff member
darksky said:
Currently, I didnt change the player mobile, so I have no props to specify a race, just at appearece, so I need work on the mobile, Ill need specify the m_Mobile on the race script, but I need get the weapon script working first and I get those errors :(
Since you want it per player (which I think is a bad idea but it's your call) then you need to create a new private property called m_Owner of type Mobile in your bow script (like it was suggested before).
 

darksky

Sorceror
Ok guys, Im working on a new props called race to specify the race in playermobile, so I just need to if the mobile isnt an elf if (from is not an elf) I dont know how to write it..

Maybe from.race != elf ?

public override bool OnEquip( Mobile from )
{

if ( from != ???)
{
from.SendMessage( "Just elves can equip it!" );
return false;
}
else
{
return true;
}
 

daat99

Moderator
Staff member
We need to see how you declared the property in playermobile in order to help you.
 

darksky

Sorceror
public enum Race
{
None,
Elf,
HalfDaemon,
HalfOrc,
Dwarf,
Drow,
Human

}
[CommandProperty( AccessLevel.GameMaster )]
public Race Race
{
get{ return m_Race; }
set{ m_Race = value; }
}

The race is working well
 

darksky

Sorceror
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 override bool OnEquip( Mobile from )
{

if ( from.Race != Elf )
{
from.SendMessage( "Only elves may use this weapon." );
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;
}
}
}

I almost got it! Damnit!

I specified the Race props in the playermobile.cs but the server is searching in the basemobile, so I got this error:

Code:
 - Error: Scripts\ElficBow.cs: CS0117: (line 56, column 6) 'Server.Mobile' não c
ontém uma definição para 'Race'

'Server.Mobile' does not contain a definition for 'Race'
 

daat99

Moderator
Staff member
darksky said:
'Server.Mobile' does not contain a definition for 'Race'
You declared the Race property in the PlayerMobile class and not in the Mobile class.
You need to test it in the PlayerMobile class as well.
 

darksky

Sorceror
Sorry, Im not unstanding what u mean. I declared in the playermobile, in the game I can set the race without problems.

Test what? Im a lil confused!
 

daat99

Moderator
Staff member
The OnEquip method is used on a Mobile class:
Code:
public override bool OnEquip( [COLOR="Blue"]Mobile[/COLOR] from )
You need to check the property on a PlayerMobile instead.
Don't try to replace the word Mobile with PlayerMobile because there is no OnEquip method for PlayerMobile class.

Take a look at another script that does something on a player (not mobile) and see how it's done in there.

Basically you need to case a new object as PlayerMobile based on your Mobile object.

If you don't know how then you need to read some c# tutorials on casting objects.
 

Axle

Wanderer
You need to cast the mobile as a playermobile, because playermobile class is where you have the race property defined. Doing this the way you're doing will make it race specific, not mobile specific. I'm guessing you wanted it mobile specific as far as making it worthless for others to loot off of corpses?
 

darksky

Sorceror
I agree, I need read come c# tutorials... (If u know any good guide in portuguese... I dont know speak english)

Each race will have a weapon like Arty, its blessed but I wont other race using the item.

I almost got my brain working, its hard, anyway Im trying lol.
 

daat99

Moderator
Staff member
darksky said:
I agree, I need read come c# tutorials... (If u know any good guide in portuguese... I dont know speak english)

Each race will have a weapon like Arty, its blessed but I wont other race using the item.

I almost got my brain working, its hard, anyway Im trying lol.
You can use google to find a lot of c# tutorials in almost all the languages.
I found some in hebrew so I can bet you can find in portuguese as well ;)
 

darksky

Sorceror
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 override bool OnEquip( Mobile from )
{
			private string m_From;
m_From = from;
if ( m_From is PlayerMobile & m_From.Race != Elf )

{
from.SendMessage( "Only elves may use this weapon." );
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;
}
}
}

I tried this:

public override bool OnEquip( Mobile from )
{
private string m_From;
m_From = from;
if ( m_From is PlayerMobile & m_From.Race != Elf )

{
from.SendMessage( "Only elves may use this weapon." );
return false;
}
else
{
return true;
}


And got this:

Code:
Scripts: Compiling C# scripts...failed (12 errors, 0 warnings)
 - Error: Scripts\ElvenBow.cs: CS1513: (line 54, column 2) } esperada
 - Error: Scripts\ElvenBow.cs: CS1519: (line 56, column 8) Símbolo '=' inválido
na declaração de membro class, struct ou interface
 - Error: Scripts\ElvenBow.cs: CS1519: (line 56, column 14) Símbolo ';' inválido
 na declaração de membro class, struct ou interface
 - Error: Scripts\ElvenBow.cs: CS1519: (line 57, column 13) Símbolo 'is' inválid
o na declaração de membro class, struct ou interface
 - Error: Scripts\ElvenBow.cs: CS1519: (line 57, column 29) Símbolo '&' inválido
 na declaração de membro class, struct ou interface
 - Error: Scripts\ElvenBow.cs: CS1519: (line 57, column 43) Símbolo '!=' inválid
o na declaração de membro class, struct ou interface
 - Error: Scripts\ElvenBow.cs: CS1519: (line 57, column 50) Símbolo ')' inválido
 na declaração de membro class, struct ou interface
 - Error: Scripts\ElvenBow.cs: CS1519: (line 60, column 17) Símbolo '(' inválido
 na declaração de membro class, struct ou interface
 - Error: Scripts\ElvenBow.cs: CS0116: (line 63, column 1) Espaço para nome não
contém diretamente membros, como campos ou métodos
 - Error: Scripts\ElvenBow.cs: CS1518: (line 69, column 17) Class, delegate, enu
m, interface ou struct esperado
 - Error: Scripts\ElvenBow.cs: CS1518: (line 76, column 17) Class, delegate, enu
m, interface ou struct esperado
 - Error: Scripts\ElvenBow.cs: CS1022: (line 85, column 1) Definição de espaço p
ara nome ou tipo, ou final do arquivo esperado
Scripts: One or more scripts failed to compile or no script files were found.
 

daat99

Moderator
Staff member
Code:
private string m_From;
m_From = from;
from is a variable of type Mobile
m_From is a variable of type string
You can't assign a Mobile value into a string value.


Code:
if ( m_From is PlayerMobile & m_From.Race != Elf )
m_From is a string and PlayerMobile is an object class, string can't be an object.
 

Packer898

Knight
Casting looks like this...

Item p = new PlateGorget();
p.Hue = 45;
blah blah

etc...

You need something along the lines of this...

if ( from is PlayerMobile )
PlayerMobile p = (PlayerMobile)from;
 

Axle

Wanderer
A few pointers, you should change this:

Code:
}
[CommandProperty( AccessLevel.GameMaster )]
public Race Race
{
get{ return m_Race; }
set{ m_Race = value; }
}

to something like this:


Code:
[CommandProperty( AccessLevel.GameMaster )]
public Race [COLOR="Red"]RaceType[/COLOR]
{
get{ return m_Race; }
set{ m_Race = value; }
}

or else it may get confusing down the road. Note the red code is your enumeration, so you need to change it to match. So to clerify, Race is the name of the command property and RaceType is your enumeration.

in your if statement, !elf will expect an enumeration, so you'll have to add !RaceType.Elf.
 

darksky

Sorceror
Im sorry guys... Im so stupid!

I need learn c#... When I get some free time Ill read some guides...

Thank you! I got this script working....

Elves in my shard have a special and different color, so why not?

public override bool OnEquip( Mobile from )
{
if ( from.Hue != 33820 )

{
from.SendMessage( "Only elves may use this weapon." );
return false;
}
else
{
return true;
}
}

lol
 

daat99

Moderator
Staff member
darksky said:
Im sorry guys... Im so stupid!

I need learn c#... When I get some free time Ill read some guides...

Thank you! I got this script working....

Elves in my shard have a special and different color, so why not?
Code:
public override bool OnEquip( Mobile from )
{
if ( from.Hue != 33820 )

{
from.SendMessage( "Only elves may use this weapon." );
return false;
}
else
{
return true;
}
}

lol
That will work only if your elves didn't casted a spell that changed their hue or painted themself using an item that changed the hue.
 
Top