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!

Full instructions for myrunuo (02/13/04)

Axle

Wanderer
Can anyone confirm this?

noobie said:
well, it was some time ago, so I dont remeber exactly the sql tables but i guess female column was "varchar" not "bool".

female = characterReader.GetBoolean( 5 );

changing this one to:

female = characterReader.GetString( 5 );

might work..

I'm thinking this is the problem:

Conversions are performed based on the underlying capabilities of the ODBC driver. If the conversion is not supported then the method call will fail.

Call System.Data.Odbc.OdbcDataReader.IsDBNull to check for null values before calling this method.

Requirements
Namespace: System.Data.Odbc
Platforms: Windows 98, Windows 98 Standard Edition, Windows Millenium Edition, Windows 2000, Windows 2000 Server, Windows 2000 Advanced Server, Windows XP Home Edition, Windows XP Professional, Windows XP, Windows "Longhorn"
Assembly: System.Data (in system.data.dll)
Version Information
.NET Framework
Supported in: 2.0, 1.1

note win2k3 is excuded from the list :confused:
Can anyone with a working paperdoll.aspx confirm this?
 

noobie

Wanderer
this is what I had two years ago..it should be working..

Code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.Odbc;
using Ultima;
using System.Drawing.Imaging;
using System.IO;


namespace xxx
{
	/// <summary>
	/// Summary description for CharacterInfo.
	/// </summary>
	public class CharacterInfoID : System.Web.UI.Page
	{
	

	
		private void Page_Load(object sender, System.EventArgs e)
		{	
			Response.Clear(); 
			bool ok = true; 

			int id=0;
			try 
			{
				id = int.Parse( Request.QueryString["CharID"] ); 
			} 
			catch 
			{ 
				ok = false; 
				return;
			} 
			OdbcConnection con=new OdbcConnection(ConnectionConfig.ODBCConnectionString());
			OdbcCommand commandText=new OdbcCommand();
			commandText.Connection=con;
			string name = ""; 
			bool female=false; 
			ushort bodyhue = 0; 
			string nototitle = ""; 
			if ( ok ) 
			{
				try
				{
					con.Open();
					commandText.CommandText=String.Format("Select * from myrunuo_characters where char_id={0}",id.ToString());
					OdbcDataReader characterReader = commandText.ExecuteReader(); 
					
					if ( characterReader.Read() ) 
					{ 
						name = characterReader.GetString( 1 ); 
						string fem = characterReader.GetString( 5 ); 
						if (fem=="1") female=true;
						bodyhue = Convert.ToUInt16(characterReader.GetInt32( 10 )); 
						nototitle = characterReader.GetString( 9 ); 
						Session["public"]=characterReader.GetString(11);
					} 
					characterReader.Close();
				} 
				catch
				{
					ok=false;
				}
			}
			if ( ok ) 
			{ 
				try
				{
					ArrayList itemEntries = new ArrayList();
					commandText.CommandText =String.Format("SELECT * FROM myrunuo_characters_layers WHERE char_id={0} ORDER BY layer_id ASC",id.ToString());
					OdbcDataReader layerReader = commandText.ExecuteReader(); 
					while ( layerReader.Read() ) 
					{ 
						byte layerID = layerReader.GetByte( 1 ); 
						ushort itemID = (ushort)layerReader.GetInt16( 2 ); 
						ushort itemHue = (ushort)layerReader.GetInt16( 3 );                
						itemEntries.Add( new ItemEntry( layerID, itemID, itemHue ) ); 
					} 
					layerReader.Close(); 
				
					Bitmap surface = new Bitmap( 262, 324 ); 
					Hues.GetHue((int)Color.White.GetHue()).ApplyTo(surface,false);
					Graphics result = Graphics.FromImage( surface ); 
             
					result.DrawImage( Ultima.Gumps.GetGump( 2001 ), 0, 0 ); // Paperdoll background 
             
					Font titleFont = new Font( "times", 10,FontStyle.Bold ); 
                    Brush titleBrush = Brushes.WhiteSmoke; 

					int index=nototitle.IndexOf(name);
					string profession="";
					int profindex=0;
					if (nototitle.Length > (profindex=index + name.Length))
					{
						profession=nototitle.Substring(profindex+1,nototitle.Length-(profindex+1));
						nototitle=nototitle.Substring(0,profindex);
					}             
					result.DrawString( nototitle, titleFont, titleBrush, new PointF( 35, 270 ) ); 
					if (profession!="")
						result.DrawString(profession, titleFont, titleBrush, new PointF(35, 285));
					Bitmap bodyImage = Ultima.Gumps.GetGump( female ? 13 : 12 ); // Body graphic 
					Hues.GetHue( bodyhue ).ApplyTo( bodyImage, false ); 
					result.DrawImage(bodyImage, 0, 15 ); 
					Bitmap status=Ultima.Gumps.GetGump( 2027);
					result.DrawImage(status, new PointF(183,230));
					Bitmap backpack=Ultima.Gumps.GetGump (50422);
					result.DrawImage(backpack, 12,15);
             
					if ( itemEntries.Count > 0 ) 
					{ 
						foreach ( ItemEntry entry in itemEntries ) 
						{ 
							Bitmap bmp = entry.CompileBitmap( female ); 
							if ( bmp == null ) 
								bmp = entry.CompileBitmap( !female ); 
                      
							if ( bmp != null ) 
							{ 
								Response.Write(bmp.Height);
								if ( entry.Hue > 0 ) 
									Hues.GetHue( entry.Hue ).ApplyTo( bmp, false ); 
                   
								result.DrawImage( bmp, 0, 15 ); 
								bmp.Dispose(); 
							} 
						} 
					} 
             
					MemoryStream memStream = new MemoryStream();
					Response.Clear();
					Response.ContentType="image/png";
             
					surface.Save( memStream, ImageFormat.Png); 
					Response.BinaryWrite(memStream.ToArray());
					con.Close();   
					if (result != null) result.Dispose();
					if (surface != null) surface.Dispose();
					Response.End(); 

				} 
				catch(Exception ex)
				{
					Response.Write(ex.ToString());
				}
				
			}
		}
		private class ItemEntry 
		{ 
			private int m_LayerID, m_ItemID, m_ItemHue; 
    
