Jump to content
  • 0
Eross

Stylist logout bug

Question

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

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

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

  • 0
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
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 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...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.