Eross Posted May 23, 2021 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 [email protected][1], getbattleflag("max_cloth_color"), getbattleflag("max_hair_style"), getbattleflag("max_hair_color"); setarray [email protected][1], LOOK_CLOTHES_COLOR, LOOK_HAIR, LOOK_HAIR_COLOR; set [email protected], select(" ~ Cloth color: ~ Hairstyle: ~ Hair color"); set [email protected], getlook([email protected][[email protected]]); set [email protected],1; while(1) { setlook [email protected][[email protected]], [email protected]; message strcharinfo(0),"This is style #"[email protected]+"."; set [email protected]$, " ~ Next (^0055FF"+(([email protected][email protected][[email protected]])[email protected]+1:1)+"^000000): ~ Previous (^0055FF"+(([email protected]!=1)[email protected]:[email protected][[email protected]])+"^000000): ~ Jump to...: ~ Revert to original (^0055FF"[email protected]+"^000000)"; switch(prompt([email protected]$)) { case 1: set [email protected], (([email protected] != [email protected][[email protected]]) ? [email protected]+1 : 1); break; case 2: set [email protected], (([email protected] != 1) ? [email protected] : [email protected][[email protected]]); break; case 3: message strcharinfo(0),"Choose a style between 1 - "[email protected][[email protected]]+"."; input [email protected],0,[email protected][[email protected]]; if ([email protected]) set [email protected], rand(1,[email protected][[email protected]]); break; case 4: set [email protected], [email protected]; setlook [email protected][[email protected]], [email protected]; break; default: set [email protected], [email protected]; setlook [email protected][[email protected]], [email protected]; end; } } } Quote Link to comment Share on other sites More sharing options...
0 Tokei Posted May 23, 2021 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 [email protected][1], getbattleflag("max_cloth_color"), getbattleflag("max_hair_style"), getbattleflag("max_hair_color"); setarray [email protected][1], LOOK_CLOTHES_COLOR, LOOK_HAIR, LOOK_HAIR_COLOR; set [email protected], select(" ~ Cloth color: ~ Hairstyle: ~ Hair color"); set [email protected], getlook([email protected][[email protected]]); set [email protected],1; @stylist_look_type = [email protected][[email protected]]; @stylist_look_value = getlook(@stylist_look_type); addtimer 1, strnpcinfo(0) + "::OnPCLogoutEvent"; while(1) { setlook [email protected][[email protected]], [email protected]; message strcharinfo(0),"This is style #"[email protected]+"."; set [email protected]$, " ~ Next (^0055FF"+(([email protected][email protected][[email protected]])[email protected]+1:1)+"^000000): ~ Previous (^0055FF"+(([email protected]!=1)[email protected]:[email protected][[email protected]])+"^000000): ~ Jump to...: ~ I want this style"; switch(prompt([email protected]$)) { case 1: set [email protected], (([email protected] != [email protected][[email protected]]) ? [email protected]+1 : 1); break; case 2: set [email protected], (([email protected] != 1) ? [email protected] : [email protected][[email protected]]); break; case 3: message strcharinfo(0),"Choose a style between 1 - "[email protected][[email protected]]+"."; input [email protected],0,[email protected][[email protected]]; if ([email protected]) set [email protected], rand(1,[email protected][[email protected]]); 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 [email protected], [email protected]; setlook [email protected][[email protected]], [email protected]; 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 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 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 [email protected][1], getbattleflag("max_cloth_color"), getbattleflag("max_hair_style"), getbattleflag("max_hair_color"); setarray [email protected][1], LOOK_CLOTHES_COLOR, LOOK_HAIR, LOOK_HAIR_COLOR; set [email protected], select(" ~ Cloth color: ~ Hairstyle: ~ Hair color"); set [email protected], getlook([email protected][[email protected]]); set [email protected],1; @stylist_look_type = [email protected][[email protected]]; @stylist_look_value = getlook(@stylist_look_type); addtimer 1, strnpcinfo(0) + "::OnPCLogoutEvent"; while(1) { setlook [email protected][[email protected]], [email protected]; message strcharinfo(0),"This is style #"[email protected]+"."; set [email protected]$, " ~ Next (^0055FF"+(([email protected][email protected][[email protected]])[email protected]+1:1)+"^000000): ~ Previous (^0055FF"+(([email protected]!=1)[email protected]:[email protected][[email protected]])+"^000000): ~ Jump to...: ~ I want this style"; switch(prompt([email protected]$)) { case 1: set [email protected], (([email protected] != [email protected][[email protected]]) ? [email protected]+1 : 1); break; case 2: set [email protected], (([email protected] != 1) ? [email protected] : [email protected][[email protected]]); break; case 3: message strcharinfo(0),"Choose a style between 1 - "[email protected][[email protected]]+"."; input [email protected],0,[email protected][[email protected]]; if ([email protected]) set [email protected], rand(1,[email protected][[email protected]]); 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 [email protected], [email protected]; setlook [email protected][[email protected]], [email protected]; 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...
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