|
||
|
|||||||
| Script Support Get support for modifying RunUO Scripts, or writing your own! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Forum Expert
Join Date: Sep 2007
Location: Over there
Posts: 1,575
|
I'm having issues trying to get this script to compile. This is a test script for an npc quest giver.
Here's the error: Code:
Errors:
+ Customs/test999.cs:
CS0161: Line 90: 'Server.Mobiles.test999.OnDragDrop(Server.Mobile, Server.It
em)': not all code paths return a value
Here is the code: Code:
public override bool OnDragDrop( Mobile from, Item dropped )
{
Mobile m = from;
PlayerMobile mobile = m as PlayerMobile;
if (mobile != null)
{
if (dropped is Katana)
{
if (dropped.Amount!=1)
{
this.PrivateOverheadMessage(MessageType.Regular, 1153, false,"That's not the right amount here!",mobile.NetState);
return false;
}
dropped.Delete();
mobile.AddToBackpack(new Katana());
this.PrivateOverheadMessage(MessageType.Regular, 1153, false,"hyhyhyh" , mobile.NetState);
return true;
}
else if (dropped is Whip)
{
this.PrivateOverheadMessage(MessageType.Regular, 1153, 1054071, mobile.NetState);
return false;
}
else
{
this.PrivateOverheadMessage(MessageType.Regular, 1153, false,"I have no need for this... ", mobile.NetState);
return false;
}
}
}
}
|
|
|
|
|
|
#2 (permalink) |
|
Forum Novice
|
Your not returning a value... your error explains it a little...'not all code paths return a value'.
Your class is... 'public override bool OnDragDrop( Mobile from, Item item )'. The class requires you to return a bool value, true or false. *edit* Looks like the null check at the start might be the cause, whats it return if the mobile's null ?
__________________
![]() We can be found on joinUO.com or listUO.com, come try us out.
Last edited by FingersMcSteal; 09-03-2008 at 10:58 PM. |
|
|
|
|
|
#3 (permalink) |
|
Forum Novice
Join Date: Sep 2007
Posts: 367
|
So... which line is line 90? It would be nice if you posted the whole script.
Edit: Try adding in this line in red: Code:
public override bool OnDragDrop(Mobile from, Item dropped)
{
Mobile m = from;
PlayerMobile mobile = m as PlayerMobile;
if (mobile != null)
{
if (dropped is Katana)
{
if (dropped.Amount != 1)
{
this.PrivateOverheadMessage(MessageType.Regular, 1153, false, "That's not the right amount here!", mobile.NetState);
return false;
}
dropped.Delete();
mobile.AddToBackpack(new Katana());
this.PrivateOverheadMessage(MessageType.Regular, 1153, false, "hyhyhyh", mobile.NetState);
return true;
}
else if (dropped is Whip)
{
this.PrivateOverheadMessage(MessageType.Regular, 1153, 1054071, mobile.NetState);
return false;
}
else
{
this.PrivateOverheadMessage(MessageType.Regular, 1153, false, "I have no need for this... ", mobile.NetState);
return false;
}
}
else
{
return false;
this.PrivateOverheadMessage(MessageType.Regular, 1153, false, "I have no need for this...", mobile.NetState);
}
}
You haven't put in a return value (true/false) for that. Last edited by Tassyon T; 09-03-2008 at 11:08 PM. |
|
|
|
|
|
#7 (permalink) |
|
Administrator
Join Date: Aug 2002
Location: Baltimore, MD
Age: 25
Posts: 4,870
|
You should indent your code properly, it makes errors like this a lot easier to spot.
__________________
Zippy, Razor Creator and RunUO Core Developer The RunUO Software Team "Intuition, like a flash of lightning, lasts only for a second. It generally comes when one is tormented by a difficult decipherment and when one reviews in his mind the fruitless experiments already tried. Suddenly the light breaks through and one finds after a few minutes what previous days of labor were unable to reveal." ~The Cryptonomicon |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|