namerpus18 Posted September 6, 2023 Group: Members Topic Count: 42 Topics Per Day: 0.05 Content Count: 120 Reputation: 11 Joined: 11/15/22 Last Seen: Friday at 11:56 PM Share Posted September 6, 2023 (edited) Good Day everyone, I just need some help, if someone can help me shorten this script. My methods are too limited and i cant find a way to shorten it. Does it improve if i manage to optimize this script? I feel that this script alone takes a lot of checking. Thank you so much, if(getmonsterinfo(killedrid, MOB_MVPEXP) > 1 && isbegin_quest(19000) > 0 || isbegin_quest(19001) > 0 || isbegin_quest(19002) > 0 || isbegin_quest(19003) > 0 || isbegin_quest(19004) > 0 || isbegin_quest(19005) > 0 || isbegin_quest(19006) > 0 || isbegin_quest(19007) > 0 || isbegin_quest(19008) > 0 || isbegin_quest(19009) > 0 || isbegin_quest(19010) > 0 || isbegin_quest(19011) > 0 || isbegin_quest(19012) > 0 || isbegin_quest(19013) > 0 || isbegin_quest(19014) > 0 || isbegin_quest(19015) > 0 || isbegin_quest(19016) > 0 || isbegin_quest(19017) > 0 || isbegin_quest(19018) > 0 || isbegin_quest(19019) > 0 ) { .... } Edited September 6, 2023 by namerpus18 Quote Link to comment Share on other sites More sharing options...
0 Winterfox Posted September 6, 2023 Group: Members Topic Count: 1 Topics Per Day: 0.00 Content Count: 245 Reputation: 93 Joined: 06/30/18 Last Seen: November 27, 2024 Share Posted September 6, 2023 (edited) 25 minutes ago, namerpus18 said: Good Day everyone, I just need some help, if someone can help me shorten this script. My methods are too limited and i cant find a way to shorten it. Does it improve if i manage to optimize this script? I feel that this script alone takes a lot of checking. Thank you so much, if(getmonsterinfo(killedrid, MOB_MVPEXP) > 1 && isbegin_quest(19000) > 0 || isbegin_quest(19001) > 0 || isbegin_quest(19002) > 0 || isbegin_quest(19003) > 0 || isbegin_quest(19004) > 0 || isbegin_quest(19005) > 0 || isbegin_quest(19006) > 0 || isbegin_quest(19007) > 0 || isbegin_quest(19008) > 0 || isbegin_quest(19009) > 0 || isbegin_quest(19010) > 0 || isbegin_quest(19011) > 0 || isbegin_quest(19012) > 0 || isbegin_quest(19013) > 0 || isbegin_quest(19014) > 0 || isbegin_quest(19015) > 0 || isbegin_quest(19016) > 0 || isbegin_quest(19017) > 0 || isbegin_quest(19018) > 0 || isbegin_quest(19019) > 0 ) { .... } It is hard to really optimize the script without knowing the whole code. But to make the snippet you have more manageable, you could organize your code like this: for(.@i = 0; .@i < 20; .@i++) { if(isbegin_quest(19000 + .@i) > 0) { .@has_quest = 1; break; } } if(getmonsterinfo(killedrid, MOB_MVPEXP) > 1 && .@has_quest) { } Edited September 6, 2023 by Winterfox Quote Link to comment Share on other sites More sharing options...
0 namerpus18 Posted September 7, 2023 Group: Members Topic Count: 42 Topics Per Day: 0.05 Content Count: 120 Reputation: 11 Joined: 11/15/22 Last Seen: Friday at 11:56 PM Author Share Posted September 7, 2023 On 9/6/2023 at 8:48 PM, Winterfox said: It is hard to really optimize the script without knowing the whole code. But to make the snippet you have more manageable, you could organize your code like this: I am sorry, I also tried that method but the thing is inside the quote should be a <condition> can be any expression similar to the <condition> in the 'if' command. I am not quite sure if doing for inside it is really possible. Thank you OnInit: questinfo(QTYPE_QUEST),QMARK_YELLOW, "checkquest (11114,HUNTING) == 2 || checkquest (11115,HUNTING) == 2 || checkquest (11116,HUNTING) == 2 || checkquest (11117,HUNTING) == 2 || checkquest (11118,HUNTING) == 2 || checkquest (11119,HUNTING) == 2 || checkquest (11120,HUNTING) == 2 || checkquest (11121,HUNTING) == 2 || checkquest (11122,HUNTING) == 2 || checkquest (11123,HUNTING) == 2"; Quote Link to comment Share on other sites More sharing options...
0 Winterfox Posted September 7, 2023 Group: Members Topic Count: 1 Topics Per Day: 0.00 Content Count: 245 Reputation: 93 Joined: 06/30/18 Last Seen: November 27, 2024 Share Posted September 7, 2023 (edited) 1 hour ago, namerpus18 said: I am sorry, I also tried that method but the thing is inside the quote should be a <condition> can be any expression similar to the <condition> in the 'if' command. I am not quite sure if doing for inside it is really possible. Thank you OnInit: questinfo(QTYPE_QUEST),QMARK_YELLOW, "checkquest (11114,HUNTING) == 2 || checkquest (11115,HUNTING) == 2 || checkquest (11116,HUNTING) == 2 || checkquest (11117,HUNTING) == 2 || checkquest (11118,HUNTING) == 2 || checkquest (11119,HUNTING) == 2 || checkquest (11120,HUNTING) == 2 || checkquest (11121,HUNTING) == 2 || checkquest (11122,HUNTING) == 2 || checkquest (11123,HUNTING) == 2"; You are right, it doesn't seem like you can put anything inside the condition argument of the questinfo function that doesn't return a value directly. It simply evaluates if the result of the script in the conditions string results in true or false, when certain events like the completion of a quest trigger a reevaluation. That means you can only use functions that the script engine knows and that return a value. So what you can do alternatively is to build the condition string dynamically. prontera,150,193,4 script DEMO 124,{ OnInit: setarray(.@quests, 11114, 11115, 11116, 11117, 11118, 11119, 11120, 11121, 11122, 11123); for(.@i = 0; .@i < getarraysize(.@quests); .@i++) .@condition$[.@i] = "checkquest(" + .@quests[.@i] + ", HUNTING) == 2"; questinfo(QTYPE_QUEST, QMARK_YELLOW, implode(.@condition$, "||")); } Edited September 7, 2023 by Winterfox 1 Quote Link to comment Share on other sites More sharing options...
0 namerpus18 Posted September 8, 2023 Group: Members Topic Count: 42 Topics Per Day: 0.05 Content Count: 120 Reputation: 11 Joined: 11/15/22 Last Seen: Friday at 11:56 PM Author Share Posted September 8, 2023 10 hours ago, Winterfox said: You are right, it doesn't seem like you can put anything inside the condition argument of the questinfo function that doesn't return a value directly. It simply evaluates if the result of the script in the conditions string results in true or false, when certain events like the completion of a quest trigger a reevaluation. That means you can only use functions that the script engine knows and that return a value. So what you can do alternatively is to build the condition string dynamically. prontera,150,193,4 script DEMO 124,{ OnInit: setarray(.@quests, 11114, 11115, 11116, 11117, 11118, 11119, 11120, 11121, 11122, 11123); for(.@i = 0; .@i < getarraysize(.@quests); .@i++) .@condition$[.@i] = "checkquest(" + .@quests[.@i] + ", HUNTING) == 2"; questinfo(QTYPE_QUEST, QMARK_YELLOW, implode(.@condition$, "||")); } This method is something new to me, I am not quite familiar specially this "implode" thing so i will read about it and I will try this today. Thank you so much always Quote Link to comment Share on other sites More sharing options...
Question
namerpus18
Good Day everyone,
I just need some help, if someone can help me shorten this script. My methods are too limited and i cant find a way to shorten it.
Does it improve if i manage to optimize this script? I feel that this script alone takes a lot of checking.
Thank you so much,
Link to comment
Share on other sites
4 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.