Jump to content
  • 0

autoload atcommand


Giant Whisper

Question

13 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

// 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.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  70
  • Reputation:   0
  • Joined:  06/19/18
  • Last Seen:  

4 hours ago, Giant Whisper said:

Hello can someone help me with this

screenr-Athena010.jpg

screenr-Athena011.jpg

autoload_atcommand.txt 2.19 kB · 0 downloads

Can you please be specific of the error?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.01
  • Content Count:  233
  • Reputation:   49
  • Joined:  12/20/18
  • Last Seen:  

Use OnInit to save your preferences for account variables.
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  55
  • Topics Per Day:  0.01
  • Content Count:  190
  • Reputation:   3
  • Joined:  04/11/12
  • Last Seen:  

saves them but upon entering they are activated and deactivated as the image shows

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.01
  • Content Count:  233
  • Reputation:   49
  • Joined:  12/20/18
  • Last Seen:  

 
I'm not on a computer to code.

But there is a lack of a 'stop' in your 'OnPCLoginEvent:'

use return at the right time.
Because your script is reading all the 'n' commands of the loop

 

 


 
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.01
  • Content Count:  235
  • Reputation:   63
  • Joined:  04/29/19
  • Last Seen:  


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.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.01
  • Content Count:  235
  • Reputation:   63
  • Joined:  04/29/19
  • Last Seen:  

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.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  55
  • Topics Per Day:  0.01
  • Content Count:  190
  • Reputation:   3
  • Joined:  04/11/12
  • Last Seen:  

already enter and delete the table lines acc_reg_str but the same thing happens even with a new acc

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.01
  • Content Count:  235
  • Reputation:   63
  • Joined:  04/29/19
  • Last Seen:  

On 2/19/2020 at 1:29 PM, Giant Whisper said:

already enter and delete the table lines acc_reg_str but the same thing happens even with a new acc

man, teste the original script please.

autoload_atcommand.txt

I belive that this work's fine.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  55
  • Topics Per Day:  0.01
  • Content Count:  190
  • Reputation:   3
  • Joined:  04/11/12
  • Last Seen:  

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

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