			public int Hue{ get{ return m_ItemHue; } } 
    
			public ItemEntry( int layerID, int itemID, int itemHue ) 
			{ 
				m_LayerID = layerID; 
				m_ItemID = itemID; 
				m_ItemHue = itemHue; 
			} 
       
			public Bitmap CompileBitmap( bool female ) 
			{ 
				int gumpID = ( female ? 60000 : 50000 ) + Ultima.TileData.ItemTable[ m_ItemID ].Animation; 
				return Ultima.Gumps.GetGump( gumpID ); 
			} 
		}


		#region Web Form Designer generated code
		protected override void OnInit(EventArgs e)
		{
			InitializeComponent();
			base.OnInit(e);
		}

		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}
 

Axle

Wanderer
Issue Resolved

Thanks Noobie, that did seem to work :) , although I promptly came up with other invalid casts for pubchar, body_hue etc. As far as the female boolean, not sure why the table wasn't set to use the bit data type instead of tinyint (byte). This is what I did, simply because converting opens up the possibilities of even more exceptions. I'm not really sure why the table in SQL is set to varchar(50) either, I converted the string to int but now face the possibility of 3 new types of exceptions: arguments, overflow and format. So far it works, tested both male and female. Here's what I changed:

Code:
string name = "";
			bool female = false;
			ushort bodyhue = 0;
			string nototitle = "";
			ushort pubchar = 0;
			
			OdbcDataReader characterReader = selectCommand.ExecuteReader();
			if ( characterReader.Read() )
			{
				name = characterReader.GetString( 1 );
                female = characterReader.GetBoolean(5); // for SQL 2k5, table changed to bit data type
                bodyhue = (ushort)characterReader.GetInt32(10); // for SQL 2k5, changed to read 32 bit int
                nototitle = characterReader.GetString( 9 );
                pubchar = (ushort)characterReader.GetByte( 11 ); // not sure why this isn't boolean using bit data type??
                //pubchar = Convert.ToUInt16(characterReader.GetByte(11)); 
				
			}
			else
			{
				ok = false;
			}
			characterReader.Close();

			if ( ok )
			{
				ArrayList itemEntries = new ArrayList();
			
				selectCommand.CommandText = String.Format( "SELECT * FROM myrunuo_characters_layers WHERE char_id='{0}' ORDER BY layer_id ASC", id.ToString() );
				OdbcDataReader layerReader = selectCommand.ExecuteReader();
				while ( layerReader.Read() )
				{
                    
					byte layerID = layerReader.GetByte( 1 );
                    //ushort itemID = (ushort)layerReader.GetInt16(2); ///MySql
                    string item_ID = layerReader.GetString(2);// SQL 2k5 table is set to varchar(50), reads item_ID as string
					int itemID = Convert.ToUInt16(item_ID); // converts item_ID string to int
                    ushort itemHue = (ushort)layerReader.GetInt32( 3 ); // table in SQL 2k5 is set to int (32 bit)
					
					itemEntries.Add( new ItemEntry( layerID, itemID, itemHue ) );
				}
				layerReader.Close();

Can anyone explain why int can't be used for item_id table? I suspect because it's wrote as 0X4d56?:confused:
 

noobie

Wanderer
int is 32 bit.

item_id is 16 bit.

use appropriate data type in the sql.
ex) for Postgresql you would use int2 for item_id, not int4 (regular int)

i dont know mysql data types, do a quick search and find out what equivalent for short int
 

daat99

Moderator
Staff member
mastery said:
Can somebody plz attach working version of myrunuo for runuo1.0.0 ?

You aren't allowed to make requests here.
If you want those script you have 2 options:
1. Search and hope to find it.
2. Try to script it yourself.

If you decide to try to script it yourself than feel free to post it here in
Code:
 tags and the errors that you get and we will be happy to help you.

Also, please read [url=http://www.runuo.com/forum/announcement.php?f=17][U][COLOR="Red"]this[/COLOR][/U][/url].
 
Top