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!

need help

mkiplm

Sorceror
need help

i tryed to make a script thats a earring addes +1 control for animels and i dont no how to add it in can any one help
 

Attachments

  • +1controlcap.cs
    2.3 KB · Views: 6

jaynigs

Wanderer
Take a look at another item script that gives skill bonuses, the Burglars bandana springs to mind. Im sure there are others, but i know that one has skillbonuses.
 

mkiplm

Sorceror
i mean like max followers that u cna have i want to make errings that can add +1 to that so it makes it 6 instead of 5
 

jaynigs

Wanderer
Ah ic, the property you need to change is FollowersMax.

So for example

Code:
from.FollowersMax += 1;

Dont forget to have it revert back to normal when the player removes the earrings.

Also, dont expect to just paste that line of code in and expect it to work, from looking at your script you need to do more work to it yet
 

mkiplm

Sorceror
jaynigs said:
Ah ic, the property you need to change is FollowersMax.

So for example

Code:
from.FollowersMax += 1;

Dont forget to have it revert back to normal when the player removes the earrings.

Also, dont expect to just paste that line of code in and expect it to work, from looking at your script you need to do more work to it yet


what else do i need or can u make changes to it so when they put it on it gives +1 and when they take it off it gose back to normal
 

jaynigs

Wanderer
yes, provided that (from) is defined as the player equiping the earrings, which is one part that is missing from the script you posted.


you need to add these 2 overrides to your script to start with..

Code:
public override void OnAdded( object parent )
{
             //you code here
}


public override void OnRemoved( object parent )
{
             //your code here
}
 

mkiplm

Sorceror
jaynigs said:
yes, provided that (from) is defined as the player equiping the earrings, which is one part that is missing from the script you posted.


you need to add these 2 overrides to your script to start with..

Code:
public override void OnAdded( object parent )
{
             //you code here
}


public override void OnRemoved( object parent )
{
             //your code here
}


then it should work?
 

jaynigs

Wanderer
Yes it will, try and work out what you need to add to those 2 overrides, i have given you pretty much all the code you need, except a few things, give it a try and see if you can work out how to do it.
 

mkiplm

Sorceror
jaynigs said:
Yes it will, try and work out what you need to add to those 2 overrides, i have given you pretty much all the code you need, except a few things, give it a try and see if you can work out how to do it.


i got errors with this what i added


- Error: Scripts\custom scripts\ScriptMaker3[1].25\+1controlcap.cs: CS1513: (li
ne 15, column 38) } expected
- Error: Scripts\custom scripts\ScriptMaker3[1].25\+1controlcap.cs: CS1519: (li
ne 29, column 24) Invalid token '=' in class, struct, or interface member declar
ation
- Error: Scripts\custom scripts\ScriptMaker3[1].25\+1controlcap.cs: CS1519: (li
ne 29, column 42) Invalid token ';' in class, struct, or interface member declar
ation
- Error: Scripts\custom scripts\ScriptMaker3[1].25\+1controlcap.cs: CS1518: (li
ne 31, column 22) Expected class, delegate, enum, interface, or struct
- Error: Scripts\custom scripts\ScriptMaker3[1].25\+1controlcap.cs: CS1518: (li
ne 35, column 31) Expected class, delegate, enum, interface, or struct
- Error: Scripts\custom scripts\ScriptMaker3[1].25\+1controlcap.cs: CS1518: (li
ne 41, column 31) Expected class, delegate, enum, interface, or struct
- Error: Scripts\custom scripts\ScriptMaker3[1].25\+1controlcap.cs: CS1022: (li
ne 46, column 19) Type or namespace definition, or end-of-file expected
 

Attachments

  • +1controlcap.cs
    1.3 KB · Views: 4

jaynigs

Wanderer
You cant just throw those overrides in any where, they need to be in the correct place.. like below..

Code:
//Created by Script Creator
using System;
using Server;
using Server.Items;

public class ControlCap: SilverEarrings
{
	[Constructable]
	public ControlCap()
	{
		Weight = 1;
		Name = "More Control Cap";
		Hue = 1153;

		LootType = LootType.Blessed; 
	}

	public override void OnAdded( object parent )
	{
        	from.FollowersMax += 1;
	}


	public override void OnRemoved( object parent )
	{
		from.FollowersMax -= 1;
	}              

	public ControlCap( Serial serial ) : base( serial )
	{
	}
              
	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();
	}
}

Note that although i have moved it to the correct place, it will still not compile, you need to check that object parent is a mobile and then cast the object parent as your mobile ( from ).

I suggest you take a look at basejewel.cs and see if you can find the 2 methods, OnAdded and OnRemoved and see if you can work out what you need to do to get this to work
 

mkiplm

