private static void Durability(Entity attacker, Entity attacked, Database.SpellInformation spell)
{//duranano
if (spell != null)
if (!spell.CanKill)
return;
#region Attack
if (attacker != null)
if (attacker.EntityFlag == EntityFlag.Player)
{
for (byte i = 4; i <= 6; i++)
{
if (attacker.Owner.Equipment.Free(i))
{
var item = attacker.Owner.Equipment.TryGetItem(i);
i = 0; <<<---Added to get rid of the other null error
if (i == 5)
{
{
if (Network.PacketHandler.IsArrow(item.ID))
{
continue;
}
}
if (Kernel.Rate(30, 100))
{
{
if (item.Durability != 0)
{
item.Durability -= 5;
Database.ConquerItemTable.UpdateDurabilityItem(item);
item.Mode = Enums.ItemMode.Update;
item.Send(attacker.Owner);
item.Mode = Enums.ItemMode.Default;
}
}
}
}
if (i == 6)
break;
}
if (attacker.Owner.Equipment.Free(10))
{
var item = attacker.Owner.Equipment.TryGetItem(10);
if (Kernel.Rate(30, 100))
{
if (item.Durability != 0) <<<null reference here
{
item.Durability -= 10;
Database.ConquerItemTable.UpdateDurabilityItem(item);
item.Mode = Enums.ItemMode.Update;
item.Send(attacker.Owner);
item.Mode = Enums.ItemMode.Default;
}
}
}
}
#endregion
Why would you be performing so many calculations before checking for NREs? Obviously you shouldn't be passing junk values into the function but if you're having issues and don't mind breaking coding conventions then just check == null and return at the very start of the function.
That way you exit the function as soon as possible if there's junk data entered.
The core issue is that you're pulling items and never checking if the item exists...
Honestly this is why functions like TryGet are so useful cause they reduce the possibility of issues like this. That being said all you have to do is check if item != null
Now - I'm not going to rant on it as long as I want to but my good ***... BREAKPOINTS.
If you have an issue in a function you place a breakpoint at the start and then step through the code until you see what item is null. It would take you 30-40 seconds to step through the function and by mousing over item you'd go "ooh ****. item is null" and you could add a check.
Breakpoints are pretty much foolproof... you place them... you step through and you read what variables are set to and make sure nothing ***** up in your function. Boom you're done.
You said that's where the exception is... and yet you never check if item is null right before using the item.
It could be the item is null or some component of the item is null (plus information, base item information, etc) which is why you HAVE to inspect the element rather than just breakpointing and not actually looking at the info it gives you.
I used your example and just changed skill to item, seems to have sorted it out, I did try that but didn't have a return so it's probably why the error kept happening but yes it's sorted now. Thank you
You said that's where the exception is... and yet you never check if item is null right before using the item.
It could be the item is null or some component of the item is null (plus information, base item information, etc) which is why you HAVE to inspect the element rather than just breakpointing and not actually looking at the info it gives you.
He has the NULL check this time, you probably didn't see it because of the ugly way he wrote it.
Will das Spiel starten und dann kommt NULL NULL 12/08/2011 - Kal Online - 2 Replies Also wie im titel schon gesagt ist habe ich wenn ich das spiel starten will ein kleines fenster mit zwei "NULL NULL" buttons kann mir jemand helfen wie ich jetzt spielen und das problem lösen kann. wäre cool wenn schnell eine antwort kommt
danke, gruß:D:D
Looking for a reference 11/08/2011 - Dekaron Private Server - 8 Replies We are sorry but we just got this letter and we comply with the msg
"
To Elitepvpers
The account Cataracts - Daemon Strother has been reported for multiple crimes by the US state department of illegal Child sexual abuse!
law § 2243 - Sexual abuse of a minor or ward:
(a) Of a Minor.— Whoever, in the special maritime and territorial jurisdiction of the United States or in a Federal prison, or in any prison, institution, or facility in which persons are held in custody by direction of or...
How to kill Dark Colluseast: Null and Steelation: Null (TT 3-1)? 06/10/2011 - PW Hacks, Bots, Cheats, Exploits - 1 Replies Can anyone tell me How to kill Dark Colluseast: Null and Steelation: Null (TT 3-1)?
:handsdown:
After patch 121 or mermaid update, the boss, Dark Colluseast: Null and Steelation: Null, has a random aggro, area stun, and area banish.
:confused: