avertuss 48 Posted July 26, 2018 Share Posted July 26, 2018 Hi. How to use that function in quest? I tried but i always have error in quest compile function pc.make_guild(guild_name, required_money, required_level) --[[to clean non alphanumeric characters]] local guild_name = string.gsub(guild_name, "[^A-Za-z0-9]", "") local guild_len_name = string.len(guild_name) --[[to check wrong sized names]] if not ((2 < guild_len_name) and (guild_len_name < 12)) then say_reward("The name should not have special characters and its length should be between 3-11 characters!") return end --[[to check required level]] if not (pc.get_level() >= required_level) then say_reward(string.format("Level too low. Needed: %d", required_level)) return false end --[[to check required money]] if not (pc.get_gold() >= required_money) then say_reward(string.format("Not enough money. Needed: %d", required_money)) return false end --[[to check already guilded people]] if (pc.hasguild() or pc.isguildmaster()) then say_reward("You're already inside a guild.") return end --[[to add a user-validation check]] say(string.format("Are you sure you wanna create such guild?[ENTER]%s", guild_name)) if select("Yes", "No")==2 then return false end --[[create the guild and process the return value]] local ret = pc.make_guild0(guild_name) if ret==-2 then say_reward("[NO] guild name is invalid (strlen <2 or >11!)") elseif ret==-1 then say_reward("[NO] guild name is invalid (special chars found!)") elseif ret==0 then say_reward("[NO] guild not created (guild name already present or already member of a guild)") elseif ret==1 then pc.change_gold(-required_money) say_reward("[YES] guild created") return true elseif ret==2 then say_reward("[NO] player already part of a guild") elseif ret==3 then say_reward("[NO] player already guild master") end return false end Link to comment Share on other sites More sharing options...
Premium ragem0re 155 Posted July 26, 2018 Premium Share Posted July 26, 2018 pc.make_guild0 requires Marty's source. Link to comment Share on other sites More sharing options...
avertuss 48 Posted July 26, 2018 Author Share Posted July 26, 2018 34 minuty temu, ragem0re napisał: pc.make_guild0 requires Marty's source. I know, i have that function in source but i can't compile quest XD When i just use pc.make_guild0(testguild) it work's but after relog. Link to comment Share on other sites More sharing options...
Premium ragem0re 155 Posted July 26, 2018 Premium Share Posted July 26, 2018 then post your error.. Link to comment Share on other sites More sharing options...
avertuss 48 Posted July 26, 2018 Author Share Posted July 26, 2018 16 minut temu, ragem0re napisał: then post your error.. Ahh sorry, im stupid Error QUEST : new_guild STATE : start guild/new_guild.quest:3:assertion failure : t.token == '(' Abort (core dumped) Quest quest new_guild begin state start begin function pc.make_guild(guild_name, required_money, required_level) --[[to clean non alphanumeric characters]] local guild_name = string.gsub(guild_name, "[^A-Za-z0-9]", "") local guild_len_name = string.len(guild_name) --[[to check wrong sized names]] if not ((2 < guild_len_name) and (guild_len_name < 12)) then say_reward("The name should not have special characters and its length should be between 3-11 characters!") return end --[[to check required level]] if not (pc.get_level() >= required_level) then say_reward(string.format("Level too low. Needed: %d", required_level)) return false end --[[to check required money]] if not (pc.get_gold() >= required_money) then say_reward(string.format("Not enough money. Needed: %d", required_money)) return false end --[[to check already guilded people]] if (pc.hasguild() or pc.isguildmaster()) then say_reward("You're already inside a guild.") return end --[[to add a user-validation check]] say(string.format("Are you sure you wanna create such guild?[ENTER]%s", guild_name)) if select("Yes", "No")==2 then return false end --[[create the guild and process the return value]] local ret = pc.make_guild0(guild_name) if ret==-2 then say_reward("[NO] guild name is invalid (strlen <2 or >11!)") elseif ret==-1 then say_reward("[NO] guild name is invalid (special chars found!)") elseif ret==0 then say_reward("[NO] guild not created (guild name already present or already member of a guild)") elseif ret==1 then pc.change_gold(-required_money) say_reward("[YES] guild created") return true elseif ret==2 then say_reward("[NO] player already part of a guild") elseif ret==3 then say_reward("[NO] player already guild master") end return false end when 20016.chat."new guild" begin local guild_name = input() local required_money = 5435 local required_level = 75 new_guild.pc.make_guild(guild_name, required_money, required_level) end end end Link to comment Share on other sites More sharing options...
Premium ragem0re 155 Posted July 26, 2018 Premium Share Posted July 26, 2018 21 minutes ago, avertuss said: function pc.make_guild(guild_name, required_money, required_level) local guild_name = string.gsub(guild_name, "[^A-Za-z0-9]", "") this seems wrong for me. i don't know about lua functions Link to comment Share on other sites More sharing options...
Bot Metin2 Dev 4883 Posted July 26, 2018 Bot Share Posted July 26, 2018 7 minutes ago, ragem0re said: this seems wrong for me. i don't know about lua functions It seems wrong, but works fine. For example if you write: int x = 7 + 4; in other languages, while running the programm will first add 7+4 and then initialize the sum of it: 11 to the variable x. The same is done in this case I guess. It replaces the given variable with a pattern, so anything else than A-Z, a-z and 0-9 will be replaced with "" and then initializes this "sum" to the local variable guild_name, wich he can use in the further function. King Regards Cyber 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