Go Back   RunUO - Ultima Online Emulation > RunUO > Script Support

Script Support Get support for modifying RunUO Scripts, or writing your own!

Reply
 
Thread Tools Display Modes
Old 09-03-2008, 10:36 PM   #1 (permalink)
Forum Expert
 
TheRockstar2253's Avatar
 
Join Date: Sep 2007
Location: Over there
Posts: 1,575
Default OnDragDrop help

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;
                             }
                             
                          }
                      }
                 }
Anyway help will be much appreciated! -Rock
TheRockstar2253 is offline   Reply With Quote
Old 09-03-2008, 10:55 PM   #2 (permalink)
Forum Novice
 
FingersMcSteal's Avatar
 
Join Date: Mar 2006
Location: North East, England, UK
Posts: 865
Send a message via ICQ to FingersMcSteal Send a message via MSN to FingersMcSteal
Default

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.
FingersMcSteal is offline   Reply With Quote
Old 09-03-2008, 11:02 PM   #3 (permalink)
Forum Novice
 
Tassyon T's Avatar
 
Join Date: Sep 2007
Posts: 367
Default

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);
        }
    }
Basically the compiler is asking you ... "what happens if the mobile is null?"
You haven't put in a return value (true/false) for that.

Last edited by Tassyon T; 09-03-2008 at 11:08 PM.
Tassyon T is offline   Reply With Quote
Old 09-03-2008, 11:05 PM   #4 (permalink)
Forum Expert
 
TheRockstar2253's Avatar
 
Join Date: Sep 2007
Location: Over there
Posts: 1,575
Default

Quote:
Originally Posted by Tassyon T View Post
So... which line is line 90? It would be nice if you posted the whole script.
Line 90 IS the OnDragDrop method. I don't really want to have to post the whole script because this is part of the script creator program I'm working on atm.
TheRockstar2253 is offline   Reply With Quote
Old 09-03-2008, 11:14 PM   #5 (permalink)
Forum Novice
 
Tassyon T's Avatar
 
Join Date: Sep 2007
Posts: 367
Default

Quote:
Originally Posted by TheRockstar2253 View Post
Line 90 IS the OnDragDrop method. I don't really want to have to post the whole script because this is part of the script creator program I'm working on atm.
did you try my code suggestion? I posted the code in an edit on my previous reply.
Tassyon T is offline   Reply With Quote
Old 09-03-2008, 11:21 PM   #6 (permalink)
Forum Expert
 
TheRockstar2253's Avatar
 
Join Date: Sep 2007
Location: Over there
Posts: 1,575
Default

Quote:
Originally Posted by Tassyon T View Post
did you try my code suggestion? I posted the code in an edit on my previous reply.
That did the trick. Thanks for the help I appreciate it man.
TheRockstar2253 is offline   Reply With Quote
Old 09-04-2008, 10:11 PM   #7 (permalink)
Administrator
 
Zippy's Avatar
 
Join Date: Aug 2002
Location: Baltimore, MD
Age: 25
Posts: 4,870
Default

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

Zippy is offline   Reply With Quote
Old 09-05-2008, 01:26 AM   #8 (permalink)
Forum Novice
 
FingersMcSteal's Avatar
 
Join Date: Mar 2006
Location: North East, England, UK
Posts: 865
Send a message via ICQ to FingersMcSteal Send a message via MSN to FingersMcSteal
Default

Quote:
Originally Posted by Zippy View Post
You should indent your code properly, it makes errors like this a lot easier to spot.
yup... me = lazy
__________________
We can be found on joinUO.com or listUO.com, come try us out.
FingersMcSteal is offline   Reply With Quote
Old 09-05-2008, 04:15 AM   #9 (permalink)
Forum Novice
 
Tassyon T's Avatar
 
Join Date: Sep 2007
Posts: 367
Default

Quote:
Originally Posted by FingersMcSteal View Post
yup... me = lazy

uh... not to nit pick, but you == lazy.
Tassyon T is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5