[Question]Bloody hell

02/11/2013 02:16 nushizu#1
Code:
def npc(Client, Option):
    if(Option == 0):
        Text("Well " + Client.Name + " heading to the Isle of Specialists?" )
        Link("Yeah.", 1)
        Link("Not this time.", 255)
    if(Option == 1):
        Text("Enjoy your stay there.")        
        Link("I will, thanks.", 255)
        Teleport(088, 038, 1010, Client)
        Finish()
    return 0
So this is an NPC (obviously for teleportation) that I'm making whom will be in all cities and shit.

Code:
def npc(Client, Option):
    if(Option == 0):
        Text("Hey, " + Client.Name + " you are looking to go to the North Marsh?")
        if(Client.Level > 90):
            Text("It appears you are indeed strong enough to go. Are you ready?")
            Link("Lets do this.", 1)
            Link("On second thought...", 255)
        else:
            Text("You're not ready for what lies beyond, are you sure you want to go?")
            Link("I'll take my chances.", 2 )
            Link( "You're probably right, I'll come back.." , 255 )
        Finish()
    if(Option == 1):
        Text("Best of luck, and be careful.")
        Teleport(824, 571, 1015, Client)
    if(Option == 2):
        Text("As you wish, be careful." )
        Teleport(824, 571, 1015, Client)
        Link("Sweet.", 255)
        Finish()
    return 0
is one I already made, the first is giving me an error the second isn't. anyone seeing an error I'm not? fresh eyes and all that shit
02/11/2013 02:42 go for it#2
i duno what programming language is that written at but here is some points that should fuck this code up
you should better use switch or at least a if else with a braces "{}"
the second one is working just because when it match the if it continue to the rest of that case (the normal code flow) , personally this way is so fucked up and make it even harder to trace
maybe you should try something like

Code:
def npc(Client, Option):
switch(option)
{
case 0:
{
        Text("Hey, " + Client.Name + " you are looking to go to the North Marsh?");
if(Client.Level > 90):
{
            Text("It appears you are indeed strong enough to go. Are you ready?");
            Link("Lets do this.", 1);
            Link("On second thought...", 255);
}
else
{
            Text("You're not ready for what lies beyond, are you sure you want to go?");
            Link("I'll take my chances.", 2 );
            Link( "You're probably right, I'll come back.." , 255 );
}
        Finish();
break;
}

case 1:
{
        Text("Best of luck, and be careful.");
        Teleport(824, 571, 1015, Client);
        Finish();
break;
}

case 2:
{
        Text("As you wish, be careful." );
        Teleport(824, 571, 1015, Client);
        Link("Sweet.", 255);
        Finish();
break;
}
}
maybe you can even merge case 1/2 with a level check

Code:
def npc(Client, Option):
switch(option)
{
case 0:
{
        Text("Hey, " + Client.Name + " you are looking to go to the North Marsh?");
if(Client.Level > 90):
{
            Text("It appears you are indeed strong enough to go. Are you ready?");
            Link("Lets do this.", 1);
            Link("On second thought...", 255);
}
else
{
            Text("You're not ready for what lies beyond, are you sure you want to go?");
            Link("I'll take my chances.", 1 );
            Link( "You're probably right, I'll come back.." , 255 );
}
        Finish();
break;
}

case 1:
{
if(Client.Level > 90):
{
        Text("Best of luck, and be careful.");
        Teleport(824, 571, 1015, Client);
        Finish();
}
else
{
        Text("As you wish, be careful." );
        Teleport(824, 571, 1015, Client);
        Link("Sweet.", 255);
        Finish();
}
break;
}
}
you should run the project from visual studio , add break point there and see the code flow and you should understand what's wrong
02/11/2013 03:06 _DreadNought_#3
PHP Code:
def npc(ClientOption):
    if(
Option == 0):
        
Text("Well " Client.Name " heading to the Isle of Specialists?" )
        
Link("Yeah."1)
        
Link("Not this time."255)
        
Finish()
    if(
Option == 1):
        
Text("Enjoy your stay there.")        
        
Link("I will, thanks."255)
        
Teleport(0880381010Client)
        
Finish()
    return 

fixed, you forgot Finish() in first case
02/11/2013 03:14 nushizu#4
I figured it out, the error was with the coordinates. you can't use "088, 038, 1010" it would have to be written "88, 38, 1010" thanks though