Author Topic: client-side activation/deactivation  (Read 1277 times)

I'm working on a client-side mod, but because of what it dose I need a way to activate/deactivate it. How would i do that?

Put everything inside a package, even unique functions. The only thing outside the package should be the on/off switch.

deactivatePackage(packageName);

Did you want to open and close a GUI window or to disable the whole script? If you're disabling the whole thing, look at what Iban said.

You can open the GUI with canvas.pushDialog(GuiNameOrID); and you can close it with canvas.popDialog(GuiNameOrID);.

OK its all in a package how would i make a chat command like /on or /off?

Code: [Select]
function clientCmdpackageon()
{
   activatePackage(example)
};

function clientCmdpackageoff()
{
   deactivatePackage(example)
};

package (example)


I think.
Replace packageon and packageoff with the command you want and replace example with your package name.
« Last Edit: April 20, 2011, 11:23:10 PM by Daenth »

Clientside /commands are enabled by using a special type of add-on that doesn't do anything on its own, but enables you to use extra functionality added by this mod. Truce's client command mod enables this, so credit to him for the code.

Code: [Select]
package clCmd {
function NMH_Type::send(%chat) {
%msg=%chat.getValue();
%wrd=firstWord(%msg);
%cmd="clCmd"@getSubStr(%wrd,1,strLen(%wrd));
if(getSubStr(%msg,0,1)$="/"&&isFunction(%cmd)) {
%eval="call(%cmd,";
for(%i=1;%i<getWordCount(%msg);%i++)
%eval=%eval@"\""@getWord(%msg,%i)@"\",";
%eval=getSubStr(%eval,0,strLen(%eval)-1)@");";
eval(%eval);
%chat.setValue("");
}
Parent::send(%chat);
}
};
activatePackage(clCmd);

function clCmdPackageOn(%c)
{
activatePackage(yourPackage);
}
function clCmdPackageOff(%c)
{
deactivatePackage(yourPackage);
}
« Last Edit: April 21, 2011, 01:14:51 AM by TripleNickels »

No. It depends on if he wants it serverside or clientside. Since he said /command, I assume he means serverside.

Code: [Select]
function serverCmdPackageOn(%c)
{
if(%c.isSuperAdmin)
activatePackage(yourPackage);
}
function serverCmdPackageOff(%c)
{
if(%c.isSuperAdmin)
deactivatePackage(yourPackage);
}
Yet the topic says "client-side". I think he wants client-sided slash commands, which Truce wrote up a long time ago and you can probably find it by searching. It called clCmdFunctionName() I'm pretty sure.

Yet the topic says "client-side". I think he wants client-sided slash commands, which Truce wrote up a long time ago and you can probably find it by searching. It called clCmdFunctionName() I'm pretty sure.
Wow, sorry. I missed that. I feel like MegaScience. Fixed my post.
« Last Edit: April 21, 2011, 01:16:06 AM by TripleNickels »

ok this is my first add-on could you explain to me a little simpler what to do?

ok this is my first add-on could you explain to me a little simpler what to do?
Is this your chatbot add-on that you made a topic about earlier? If so, add this to the end of your code:

Code: [Select]
package clCmd {
function NMH_Type::send(%chat) {
%msg=%chat.getValue();
%wrd=firstWord(%msg);
%cmd="clCmd"@getSubStr(%wrd,1,strLen(%wrd));
if(getSubStr(%msg,0,1)$="/"&&isFunction(%cmd)) {
%eval="call(%cmd,";
for(%i=1;%i<getWordCount(%msg);%i++)
%eval=%eval@"\""@getWord(%msg,%i)@"\",";
%eval=getSubStr(%eval,0,strLen(%eval)-1)@");";
eval(%eval);
%chat.setValue("");
}
Parent::send(%chat);
}
};
activatePackage(clCmd);

function clCmdChatbotOn(%c)
{
activatePackage(chatbot);
}
function clCmdChatbotOff(%c)
{
deactivatePackage(chatbot);
}

Then use /chatbotOn and /chatbotOff to toggle your chatbot.
« Last Edit: April 21, 2011, 06:15:02 AM by TripleNickels »

thanks so much every one