Jump to content
  • 0

Clear arrays every logout


Eross

Question


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

Hi! Im trying to add SAVE LOAD and SELL Style feature on my stylist ... Question, why does all my saved styles get wiped out everytime I logout/login ??? Thanks

prontera,76,96,1	script	Stylist#custom_stylist	122,{
set .@Styles, getbattleflag("max_hair_style");
set .@Look, LOOK_HAIR;
set .@Revert, getlook(.@Look);
set .@Style,1;
set .cost,70000;
set .@SlotName$,"Hair Style";
	@stylist_look_type = .@Look;
	@stylist_look_value = getlook(@stylist_look_type);
	addtimer 1, strnpcinfo(0) + "::OnPCLogoutEvent";
	switch(select("Change Hairstyle:Style collections:Quit")) {	
	case 1:
	while(1) {
		ignoretimeout 1;
		setlook .@Look, .@Style;
		mes "Hair 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;
		}
	}
	case 2:
		while(1) {
			switch(select("Save current hairstyle:Load hairstyle:Sell hairstyle")) {
				case 1:
					mes "Choose which slot you'd like to save to:";
					close2;
					set .@x, select(""+.@SlotName$+" [" +@revert[1]+ "]",
									""+.@SlotName$+" [" +@revert[2]+ "]",
									""+.@SlotName$+" [" +@revert[3]+ "]",		
									""+.@SlotName$+" [" +@revert[4]+ "]",		
									""+.@SlotName$+" [" +@revert[5]+ "]");		
					setarray @revert[.@x], .@Revert;	
					break;
				case 2:
					mes "Choose which slot you'd like to load from:";
					close2;					
					set .@x, select(""+.@SlotName$+" [" +@revert[1]+ "]",
									""+.@SlotName$+" [" +@revert[2]+ "]",
									""+.@SlotName$+" [" +@revert[3]+ "]",		
									""+.@SlotName$+" [" +@revert[4]+ "]",		
									""+.@SlotName$+" [" +@revert[5]+ "]");	
					if (@revert[.@x] == 0) { message strcharinfo(0),"NO SAVED STYLE"; end; }
					setlook LOOK_HAIR, @revert[.@x];
					@stylist_look_type = @stylist_look_value = 0;
					//deltimer strnpcinfo(0) + "::OnPCLogoutEvent";
					break;
				case 3:
					mes "Choose which slot you'd like to sell:";
					close2;					
					set .@x, select(""+.@SlotName$+" [" +@revert[1]+ "]",
									""+.@SlotName$+" [" +@revert[2]+ "]",
									""+.@SlotName$+" [" +@revert[3]+ "]",		
									""+.@SlotName$+" [" +@revert[4]+ "]",		
									""+.@SlotName$+" [" +@revert[5]+ "]");
						if (@revert[.@x] == 0) { message strcharinfo(0),"NO SAVED STYLE"; end; }		
						switch (select("Cofirm:Cancel")) {
							setarray @revert[.@x], "";
						}
					
			}	
		}	
}
	
	end;
OnPCLogoutEvent:
	if (@stylist_look_type != 0) {
		setlook @stylist_look_type, @stylist_look_value;
	}
	
	deltimer strnpcinfo(0) + "::OnPCLogoutEvent";
	end;
}

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Developer
  • Topic Count:  36
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   431
  • Joined:  01/26/16
  • Last Seen:  

You used temporary variable type on the array, that's why.

Link to comment
Share on other sites

  • 0

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

6 hours ago, Secrets said:

You used temporary variable type on the array, that's why.

Thanks for the answer ...Can you help me edit this script to make permanent per character ??? thankyou 

 

I actually copied some lines from this script and its kinda weird that this npc can save datas while mine cant 

Quote

