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!

[RunUO 2.0 RC1] Storm33229's Kill Log 1.0

Storm33229's Kill Log 1.0

Storm33229's Kill Log 1.0

What does it do?
Here is an example of what the log looks like:
Code:
Storm33229's Kill Log 1.0
######################################################
Attacker: Storm
Attacker's Account: storm332
Victim: test
Victim's Account: storm33229
Victim's Location of Death: (1492, 1629, 13)
Victim's Time of Death: 8/13/2006 10:13:39 AM
######################################################
Attacker: Storm
Attacker's Account: storm332
Victim: test
Victim's Account: storm33229
Victim's Location of Death: (1481, 1612, 20)
Victim's Time of Death: 8/13/2006 10:13:56 AM

It writes the attackers name and the victims name, along with the exact date and time.

PlayerMobile.CS Edits
Code:
[SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][SIZE=2] OnBeforeDeath()
{
m_InsuranceCost = 0;
m_InsuranceAward = [/SIZE][SIZE=2][COLOR=#0000ff]base[/COLOR][/SIZE][SIZE=2].FindMostRecentDamager( [/SIZE][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][SIZE=2] );
[/SIZE][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( m_InsuranceAward [/SIZE][SIZE=2][COLOR=#0000ff]is[/COLOR][/SIZE][SIZE=2] BaseCreature )
{
Mobile master = ((BaseCreature)m_InsuranceAward).GetMaster();
[/SIZE][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( master != [/SIZE][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][SIZE=2] )
m_InsuranceAward = master;
}
[/SIZE][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( m_InsuranceAward != [/SIZE][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][SIZE=2] && (!m_InsuranceAward.Player || m_InsuranceAward == [/SIZE][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][SIZE=2]) )
m_InsuranceAward = [/SIZE][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][SIZE=2];
[/SIZE][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( m_InsuranceAward [/SIZE][SIZE=2][COLOR=#0000ff]is[/COLOR][/SIZE][SIZE=2] PlayerMobile )
((PlayerMobile)m_InsuranceAward).m_InsuranceBonus = 0;
[/SIZE][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( m_ReceivedHonorContext != [/SIZE][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][SIZE=2] )
m_ReceivedHonorContext.OnTargetKilled();
[/SIZE][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( m_SentHonorContext != [/SIZE][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][SIZE=2] )
m_SentHonorContext.OnSourceKilled();
[COLOR=red][SIZE=2][COLOR=red]PlayerMobile attacker = [/COLOR][/SIZE][COLOR=red][SIZE=2]this[/SIZE][SIZE=2].LastKiller [/SIZE][SIZE=2]as[/SIZE][/COLOR][SIZE=2][COLOR=red] PlayerMobile;[/COLOR]
[COLOR=red]PlayerMobile victim = [/COLOR][/SIZE][COLOR=red][SIZE=2]this[/SIZE][SIZE=2]as[/SIZE][/COLOR][SIZE=2][COLOR=red] PlayerMobile;[/COLOR]
[/SIZE][COLOR=red][SIZE=2]if[/SIZE][SIZE=2] (attacker [/SIZE][SIZE=2]is[/SIZE][SIZE=2] PlayerMobile && victim [/SIZE][SIZE=2]is[/SIZE][/COLOR][SIZE=2][COLOR=red] PlayerMobile)[/COLOR]
[COLOR=red]{[/COLOR]
[/SIZE][COLOR=red][SIZE=2]string[/SIZE][SIZE=2] path = [/SIZE][SIZE=2]"Storm33229's Kill Log 1.0.TXT"[/SIZE][/COLOR][SIZE=2][COLOR=red];[/COLOR]
[/SIZE][COLOR=red][SIZE=2]if[/SIZE][SIZE=2] (![/SIZE][SIZE=2]File[/SIZE][/COLOR][SIZE=2][COLOR=red].Exists(path))[/COLOR]
[COLOR=red]{[/COLOR]
[/SIZE][SIZE=2][COLOR=red]// Create a file to write to.[/COLOR]
[/SIZE][COLOR=red][SIZE=2]using[/SIZE][SIZE=2] ([/SIZE][SIZE=2]StreamWriter[/SIZE][SIZE=2] sw = [/SIZE][SIZE=2]File[/SIZE][/COLOR][SIZE=2][COLOR=red].CreateText(path))[/COLOR]
[COLOR=red]{[/COLOR]
[COLOR=red]sw.WriteLine([/COLOR][/SIZE][SIZE=2][COLOR=red]"Storm33229's Kill Log 1.0"[/COLOR][/SIZE][SIZE=2][COLOR=red]);[/COLOR]
[COLOR=red]sw.Close();[/COLOR]
[COLOR=red]}[/COLOR]
[COLOR=red]}[/COLOR]
[/SIZE][SIZE=2][COLOR=red]// This text is always added, making the file longer over time[/COLOR]
[/SIZE][SIZE=2][COLOR=red]// if it is not deleted.[/COLOR]
[/SIZE][COLOR=red][SIZE=2]using[/SIZE][SIZE=2] ([/SIZE][SIZE=2]StreamWriter[/SIZE][SIZE=2] sw = [/SIZE][SIZE=2]File[/SIZE][/COLOR][SIZE=2][COLOR=red].AppendText(path))[/COLOR]
[COLOR=red]{[/COLOR]
[COLOR=red]sw.WriteLine([/COLOR][/SIZE][SIZE=2][COLOR=red]"######################################################"[/COLOR][/SIZE][SIZE=2][COLOR=red]);[/COLOR]
[COLOR=red]sw.WriteLine([/COLOR][/SIZE][SIZE=2][COLOR=red]"Attacker: "[/COLOR][/SIZE][SIZE=2][COLOR=red] + attacker.Name);[/COLOR]
[COLOR=red]sw.WriteLine([/COLOR][/SIZE][SIZE=2][COLOR=red]"Attacker's Account: "[/COLOR][/SIZE][SIZE=2][COLOR=red] + attacker.Account);[/COLOR]
[COLOR=red]sw.WriteLine([/COLOR][/SIZE][SIZE=2][COLOR=red]"Victim: "[/COLOR][/SIZE][SIZE=2][COLOR=red] + victim.Name);[/COLOR]
[COLOR=red]sw.WriteLine([/COLOR][/SIZE][SIZE=2][COLOR=red]"Victim's Account: "[/COLOR][/SIZE][SIZE=2][COLOR=red] + victim.Account);[/COLOR]
[COLOR=red]sw.WriteLine([/COLOR][/SIZE][SIZE=2][COLOR=red]"Victim's Location of Death: "[/COLOR][/SIZE][SIZE=2][COLOR=red] + victim.Location);[/COLOR]
[COLOR=red]sw.WriteLine([/COLOR][/SIZE][COLOR=red][SIZE=2]"Victim's Time of Death: "[/SIZE][SIZE=2] + [/SIZE][SIZE=2]DateTime[/SIZE][/COLOR][SIZE=2][COLOR=red].Now);[/COLOR]
[COLOR=red]sw.Close();[/COLOR]
[COLOR=red]}[/COLOR]
[COLOR=red]}[/COLOR]
[/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]base[/COLOR][/SIZE][SIZE=2].OnBeforeDeath();
}
[/SIZE]

and DO NOT forget this:
Code:
[COLOR=red]using System.IO;[/COLOR]

Hopefully this will help eliminate and catch unwanted Player Killers(PKs) on shards who have rules against them.

Enjoy!
-Storm
 

Attachments

  • PlayerMobile.cs
    98.7 KB · Views: 119

PhoenixDIE

Wanderer
Getting this error when i try and edit this into the playermoblile.cs!



Error:
+ mobiles/playermoblile.cs:
CS1002: Line 1823: ; expected



Any ideas?
 

Attachments

  • PlayerMobile.cs
    98.6 KB · Views: 60

LightShade

Sorceror
I haven't had a chance to check this out yet, but if you're wanting to curb rampant PKing....or be able to keep track of it, you should probably add in coordinates, facet, account, etc... in the output file. That way you can see more of what is going on.
 
LightShade said:
I haven't had a chance to check this out yet, but if you're wanting to curb rampant PKing....or be able to keep track of it, you should probably add in coordinates, facet, account, etc... in the output file. That way you can see more of what is going on.

Great Idea!!

@PhoenixDIE: Hit CTRL+G type in the Line number and copy paste it in here and I will fix it for you.

-Storm

--Edit--
File Updated with new code!
 

PhoenixDIE

Wanderer
ok the line is 1823 and it says its this line :

PlayerMobile victim = thisas PlayerMobile;



Just wondering this is how its suposed to look right?

public override bool OnBeforeDeath()
{
m_InsuranceCost = 0;
m_InsuranceAward = base.FindMostRecentDamager( false );

if ( m_InsuranceAward is BaseCreature )
{
Mobile master = ((BaseCreature)m_InsuranceAward).GetMaster();

if ( master != null )
m_InsuranceAward = master;
}

if ( m_InsuranceAward != null && (!m_InsuranceAward.Player || m_InsuranceAward == this) )
m_InsuranceAward = null;

if ( m_InsuranceAward is PlayerMobile )
((PlayerMobile)m_InsuranceAward).m_InsuranceBonus = 0;

if ( m_ReceivedHonorContext != null )
m_ReceivedHonorContext.OnTargetKilled();
if ( m_SentHonorContext != null )
m_SentHonorContext.OnSourceKilled();
PlayerMobile attacker = this.LastKiller as PlayerMobile;
PlayerMobile victim = thisas PlayerMobile;
if (attacker is PlayerMobile && victim is PlayerMobile)
{
string path = "Storm33229's Kill Log 1.0.TXT";
if (!File.Exists(path))
{
// Create a file to write to.
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine("Storm33229's Kill Log 1.0");
sw.Close();
}
}
// This text is always added, making the file longer over time
// if it is not deleted.
using (StreamWriter sw = File.AppendText(path))
{
sw.WriteLine("######################################################");
sw.WriteLine("Attacker: " + attacker.Name);
sw.WriteLine("Attacker's Account: " + attacker.Account);
sw.WriteLine("Victim: " + victim.Name);
sw.WriteLine("Victim's Account: " + victim.Account);
sw.WriteLine("Victim's Location of Death: " + victim.Location);
sw.WriteLine("Victim's Time of Death: " + DateTime.Now);
sw.Close();
}
}
returnbase.OnBeforeDeath();
}
 
just copy my red text and slip it in.

the line:
PlayerMobile victim = thisas PlayerMobile;
needs to be:
PlayerMobile victim = this as PlayerMobile;
 

PhoenixDIE

Wanderer
haha..well..i changed that line now i get like 5 other errors! lol...thx any way




Line : 1827 the name 'file' does not exist in the current conext
Line : 1830 the type or namespace name 'streamwriter' could not be found (are you missing a using directive or an assemby reference?)
Line : 1830 the name 'file' does not exist in the current context
Line : 1839 The type of namespace name 'streamwriter' could not be found
(are you missing a useing directive or a assembly reference?)
Line : 1839 The name 'file' does not exist in the current context


and thats doing what you said copying red text and changeing that one like to this as! so i dont know! sorry
 
PhoenixDIE said:
haha..well..i changed that line now i get like 5 other errors! lol...thx any way




Line : 1827 the name 'file' does not exist in the current conext
Line : 1830 the type or namespace name 'streamwriter' could not be found (are you missing a using directive or an assemby reference?)
Line : 1830 the name 'file' does not exist in the current context
Line : 1839 The type of namespace name 'streamwriter' could not be found
(are you missing a useing directive or a assembly reference?)
Line : 1839 The name 'file' does not exist in the current context


and thats doing what you said copying red text and changeing that one like to this as! so i dont know! sorry

Re-read first post. I updated it. Add System.IO; to your using directives.

-Storm
 
Storm33229 said:
Re-read first post. I updated it. Add System.IO; to your using directives.

-Storm
Awesome, I wrote something like this awhile back but when lost it when both my computer and my moms computer( my backup spot ) died within the same week. :/

Thanks much, it saves me from rewriting it hehe. :D
 
o0_Sithid_0o said:
Awesome, I wrote something like this awhile back but when lost it when both my computer and my moms computer( my backup spot ) died within the same week. :/

Thanks much, it saves me from rewriting it hehe. :D

NP Skipper!

-Storm
 
Top