Jump to content
  • 0
Sign in to follow this  
Helena

How to add join main in this script?

Question

Hi Hercules,

 

I was wondering if someone could help me. I'm using the following script but I would like @join #main and @channel leave #main to be added into it. It's just difficult because #main doesn't go by on and off.

 

Thanks! Help is much appreciated!

 

header    .@npcname$ = "["+ strnpcinfo(1) +"]";//    dispbottom atcommand_login +""; // debugging    mes .@npcname$;    mes "Hello, "+strcharinfo(0)+"!";    mes "I can permanently enable some commands you often use, this is useful so you won't need to type the commands upon each log in!";	next;    mes .@npcname$;    mes "The setting(s) will remain enabled or disabled until you talk to me again and want me to un-do the change.";    next;    for ( .@i = 0; .@i < .total; .@i++ )        .@menu$ = .@menu$ + .atname$[.@i] +" ["+( ( atcommand_login & 1 << .@i )? "^00BB22On^000000" : "^FF2200Off^000000" )+"] :";    .@s = select( .@menu$ ) -1;    mes .@npcname$;    mes "Status: "+( ( atcommand_login & 1 << .@s )? "^00BB22On^000000" : "^FF2200Off^000000");    next;    mes .@npcname$;	mes "What do you want to do?";    if ( select( "I'd like to "+( ( atcommand_login & 1 << .@s )? "^FF2200disable^000000": "^00BB22enable^000000"  )+" it!", "Nothing." ) == 2 ) {        mes "See ya.";        close;    }    if ( atcommand_login & 1 << .@s ) {        mes .atname$[.@s] +" is now ^FF2200disabled^000000.";        atcommand "@"+ .atcommand$[.@s] +" off";    }    else {        mes .atname$[.@s] +" is now ^00BB22enabled^000000.";        atcommand "@"+ .atcommand$[.@s] +( ( .@s == 1 )? "on": "" );    }    atcommand_login = atcommand_login ^ 1 << .@s;    close;OnPCLoginEvent:    if ( !atcommand_login ) end;    for ( .@i = 0; .@i < .total; .@i++ ) {        if ( atcommand_login & 1 << .@i ) {            atcommand "@"+ .atcommand$[.@i] +( ( .@i == 1 )? " on": "" );            dispbottom .atname$[.@i] +" is now enabled";        }    }    end;OnInit:    setarray .atname$, "- @autoloot", "- @noask", "- @noks", "- @showexp";    setarray .atcommand$, "autoloot", "noask ", "noks", "showexp";    .total = 4;    end;}

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

The way your script is written, there is no proper way to seamlessly inject those specific commands into your script. You'll have to use a less "dynamic" way of enabling/disabling commands to include a toggle in the same script, or create a custom toggle with "on/off" parameters and use it in your script.

 

With this example, you can @main on and @main off (and include the new command in your script!):

 

-	script	at_main	-1,{	OnInit:		bindatcmd "main", strnpcinfo(3) +"::OnCommand", 0, 2;		end;					OnCommand:		if (.@atcmd_parameters$[0] == "on") {			if (!@main) {				atcommand "@join #main";				message strcharinfo(0), "You are now in #main chat.";				@main = 1;			} else {				message strcharinfo(0), "You are already in #main chat.";			}		} else if (.@atcmd_parameters$[0] == "off") {			if (@main) {				atcommand "@channel leave #main";				message strcharinfo(0), "You are no longer in #main chat.";				@main = 0;			} else {				message strcharinfo(0), "You are not in #main chat.";			}		} else {			message strcharinfo(0), "Invalid parameters.";			message strcharinfo(0), .@atcmd_command$ +" failed.";		}				end;}

Share this post


Link to post
Share on other sites
  • 0

Thanks Mumbles that works!

 

Any way to inject a permanent option in it? I.e: @main permaon/permaoff , a function that will keep it enabled or disabled even when you re-log?

 

Thanks :)

Share this post


Link to post
Share on other sites
  • 0

If you just want a permanent option in the command @main (from my script), replace all instances of the variable @main with main. Did that make sense? ;o

 


 

I thought you were aiming to inject the command @main into your existing script, which could be done by modifying your settings a little (I think?):

 

OnInit:	setarray .atname$, "- @autoloot", "- @noask", "- @noks", "- @showexp", "- @main";	setarray .atcommand$, "autoloot", "noask ", "noks", "showexp", "main";	.total = 5;	end;

 