prontera,77,99,3    script    Stylist    122,{

    set .@name$,"[^FF8000Stylist^000000]";
    setarray .@max[1],553,251,48;        // Number of cloths, haircolors, hairstyles in client
    setarray .@blacklist[0],188,143,261;    // NPC will skip any cloth colors in this array.
                                        //      Use for palettes that cause errors or just plain look bad.
                                        //        Leave first value at 0 to disable.
    setarray .@type[1],7,6,1;            // DO NOT EDIT
    set .@style,0;
    
    mes .@name$;
    mes "I can change your appearance for you if you'd like.";
    mes " ";
    mes "Just choose what you'd like to change:";
    next;
    set .@s,select("Clothes color",
                "Hair color",
                "Hair style");
    
    mes .@name$;
    mes "Alright, how would you like to search?";
    next;
    menu "Start at the beginning",L_start,
        "Choose where to start",-;
    
    // CHOOSE WHERE TO START =====================================================
    mes .@name$;
    mes "Alright, choose a style between ^0000FF0 and " +.@max[.@s]+ "^000000.";
    next;
    input .@style;
    
    if (.@style < 0 || .@style > .@max[.@s]) {
        mes .@name$;
        mes "Style chosen is out of range.";
        close;
    }

  L_start:
    setarray @revert[1],getlook(.@type[.@s]),0,0;
    mes .@name$;
    mes "Alright here we go, starting at style ^007700" +.@style+ "^000000.";
    next;
    
  // BEGINNING OF STYLE MENU LOOP ================================================
  L_menuloop:
    if (.@blacklist[0]) {
        for (set .@f,0; .@f < getarraysize(.@blacklist); set .@f,.@f+1) {
            if (.@style == .@blacklist[.@f] && .@previous == 1 && .@s == 1) {
                message strcharinfo(0),"GM Message - Cloth " +.@style+ " was removed.";
                set .@style, .@style - 1;
                goto L_menuloop;
            } else if (.@style == .@blacklist[.@f] && .@s == 1) {
                message strcharinfo(0),"GM Message - Cloth " +.@style+ " was removed.";
                set .@style, .@style +1;
                goto L_menuloop;
            }
        }
    }
    setlook .@type[.@s],.@style;
    mes "This is style number ^007700" +.@style+ "^000000.";
    
    set .@next, .@style + 1;
    set .@prev, .@style - 1;
    
    // MAXIMUM MENU
    if (.@style == .@max[.@s]) {
        set .@next,0;
        message strcharinfo(0),"Limit Reached";
    }
    
    // MINIMUM MENU ==============================================================
    if (.@style == 0) {
        set .@prev,.@max[.@s];
        message strcharinfo(0),"Beginning Reached";
    }
    
    // PREVIOUS MENU =============================================================
    if (.@previous) {
        menu "^FF0000Previous - " +.@prev+ "^000000",L_prev,
            "^0000FFNext - " +.@next+ "^000000",L_next,
            "Jump to",L_jump,
            "Save",L_save,
            "Load",L_load;
    }
    
    // DEFAULT MENU ==============================================================
    menu "^0000FFNext - " +.@next+ "^000000",L_next,
        "^FF0000Previous - " +.@prev+ "^000000",L_prev,
        "Jump to",L_jump,
        "Save",L_save,
        "Load",L_load;
        
  L_next:
    set .@previous,0;
    set .@style, .@next;
    goto L_menuloop;

  L_prev:
    set .@previous,1;
    set .@style, .@prev;
    goto L_menuloop;
    
  L_jump:
    next;
    mes .@name$;
    mes "Choose which style you'd like to jump to:";
    next;
    input .@style;
    if (.@style < 0 || .@style > .@max[.@s]) {
        mes .@name$;
        mes "Style chosen is out of range.";
        close;
    }
    goto L_menuloop;
    
  L_save:
    next;
    mes .@name$;
    mes "Choose which slot you'd like to save to:";
    set .@x, select("Slot 1 - [" +@revert[1]+ "]",
                    "Slot 2 - [" +@revert[2]+ "]",
                    "Slot 3 - [" +@revert[3]+ "]");
                    
    setarray @revert[.@x], .@style;
    goto L_menuloop;
    
  L_load:
    next;
    mes .@name$;
    mes "Choose which slot you'd like to load from:";
    set .@x, select("Slot 1 - [" +@revert[1]+ "]",
                    "Slot 2 - [" +@revert[2]+ "]",
                    "Slot 3 - [" +@revert[3]+ "]");
                    
    set .@style, @revert[.@x];
    goto L_menuloop;
}

 

 

[FIXED] ~ (I guess?)

 I changed all the 

@revert

into

revert

 

                    mes "Choose which slot you'd like to save to:";
                    close2;
                    set .@x, select(""+.@SlotName$+" [" +revert[1]+ "]",
                                    ""+.@SlotName$+" [" +revert[2]+ "]",
                                    ""+.@SlotName$+" [" +revert[3]+ "]",        
                                    ""+.@SlotName$+" [" +revert[4]+ "]",        
                                    ""+.@SlotName$+" [" +revert[5]+ "]");        
                    setarray revert[.@x], .@Revert;    
                    break;

 

~~~ 

Edited by Origami
[FIXED] ~ (I guess?)
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...