Jump to content
  • 0

Question

13 answers to this question

Recommended Posts

  • 0
Posted
// Written by me, Cydh
// For rathena.org
// Autoload atcommand for players on login

prontera,147,155,5	script	Kafra#saveyouratcmd	4_F_KAFRA4,{
	doevent "autoload_atcommand_main::OnTalk";
}

-	script	script	autoload_atcommand_main	-1,{
	OnTalk:
		mes .npc$;
		mes "Hi, you can select command that auto enable when you login.";
		next;
		switch(select("Select commands","Close")) {
			case 1:
				callsub(OnSelectCommand);
				break;
		}
		close;

		OnSelectCommand:
			mes .npc$;
			mes "Please select command from menu.";
			.@menu$ = "";
			for (.@i = 0; .@i < .CmdListCnt; .@i++) {
				if (callsub(OnCheckCmd,.CmdList$[.@i]) != -1) {
					.@st$ = " - ^33CC33Enabled^000000";
				} else {
					.@st$ = " - ^999999Disabled^000000";
				}
				.@menu$ = .@menu$+":"+.CmdList$[.@i]+" "+.@st$;
			}
			.@menu$ = .@menu$+":Close";
			.@sel = select(.@menu$)-2;
			if (.@sel != .@i) {
				.@idx = callsub(OnCheckCmd,.CmdList$[.@sel]);
				mes "Atcommand ^3399FF"+.CmdList$[.@sel]+"^000000:";
				if (.@idx < 0) { // Enable it
					#AutoAtcommand$[getarraysize(#AutoAtcommand$)] = .CmdList$[.@sel];
					mes "  ^33CC33Auto-enabled on login^000000";
				} else { // Disable it
					callsub(OnClearRemoveCmd,#AutoAtcommand$[.@idx]);
					mes "  ^FF0000Not enabled on login^000000";
				}
				next;
				callsub(OnSelectCommand);
			}
			return;

	OnCheckCmd:
		.@cmd$ = getarg(0);
		for (.@i = 0; .@i < getarraysize(#AutoAtcommand$); .@i++) {
			if (#AutoAtcommand$[.@i] == .@cmd$)
				return .@i;
		}
		return -1;

	OnClearRemoveCmd:
		.@cmd$ = getarg(0);
		.@size = getarraysize(#AutoAtcommand$);
		for (.@i = 0; .@i < .@size; .@i++) {
			if (#AutoAtcommand$[.@i] == .@cmd$)
				break;
		}
		if (.@i != .@size) {
			#AutoAtcommand$[.@i] = "";
			.@j = 0;
			for (.@i = 0; .@i < .@size; .@i++) {
				if (#AutoAtcommand$[.@i] == "")
					continue;
				if (.@i != .@j) {
					#AutoAtcommand$[.@j] = #AutoAtcommand$[.@i];
					#AutoAtcommand$[.@i] = "";
				}
				.@j++;
			}
		}
		return 1;

	OnPCLoginEvent:
		.@j = 0;
		for (.@i = 0; .@i < getarraysize(#AutoAtcommand$); .@i++) {
			if (#AutoAtcommand$[.@i] != "") {
				dispbottom "[ Auto command: "+#AutoAtcommand$[.@i]+" ]";
				atcommand ""+#AutoAtcommand$[.@i]+"";
				.@j++;
			}
		}
		end;

	OnInit:
		.npc$ = "[ Kafra ]";
		setarray .CmdList$[0],"@autoloot","@noks","@showexp";
		.CmdListCnt = getarraysize(.CmdList$);
		end;
}

do something like this if you want to duplicate the npc, split it into 2 NPC scripts are the easiest and less complicated way.

  • 0
Posted


the script is working perfectly.
I believe you may have created many variables in acc_reg_str.
You may have created several variables while editing or testing the npc, it happened to me too.

  • 0
Posted
9 hours ago, Giant Whisper said:

and how do I solve it

Access your sql database.
Go to table acc_reg_str, and delete the autoload regs.

The records appear according to the command name.
Example: #autoloot. You can delete the line.

  • 0
Posted

problem solved my mistake when duplicating

?

//geffen,125,70,4    duplicate(Kafra Settings#saveyouratcmd)    Kafra Settings#saveyouratcmd#1    4_F_KAFRA4
//izlude,139,138,4    duplicate(Kafra Settings#saveyouratcmd)    Kafra Settings#saveyouratcmd#2    4_F_KAFRA4
//prontera,148,201,5    duplicate(Kafra Settings#saveyouratcmd)    Kafra Settings#saveyouratcmd#3    4_F_KAFRA4
//moscovia,216,190,4    duplicate(Kafra Settings#saveyouratcmd)    Kafra Settings#saveyouratcmd#4    4_F_KAFRA4

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...