Blockland Forums > Modification Help
client-side activation/deactivation
<< < (2/3) > >>
TripleNickels:
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: ---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);
}

--- End code ---
lilboarder32:

--- Quote from: TripleNickels on April 20, 2011, 11:40:41 PM ---No. It depends on if he wants it serverside or clientside. Since he said /command, I assume he means serverside.


--- Code: ---function serverCmdPackageOn(%c)
{
if(%c.isSuperAdmin)
activatePackage(yourPackage);
}
function serverCmdPackageOff(%c)
{
if(%c.isSuperAdmin)
deactivatePackage(yourPackage);
}

--- End code ---

--- End quote ---
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.
TripleNickels:

--- Quote from: lilboarder32 on April 21, 2011, 01:08:00 AM ---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.

--- End quote ---
Wow, sorry. I missed that. I feel like MegaScience. Fixed my post.
tylerk196:
ok this is my first add-on could you explain to me a little simpler what to do?
TripleNickels:

--- Quote from: tylerk196 on April 21, 2011, 02:40:27 AM ---ok this is my first add-on could you explain to me a little simpler what to do?

--- End quote ---
Is this your chatbot add-on that you made a topic about earlier? If so, add this to the end of your code:


--- Code: ---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);
}

--- End code ---

Then use /chatbotOn and /chatbotOff to toggle your chatbot.
Navigation
Message Index
Next page
Previous page

Go to full version