Eross Posted May 23, 2021 Group: Members Topic Count: 166 Topics Per Day: 0.09 Content Count: 377 Reputation: 12 Joined: 04/05/20 Last Seen: 18 hours ago Share Posted May 23, 2021 Hi ,how to make this script revert all styles when player tries to bug it using ALT+F4 ???? Quote //===== rAthena Script ======================================= //= Stylist //===== By: ================================================== //= Euphy //===== Current Version: ===================================== //= 1.1 //===== Compatible With: ===================================== //= rAthena Project //===== Description: ========================================= //= Changes your hair style, hair color, and cloth color. //===== Additional Comments: ================================= //= 1.0 Initial script. //= 1.1 Switched to 'getbattleflag', credits to Saithis. [Euphy] //============================================================ prontera,76,96,1 script Stylist#custom_stylist 122,{ setarray .@Styles[1], getbattleflag("max_cloth_color"), getbattleflag("max_hair_style"), getbattleflag("max_hair_color"); setarray .@Look[1], LOOK_CLOTHES_COLOR, LOOK_HAIR, LOOK_HAIR_COLOR; set .@s, select(" ~ Cloth color: ~ Hairstyle: ~ Hair color"); set .@Revert, getlook(.@Look[.@s]); set .@Style,1; while(1) { setlook .@Look[.@s], .@Style; message strcharinfo(0),"This is style #"+.@Style+"."; set .@menu$, " ~ Next (^0055FF"+((.@Style!=.@Styles[.@s])?.@Style+1:1)+"^000000): ~ Previous (^0055FF"+((.@Style!=1)?.@Style-1:.@Styles[.@s])+"^000000): ~ Jump to...: ~ Revert to original (^0055FF"+.@Revert+"^000000)"; switch(prompt(.@menu$)) { case 1: set .@Style, ((.@Style != .@Styles[.@s]) ? .@Style+1 : 1); break; case 2: set .@Style, ((.@Style != 1) ? .@Style-1 : .@Styles[.@s]); break; case 3: message strcharinfo(0),"Choose a style between 1 - "+.@Styles[.@s]+"."; input .@Style,0,.@Styles[.@s]; if (!.@Style) set .@Style, rand(1,.@Styles[.@s]); break; case 4: set .@Style, .@Revert; setlook .@Look[.@s], .@Revert; break; default: set .@Style, .@Revert; setlook .@Look[.@s], .@Revert; end; } } } Quote Link to comment Share on other sites More sharing options...
0 Tokei Posted May 23, 2021 Group: Members Topic Count: 16 Topics Per Day: 0.00 Content Count: 696 Reputation: 722 Joined: 11/12/12 Last Seen: 10 hours ago Share Posted May 23, 2021 (edited) You have a few ways of doing that. Your script doesn't cover all possible abusable ways even with logout. It is possible to cancel a script without logging out. One trick is to "abuse" the addtimer behavior. While a script is running, the timed event will not run until the current script is finished (it is queued). As for the logging out issue, you can simply use OnPCLogoutEvent. One drawback from this is that you need to delete the timer as otherwise it will revert whenever you exit the NPC. So I added another menu option to confirm your style, " ~ I want this style". I'd probably remove the " ~ Revert to original" if I were you as it's not needed at all. Cancelling will do that for you and that way you can keep 4 menu options and keep things clean. prontera,76,96,1 script Stylist#custom_stylist 122,{ setarray .@Styles[1], getbattleflag("max_cloth_color"), getbattleflag("max_hair_style"), getbattleflag("max_hair_color"); setarray .@Look[1], LOOK_CLOTHES_COLOR, LOOK_HAIR, LOOK_HAIR_COLOR; set .@s, select(" ~ Cloth color: ~ Hairstyle: ~ Hair color"); set .@Revert, getlook(.@Look[.@s]); set .@Style,1; @stylist_look_type = .@Look[.@s]; @stylist_look_value = getlook(@stylist_look_type); addtimer 1, strnpcinfo(0) + "::OnPCLogoutEvent"; while(1) { setlook .@Look[.@s], .@Style; message strcharinfo(0),"This is style #"+.@Style+"."; set .@menu$, " ~ Next (^0055FF"+((.@Style!=.@Styles[.@s])?.@Style+1:1)+"^000000): ~ Previous (^0055FF"+((.@Style!=1)?.@Style-1:.@Styles[.@s])+"^000000): ~ Jump to...: ~ I want this style"; switch(prompt(.@menu$)) { case 1: set .@Style, ((.@Style != .@Styles[.@s]) ? .@Style+1 : 1); break; case 2: set .@Style, ((.@Style != 1) ? .@Style-1 : .@Styles[.@s]); break; case 3: message strcharinfo(0),"Choose a style between 1 - "+.@Styles[.@s]+"."; input .@Style,0,.@Styles[.@s]; if (!.@Style) set .@Style, rand(1,.@Styles[.@s]); break; case 4: // You have to set the values to 0 and remove the timer event once the colors are chosen and confirmed // Your code currently doesn't have a way out of your loops, so I added this one. @stylist_look_type = @stylist_look_value = 0; deltimer strnpcinfo(0) + "::OnPCLogoutEvent"; end; default: set .@Style, .@Revert; setlook .@Look[.@s], .@Revert; end; } } end; OnPCLogoutEvent: if (@stylist_look_type != 0) { setlook @stylist_look_type, @stylist_look_value; } deltimer strnpcinfo(0) + "::OnPCLogoutEvent"; end; } Edited May 23, 2021 by Tokei 1 Quote Link to comment Share on other sites More sharing options...
0 Chaos92 Posted May 23, 2021 Group: Members Topic Count: 49 Topics Per Day: 0.01 Content Count: 1826 Reputation: 288 Joined: 08/03/12 Last Seen: 1 hour ago Share Posted May 23, 2021 1 hour ago, Origami said: Hi ,how to make this script revert all styles when player tries to bug it using ALT+F4 ???? What do you mean by bug it using alt+f4 ? Alt+f4 close the client right. Quote Link to comment Share on other sites More sharing options...
0 Eross Posted May 24, 2021 Group: Members Topic Count: 166 Topics Per Day: 0.09 Content Count: 377 Reputation: 12 Joined: 04/05/20 Last Seen: 18 hours ago Author Share Posted May 24, 2021 (edited) 1 hour ago, Tokei said: You have a few ways of doing that. Your script doesn't cover all possible abusable ways even with logout. It is possible to cancel a script without logging out. One trick is to "abuse" the addtimer behavior. While a script is running, the timed event will not run until the current script is finished (it is queued). As for the logging out issue, you can simply use OnPCLogoutEvent. One drawback from this is that you need to delete the timer as otherwise it will revert whenever you exit the NPC. So I added another menu option to confirm your style, " ~ I want this style". I'd probably remove the " ~ Revert to original" if I were you as it's not needed at all. Cancelling will do that for you and that way you can keep 4 menu options and keep things clean. prontera,76,96,1 script Stylist#custom_stylist 122,{ setarray .@Styles[1], getbattleflag("max_cloth_color"), getbattleflag("max_hair_style"), getbattleflag("max_hair_color"); setarray .@Look[1], LOOK_CLOTHES_COLOR, LOOK_HAIR, LOOK_HAIR_COLOR; set .@s, select(" ~ Cloth color: ~ Hairstyle: ~ Hair color"); set .@Revert, getlook(.@Look[.@s]); set .@Style,1; @stylist_look_type = .@Look[.@s]; @stylist_look_value = getlook(@stylist_look_type); addtimer 1, strnpcinfo(0) + "::OnPCLogoutEvent"; while(1) { setlook .@Look[.@s], .@Style; message strcharinfo(0),"This is style #"+.@Style+"."; set .@menu$, " ~ Next (^0055FF"+((.@Style!=.@Styles[.@s])?.@Style+1:1)+"^000000): ~ Previous (^0055FF"+((.@Style!=1)?.@Style-1:.@Styles[.@s])+"^000000): ~ Jump to...: ~ I want this style"; switch(prompt(.@menu$)) { case 1: set .@Style, ((.@Style != .@Styles[.@s]) ? .@Style+1 : 1); break; case 2: set .@Style, ((.@Style != 1) ? .@Style-1 : .@Styles[.@s]); break; case 3: message strcharinfo(0),"Choose a style between 1 - "+.@Styles[.@s]+"."; input .@Style,0,.@Styles[.@s]; if (!.@Style) set .@Style, rand(1,.@Styles[.@s]); break; case 4: // You have to set the values to 0 and remove the timer event once the colors are chosen and confirmed // Your code currently doesn't have a way out of your loops, so I added this one. @stylist_look_type = @stylist_look_value = 0; deltimer strnpcinfo(0) + "::OnPCLogoutEvent"; end; default: set .@Style, .@Revert; setlook .@Look[.@s], .@Revert; end; } } end; OnPCLogoutEvent: if (@stylist_look_type != 0) { setlook @stylist_look_type, @stylist_look_value; } deltimer strnpcinfo(0) + "::OnPCLogoutEvent"; end; } Thankyou sir @Tokei ! Youve saved me again ! ^_^ ... Another on sir,, How about when a player succesfully paid for a style ,for example Hairstyle #1 .. That style will be marked at (PURCHASED STYLE) and whenever he/she wants to use that style , the NPC will not ask for payment anymore .. sir @Chaos92 yes exactly sir ... Edited May 24, 2021 by Origami add'l question Quote Link to comment Share on other sites More sharing options...
Question
Eross
Hi ,how to make this script revert all styles when player tries to bug it using ALT+F4 ????
Link to comment
Share on other sites
3 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.