If that's the case, then disregard the first part of this post.

Share this post


Link to post
Share on other sites
  • 0

If you just want a permanent option in the command @main (from my script), replace all instances of the variable @main with main. Did that make sense? ;o

 


 

I thought you were aiming to inject the command @main into your existing script, which could be done by modifying your settings a little (I think?):

 

OnInit:setarray .atname$, "- @autoloot", "- @noask", "- @noks", "- @showexp", "- @main";setarray .atcommand$, "autoloot", "noask ", "noks", "showexp", "main";.total = 5;end;

 

If that's the case, then disregard the first part of this post.

 

Hi Mumbles! Thanks for your help so far. ^^

 

I've tried both methods. For the first one, It doesnt let me make it a permanent command that even stays upon relogging. I've done what you said and edited the script by replacing "@main" with "main" (see below) but alas it doesnt work. >.<

 

 

 -	script	at_main	-1,{OnInit:		bindatcmd "main", strnpcinfo(3) +"::OnCommand", 0, 2;		end;					OnCommand:		if (.@atcmd_parameters$[0] == "on") {			if (!main) {				atcommand "@join #main";				message strcharinfo(0), "You can use the global/main chat system by whispering to '#main'.";				main = 1;			} else {				message strcharinfo(0), "You are already in #main chat.";			}		} else if (.@atcmd_parameters$[0] == "off") {			if (main) {				atcommand "@channel leave #main";				message strcharinfo(0), "You are no longer in #main chat.";				main = 0;			} else {				message strcharinfo(0), "You are not in #main chat. You can join the global/main chat system by typing '@main on'.";			}		} else {			message strcharinfo(0), "Invalid parameters.";			message strcharinfo(0), .@atcmd_command$ +" failed.";		}				end;	}

 

 

 

 

Ive also tried to put the command in the option NPC like you said, but it says "main failed" and then the rest of the failed channel message system, i've tested if it really was by dual clienting, but my character did not receive the #main messages unless i typed the command manually first. Does that mean this cant be done? ]:

Edited by Mumbles
Codeboxed

Share this post


Link to post
Share on other sites
  • 0

Try creating a separate segment of code under OnPCLoginEvent that triggers when the variable main is present.

Share this post


Link to post
Share on other sites
  • 0

Try creating a separate segment of code under OnPCLoginEvent that triggers when the variable main is present.

 

Hi Mumbles. Something like this? (it doesnt work though.. :[)

 

 

-	script	at_main	-1,{	 OnInit:		bindatcmd "main", strnpcinfo(3) +"::OnCommand", 0, 2;		end;					OnCommand:sleep2 100;		 if (.@atcmd_parameters$[0] == "on") {			if (!main) {				atcommand "@join #main";				message strcharinfo(0), "You can use the global/main chat system by whispering to '#main'.";				main = 1;			} else {				message strcharinfo(0), "You are already in #main chat.";			}		} else if (.@atcmd_parameters$[0] == "off") {			if (main) {				atcommand "@channel leave #main";				message strcharinfo(0), "You are no longer in #main chat.";				main = 0;			} else {				message strcharinfo(0), "You are not in #main chat. You can join the global/main chat system by typing '@main on'.";			}		} else {			message strcharinfo(0), "Invalid parameters.";			message strcharinfo(0), .@atcmd_command$ +" failed.";		}				end;	 OnPCLoginEvent:sleep2 500;		if (.@atcmd_parameters$[0] == "on") {			if (!main) {				atcommand "@join #main";				message strcharinfo(0), "You can use the global/main chat system by whispering to '#main'.";				main = 1;			} else {				message strcharinfo(0), "You are already in #main chat.";			}		} else if (.@atcmd_parameters$[0] == "off") {			if (main) {				atcommand "@channel leave #main";				message strcharinfo(0), "You are no longer in #main chat.";				main = 0;			} else {				message strcharinfo(0), "You are not in #main chat. You can join the global/main chat system by typing '@main on'.";			}		} else {			message strcharinfo(0), "Invalid parameters.";			message strcharinfo(0), .@atcmd_command$ +" failed.";		}				end; } 

Share this post


Link to post
Share on other sites
  • 0

 

OnPCLoginEvent:	if (main) {		atcommand "@main on";	}		end;

Something more like this o.o

 

Thank you!

 

That script works perfectly, although, still doesn't work per settings NPC. >.< But thank you either way!

Share this post


Link to post
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.   Restore formatting

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

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