Jump to content
  • 0

Stylist logout bug


Eross

Question


  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.10
  • Content Count:  349
  • Reputation:   12
  • Joined:  04/05/20
  • Last Seen:  

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;            
        }
    }
}

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  667
  • Reputation:   675
  • Joined:  11/12/12
  • Last Seen:  

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 by Tokei
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  49
  • Topics Per Day:  0.01
  • Content Count:  1609
  • Reputation:   247
  • Joined:  08/03/12
  • Last Seen:  

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.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.10
  • Content Count:  349
  • Reputation:   12
  • Joined:  04/05/20
  • Last Seen:  

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 by Origami
add'l question
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...