Shoutbox

{help please} script disable - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: {help please} script disable (/showthread.php?tid=66346)

{help please} script disable by skyserpent on 09-17-2006 at 01:40 AM

what code can i add to my script so that when i send start! it enables the script and when i send stop! it disables the script

thanks for any help

oh and i would like the script to always start disabled


RE: {help please} script disable by NanaFreak on 09-17-2006 at 01:53 AM

ok here you go

code:
var started = 0;
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message)
{
 
if(started==0)
  {
   
if(Message=='start!')
    {
      started=1;
      //code here for when started
    }
   
if(Message=='stop!')
    {
      ChatWnd.SendMessage('not started');
    }
  }
 
else if(started==1)
  {
   
if(Message=='stop!')
    {
      started=0;
      //code here for diabled
    }
   
if(Message=='start!')
    {
      ChatWnd.SendMessage('already started');
    }
  }
}

fixed the start! stop! codes

fix my code (i had mesage not message)

added some colour to help you out

RE: {help please} script disable by phalanxii on 09-17-2006 at 01:55 AM

I'm not the most efficient of programmers, but one way to do it is:

code:
var ScriptEnabled = false;

function OnEvent_ChatWndSendMessage(ChatWnd, Message) {
   if(Message == "start!") ScriptEnabled = true;
   if(Message == "stop!") ScriptEnabled = false;
}

function <your function>(<your parameters>) {
   if(ScriptEnabled) {
      ... //Code goes in here
   }
}
You will need to repeat the last function for every function in your script.
RE: {help please} script disable by skyserpent on 09-17-2006 at 02:01 AM

help me with "function <your function>(<your parameters>)" please


RE: RE: {help please} script disable by phalanxii on 09-17-2006 at 02:06 AM

quote:
Originally posted by skyserpent
help me with "function <your function>(<your parameters>)" please

What is the name of the function(s) in your script? For example, if my script has a function called FindAddress with parameters First, Second, Offset, it will appear in my script as:
code:
function FindAddress(First, Second, Offset) {
   x = First + Second - Offset;
}
So if I want to integrate this with the script enabled, I simply have to change it to:
code:
function FindAddress(First, Second, Offset) {
   if(ScriptEnabled) {
      x = First + Second - Offset;
   }
}

RE: {help please} script disable by skyserpent on 09-17-2006 at 02:25 AM

everything is sorted

thanks buddies