Rumor 2606 Posted February 21, 2014 Share Posted February 21, 2014 quest change_name_item begin state start begin when 71055.use begin say_title("Change of Name List") if pc.is_married() then say("") say("You can't change names when you're married.") say("") return elseif pc.is_polymorphed() then say("") say("You can't change names when you're transformed.") say("") return elseif pc.has_guild() then say("") say("You can't change names when you're in a guild.") say("") return elseif party.is_party() then say("") say("You can't change names when you're in a party.") say("") return elseif pc.get_level() < 80 then say("") say("You can't change names before level 80.") say("") return elseif get_time() < pc.getqf("next_time") then say("") say("You've recently changed your name.") say("You can't change your name right now.") say("") return end say("Please enter the name you want.") local name = pc.name local str = input() local ret = pc.change_name(str) say_title("Change of Name List") if ret == 0 then say("") say("You have not relogged since the last time you") say("changed your name. Please relog now.") say("") char_log(0, "CHANGE_NAME", "HAVE NOT RE-LOGIN") elseif ret == 1 then say("") say("There was a problem. Please try again.") say("") char_log(0, "CHANGE_NAME", "ITEM USE PROBLEM") elseif ret == 2 then say("") say("This name is not available.") say("Please select another name.") say("") char_log(0, "CHANGE_NAME", "CAN NOT USE NAME") elseif ret == 3 then say("") say("This name is not available.") say("Please select another name.") say("") char_log(0, "CHANGE_NAME", "ALREADY USING NAME") elseif ret == 4 then say("") say("Successful name change!") say("You cannot change your name again for") say("another 24 hours.") say("") pc.remove_item("71055", 1) pc.setqf("next_time", get_time() + time_hour_to_sec(24*1)) horse.set_name(""..str"'s Horse") char_log(0, "CHANGE_NAME", "SUCCESS: from "..name.." to "..str) wait() pc.warp(pc.get_x()*100, pc.get_y()*100) else say("") say("Unknown error.") say("Please notify Rumor with this number:") say(ret) say("and he will take a look at the issue.") say("") char_log(0, "CHANGE_NAME", "UNKNOWN NAME") end end end end The players are choosing very long names which can't be typed in a private message window or fully seen on their character. I need to be able to limit their name length somehow. Link to comment Share on other sites More sharing options...
Aveline™ 554 Posted February 21, 2014 Share Posted February 21, 2014 function isLongName(name) return string.len(name) < 16 end local readMe = input() if(isLongName(tostring(readMe)) == false) then print("Your name is very long !...") else print("Your name is not very long.. ") end Regards. 1 Plain logic saves lives. Link to comment Share on other sites More sharing options...
Rumor 2606 Posted February 21, 2014 Author Share Posted February 21, 2014 so I would add the function and local then add the rest with an elseif statement somewhere after line 47 right? Link to comment Share on other sites More sharing options...
Aveline™ 554 Posted February 21, 2014 Share Posted February 21, 2014 so I would add the function and local then add the rest with an elseif statement somewhere after line 47 right? quest change_name_item begin state start begin function isLongName(name) return string.len(name) < 16 end when 71055.use begin say_title("Change of Name List") if pc.is_married() then say("") say("You can't change names when you're married.") say("") return elseif pc.is_polymorphed() then say("") say("You can't change names when you're transformed.") say("") return elseif pc.has_guild() then say("") say("You can't change names when you're in a guild.") say("") return elseif party.is_party() then say("") say("You can't change names when you're in a party.") say("") return elseif pc.get_level() < 80 then say("") say("You can't change names before level 80.") say("") return elseif get_time() < pc.getqf("next_time") then say("") say("You've recently changed your name.") say("You can't change your name right now.") say("") return end say("Please enter the name you want.") local name = pc.name local str = input() if(change_name_item.isLongName(tostring(str)) == false) then say_title("Error 1") say("") --- say("I'm sorry but your name very long") say("and you don't do this. ") return end local ret = pc.change_name(str) say_title("Change of Name List") if ret == 0 then say("") say("You have not relogged since the last time you") say("changed your name. Please relog now.") say("") char_log(0, "CHANGE_NAME", "HAVE NOT RE-LOGIN") elseif ret == 1 then say("") say("There was a problem. Please try again.") say("") char_log(0, "CHANGE_NAME", "ITEM USE PROBLEM") elseif ret == 2 then say("") say("This name is not available.") say("Please select another name.") say("") char_log(0, "CHANGE_NAME", "CAN NOT USE NAME") elseif ret == 3 then say("") say("This name is not available.") say("Please select another name.") say("") char_log(0, "CHANGE_NAME", "ALREADY USING NAME") elseif ret == 4 then say("") say("Successful name change!") say("You cannot change your name again for") say("another 24 hours.") say("") pc.remove_item("71055", 1) pc.setqf("next_time", get_time() + time_hour_to_sec(24*1)) horse.set_name(""..str"'s Horse") char_log(0, "CHANGE_NAME", "SUCCESS: from "..name.." to "..str) wait() pc.warp(pc.get_x()*100, pc.get_y()*100) else say("") say("Unknown error.") say("Please notify Rumor with this number:") say(ret) say("and he will take a look at the issue.") say("") char_log(0, "CHANGE_NAME", "UNKNOWN NAME") end end end end Like this? Plain logic saves lives. Link to comment Share on other sites More sharing options...
Rumor 2606 Posted February 21, 2014 Author Share Posted February 21, 2014 oh I was going to do it this way: quest change_name_item begin state start begin when 71055.use begin say_title("Change of Name List") if pc.is_married() then say("") say("You can't change names when you're married.") say("") return elseif pc.is_polymorphed() then say("") say("You can't change names when you're transformed.") say("") return elseif pc.has_guild() then say("") say("You can't change names when you're in a guild.") say("") return elseif party.is_party() then say("") say("You can't change names when you're in a party.") say("") return elseif pc.get_level() < 80 then say("") say("You can't change names before level 80.") say("") return elseif get_time() < pc.getqf("next_time") then say("") say("You've recently changed your name.") say("You can't change your name right now.") say("") return end say("Please enter the name you want.") function isLongName(name) return string.len(name) < 16 end local name = pc.name local length = input() local str = input() local ret = pc.change_name(str) say_title("Change of Name List") if ret == 0 then say("") say("You have not relogged since the last time you") say("changed your name. Please relog now.") say("") char_log(0, "CHANGE_NAME", "HAVE NOT RE-LOGIN") elseif ret == 1 then say("") say("There was a problem. Please try again.") say("") char_log(0, "CHANGE_NAME", "ITEM USE PROBLEM") elseif ret == 2 then say("") say("This name is not available.") say("Please select another name.") say("") char_log(0, "CHANGE_NAME", "CAN NOT USE NAME") elseif ret == 3 then say("") say("This name is not available.") say("Please select another name.") say("") char_log(0, "CHANGE_NAME", "ALREADY USING NAME") elseif(isLongName(tostring(length)) == false) then say("") say("Your name is too long.") say("Please select another.") say("") char_log(0, "CHANGE_NAME", "NAME TOO LONG") elseif ret == 4 then say("") say("Successful name change!") say("You cannot change your name again for") say("another 24 hours.") say("") pc.remove_item("71055", 1) pc.setqf("next_time", get_time() + time_hour_to_sec(24*1)) horse.set_name(""..str"'s Horse") char_log(0, "CHANGE_NAME", "SUCCESS: from "..name.." to "..str) wait() pc.warp(pc.get_x()*100, pc.get_y()*100) else say("") say("Unknown error.") say("Please notify Rumor with this number:") say(ret) say("and he will take a look at the issue.") say("") char_log(0, "CHANGE_NAME", "UNKNOWN NAME") end end end end Link to comment Share on other sites More sharing options...
Rumor 2606 Posted February 21, 2014 Author Share Posted February 21, 2014 I've got this now quest change_name_item begin state start begin function isLongName(name) return string.len(name) < 16 end when 71055.use begin say_title("Change of Name List") if pc.is_married() then say("") say("You can't change names when you're married.") say("") return elseif pc.is_polymorphed() then say("") say("You can't change names when you're transformed.") say("") return elseif pc.has_guild() then say("") say("You can't change names when you're in a guild.") say("") return elseif party.is_party() then say("") say("You can't change names when you're in a party.") say("") return elseif pc.get_level() < 80 then say("") say("You can't change names before level 80.") say("") return elseif get_time() < pc.getqf("next_time") then say("") say("You've recently changed your name.") say("You can't change your name right now.") say("") return end say("Please enter the name you want.") local name = pc.name local str = input() if(change_name_item.isLongName(tostring(str)) == false) then say_title("Change of Name List") say("") say("The entered name is too long.") say("Please select another name.") say("") char_log(0, "CHANGE_NAME", "NAME TOO LONG") return end local ret = pc.change_name(str) say_title("Change of Name List") if ret == 0 then say("") say("You have not relogged since the last time you") say("changed your name. Please relog now.") say("") char_log(0, "CHANGE_NAME", "HAVE NOT RE-LOGIN") elseif ret == 1 then say("") say("There was a problem. Please try again.") say("") char_log(0, "CHANGE_NAME", "ITEM USE PROBLEM") elseif ret == 2 then say("") say("This name is not avaliable.") say("Please select another name.") say("") char_log(0, "CHANGE_NAME", "CAN NOT USE NAME") elseif ret == 3 then say("") say("This name is not avaliable.") say("Please select another name.") say("") char_log(0, "CHANGE_NAME", "ALREADY USING NAME") elseif ret == 4 then say("") say("Successful name change!") say("You cannot change your name again for") say("another 24 hours.") say("") pc.remove_item("71055", 1) pc.setqf("next_time", get_time() + time_hour_to_sec(24*1)) horse.set_name(""..str"'s Horse") char_log(0, "CHANGE_NAME", "SUCCESS: from "..name.." to "..str) wait() pc.warp(pc.get_x()*100, pc.get_y()*100) else say("") say("Unknown error.") say("Please notify Rumor with this number:") say(ret) say("and he will take a look at the issue.") say("") char_log(0, "CHANGE_NAME", "UNKNOWN NAME") end end end end Link to comment Share on other sites More sharing options...
Developer PACI 921 Posted February 21, 2014 Developer Share Posted February 21, 2014 When you create a function in a questfile, you always have to use it like: quest_name.function_name, otherwise the game will try to find that function, in questlib or in game core. And it'll return nil because that function doesn't exists. All you needed was adding string.len(str) < 16. when you return 0 and server doesn't boot: Link to comment Share on other sites More sharing options...
Rumor 2606 Posted February 21, 2014 Author Share Posted February 21, 2014 When you create a function in a questfile, you always have to use it like: quest_name.function_name, otherwise the game will try to find that function, in questlib or in game core. All you needed was adding string.len(str) < 16. Yeah I know that about functions, I just didn't know how to add this limitation to the scroll. The latest quest I posted should work fine, right? Link to comment Share on other sites More sharing options...
Developer PACI 921 Posted February 21, 2014 Developer Share Posted February 21, 2014 Yes you're right, it should work. 1 when you return 0 and server doesn't boot: Link to comment Share on other sites More sharing options...
Rumor 2606 Posted February 22, 2014 Author Share Posted February 22, 2014 All worked out fine, thankyou. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now