Sorceror
public override void OnAdded( object parent )
{
if ( Core.AOS && parent is Mobile )
{
Mobile from = (Mobile)parent;

m_AosSkillBonuses.AddTo( from );

int strBonus = m_AosAttributes.BonusStr;
int dexBonus = m_AosAttributes.BonusDex;
int intBonus = m_AosAttributes.BonusInt;

if ( strBonus != 0 || dexBonus != 0 || intBonus != 0 )
{
string modName = this.Serial.ToString();

if ( strBonus != 0 )
from.AddStatMod( new StatMod( StatType.Str, modName + "Str", strBonus, TimeSpan.Zero ) );

if ( dexBonus != 0 )
from.AddStatMod( new StatMod( StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero ) );

if ( intBonus != 0 )
from.AddStatMod( new StatMod( StatType.Int, modName + "Int", intBonus, TimeSpan.Zero ) );
}

from.CheckStatTimers();
}
}

public override void OnRemoved( object parent )
{
if ( Core.AOS && parent is Mobile )
{
Mobile from = (Mobile)parent;

m_AosSkillBonuses.Remove();

string modName = this.Serial.ToString();

from.RemoveStatMod( modName + "Str" );
from.RemoveStatMod( modName + "Dex" );
from.RemoveStatMod( modName + "Int" );

from.CheckStatTimers();
}
}

would that be one of them
 

jaynigs

Wanderer
yes it is, now you do not need all that code in your earrings, you simply need the code that checks if object parent is a mobile, and then cast mobile from as the object parent ( as it is shown in basejewel )

Keep at it, and try to understand what we are doing here.
 

mkiplm

Sorceror
public override void OnAdded( object parent )
{
if ( Core.AOS && parent is Mobile )
{
Mobile from = (Mobile)parent;



public override void OnRemoved( object parent )
{
if ( Core.AOS && parent is Mobile )
{
Mobile from = (Mobile)parent;


so only that
 

jaynigs

Wanderer
mkiplm said:
public override void OnAdded( object parent )
{
if ( Core.AOS && parent is Mobile )
{
Mobile from = (Mobile)parent;



public override void OnRemoved( object parent )
{
if ( Core.AOS && parent is Mobile )
{
Mobile from = (Mobile)parent;


so only that

You are on the right lines, you do not need the Core.AOS check though, so just

Code:
			if (  parent is Mobile )
			{
				Mobile from = (Mobile)parent;
 

jaynigs

Wanderer
mkiplm said:
if ( parent is Mobile )
{
Mobile from = (Mobile)parent;

so this should go right under the other one

No, above it,

Code:
                if (  parent is Mobile )
		{
			Mobile from = (Mobile)parent;
             	        from.FollowersMax += 1;
                }
 

mkiplm

Sorceror
- Error: Scripts\custom scripts\ScriptMaker3[1].25\+1controlcap.cs: CS1519: (li
ne 18, column 17) Invalid token 'if' in class, struct, or interface member decla
ration
- Error: Scripts\custom scripts\ScriptMaker3[1].25\+1controlcap.cs: CS1519: (li
ne 18, column 30) Invalid token 'is' in class, struct, or interface member decla
ration
- Error: Scripts\custom scripts\ScriptMaker3[1].25\+1controlcap.cs: CS1519: (li
ne 18, column 40) Invalid token ')' in class, struct, or interface member declar
ation
- Error: Scripts\custom scripts\ScriptMaker3[1].25\+1controlcap.cs: CS1519: (li
ne 21, column 41) Invalid token '+=' in class, struct, or interface member decla
ration
- Error: Scripts\custom scripts\ScriptMaker3[1].25\+1controlcap.cs: CS1518: (li
ne 24, column 18) Expected class, delegate, enum, interface, or struct
- Error: Scripts\custom scripts\ScriptMaker3[1].25\+1controlcap.cs: CS1518: (li
ne 30, column 18) Expected class, delegate, enum, interface, or struct
- Error: Scripts\custom scripts\ScriptMaker3[1].25\+1controlcap.cs: CS1518: (li
ne 35, column 9) Expected class, delegate, enum, interface, or struct
- Error: Scripts\custom scripts\ScriptMaker3[1].25\+1controlcap.cs: CS1518: (li
ne 39, column 18) Expected class, delegate, enum, interface, or struct
- Error: Scripts\custom scripts\ScriptMaker3[1].25\+1controlcap.cs: CS1518: (li
ne 45, column 18) Expected class, delegate, enum, interface, or struct
- Error: Scripts\custom scripts\ScriptMaker3[1].25\+1controlcap.cs: CS1022: (li
ne 50, column 1) Type or namespace definition, or end-of-file expected

Errors lots of them to
 

Attachments

  • +1controlcap.cs
    964 bytes · Views: 4

jaynigs

Wanderer
when i said above it, i still meant within the overrides,

Code:
	public override void OnAdded( object parent )
	{
		if (  parent is Mobile )
		{
			Mobile from = (Mobile)parent;
			from.FollowersMax += 1;
		}
	}
 
Top