Code (text): ({ beforeChatMessage: function(src, message) { if (sys.auth(src) < 2 && getVal('muted' + ip(src)) == true) { sys.stopEvent(); sys.sendMessage(src, "Bot: you are muted!"); return; } unmute : function(user) { setVal('muted' + ip(user)) = false; return; } , init : function() if ((message[0] == '/' || message[0] == '!') && message.length > 1) { print("Command -- " + sys.name(src) + ": " + message); sys.stopEvent(); var command; var commandData; var pos = message.indexOf(' '); if (pos != -1) { command = message.substring(1, pos).toLowerCase(); commandData = message.substr(pos+1); } else { command = message.substr(1).toLowerCase(); } var tar = sys.id(commandData); } /** Moderator Commands **/ if (sys.auth(src) < 1) { sys.sendMessage(src, "CommandBot: The command " + command + " can not be used by users."); return; } if (command == "mute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) { sys.sendMessage("Bot: you dont have sufficient auth to mute " + commandData + "."); return; } sys.sendAll("Bot: " + commandData + " was muted by " + sys.name(src) + "!"); muted[tar] = true; return } } if (command == "ummute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) { sys.sendMessage("Bot: you dont have sufficient auth to unmute " + commandData + "."); return; } sys.sendAll("Bot: " + commandData + " was unmuted by " + sys.name(src) + "!"); this.unmute(tar); return } }) It keeps giving me errors, I cant figure out how to make it work. x.x Im a noob at this x.x
you stuck : Code (text): unmute : function(user) { setVal('muted' + ip(user)) = false; return; } , init : function() in the middle of the "beforeChatMessage" function! You need to put that after! Also 'init: function()': --> There's no body to that function!! You might as well remove that line.
I tried, it failed; Code (text): ({ unmute : function(user){ saveVal('muted' + ip(user)) = false; return; { , beforeChatMessage: function(src, message) { if (sys.auth(src) < 2 && getVal('muted' + ip(src)) == true) { sys.stopEvent(); sys.sendMessage(src, "Bot: you are muted!"); return; } , init : function() if ((message[0] == '/' || message[0] == '!') && message.length > 1) { print("Command -- " + sys.name(src) + ": " + message); sys.stopEvent(); var command; var commandData; var pos = message.indexOf(' '); if (pos != -1) { command = message.substring(1, pos).toLowerCase(); commandData = message.substr(pos+1); } else { command = message.substr(1).toLowerCase(); } var tar = sys.id(commandData); } /** Moderator Commands **/ if (sys.auth(src) < 1) { sys.sendMessage(src, "CommandBot: The command " + command + " can not be used by users."); return; } if (command == "mute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) { sys.sendMessage("Bot: you dont have sufficient auth to mute " + commandData + "."); return; } sys.sendAll("Bot: " + commandData + " was muted by " + sys.name(src) + "!"); muted[tar] = true; return } } if (command == "ummute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) { sys.sendMessage("Bot: you dont have sufficient auth to unmute " + commandData + "."); return; } sys.sendAll("Bot: " + commandData + " was unmuted by " + sys.name(src) + "!"); this.unmute(tar); return } })
I took it out. Code (text): ({ unmute : function(user){ saveVal('muted' + ip(user)) = false; return; { beforeChatMessage: function(src, message) { if (sys.auth(src) < 2 && getVal('muted' + ip(src)) == true) { sys.stopEvent(); sys.sendMessage(src, "Bot: you are muted!"); return; } if ((message[0] == '/' || message[0] == '!') && message.length > 1) { print("Command -- " + sys.name(src) + ": " + message); sys.stopEvent(); var command; var commandData; var pos = message.indexOf(' '); if (pos != -1) { command = message.substring(1, pos).toLowerCase(); commandData = message.substr(pos+1); } else { command = message.substr(1).toLowerCase(); } var tar = sys.id(commandData); } /** Moderator Commands **/ if (sys.auth(src) < 1) { sys.sendMessage(src, "CommandBot: The command " + command + " can not be used by users."); return; } if (command == "mute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) { sys.sendMessage("Bot: you dont have sufficient auth to mute " + commandData + "."); return; } sys.sendAll("Bot: " + commandData + " was muted by " + sys.name(src) + "!"); muted[tar] = true; return } } if (command == "ummute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) { sys.sendMessage("Bot: you dont have sufficient auth to unmute " + commandData + "."); return; } sys.sendAll("Bot: " + commandData + " was unmuted by " + sys.name(src) + "!"); this.unmute(tar); return } }) Script Error line 6: SyntaxError: Parse error Whats wrong with line 6 exactly? xo
Steve is here to help! Code (text): ({ unmute : function(user){ saveVal('muted' + ip(user)) = false; return; } , beforeChatMessage: function(src, message) { if (sys.auth(src) < 2 && getVal('muted' + ip(src)) == true) { sys.stopEvent(); sys.sendMessage(src, "Bot: you are muted!"); return; } if ((message[0] == '/' || message[0] == '!') && message.length > 1) { print("Command -- " + sys.name(src) + ": " + message); sys.stopEvent(); var command; var commandData; var pos = message.indexOf(' '); if (pos != -1) { command = message.substring(1, pos).toLowerCase(); commandData = message.substr(pos+1); } else { command = message.substr(1).toLowerCase(); } var tar = sys.id(commandData); } /** Moderator Commands **/ if (sys.auth(src) < 1) { sys.sendMessage(src, "CommandBot: The command " + command + " can not be used by users."); return; } if (command == "mute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) { sys.sendMessage("Bot: you dont have sufficient auth to mute " + commandData + "."); return; } sys.sendAll("Bot: " + commandData + " was muted by " + sys.name(src) + "!"); muted[tar] = true; return } if (command == "ummute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) { sys.sendMessage("Bot: you dont have sufficient auth to unmute " + commandData + "."); return; } sys.sendAll("Bot: " + commandData + " was unmuted by " + sys.name(src) + "!"); this.unmute(tar); return; } } }) Never scripted in javascript in my life. Untested.
It says it was muted, but then when you try to talk, it still works. Code (text): ({ unmute : function(user){ saveVal('muted' + ip(user),false); return; } , beforeChatMessage: function(src, message) { if (sys.auth(src) < 2 && getVal('muted' + ip(src)) == true) { sys.stopEvent(); sys.sendMessage(src, "Bot: you are muted!"); return; } if ((message[0] == '/' || message[0] == '!') && message.length > 1) { print("Command -- " + sys.name(src) + ": " + message); sys.stopEvent(); var command; var commandData; var pos = message.indexOf(' '); if (pos != -1) { command = message.substring(1, pos).toLowerCase(); commandData = message.substr(pos+1); } else { command = message.substr(1).toLowerCase(); } var tar = sys.id(commandData); } /** Moderator Commands **/ if (sys.auth(src) < 1) { sys.sendMessage(src, "CommandBot: The command " + command + " can not be used by users."); return; } if (command == "mute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) { sys.sendMessage("Bot: you dont have sufficient auth to mute " + commandData + "."); return; } sys.sendAll("Bot: " + commandData + " was muted by " + sys.name(src) + "!"); saveVal('muted' + ip(user),false); return } if (command == "ummute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) { sys.sendMessage("Bot: you dont have sufficient auth to unmute " + commandData + "."); return; } sys.sendAll("Bot: " + commandData + " was unmuted by " + sys.name(src) + "!"); this.unmute(tar); return; } } }) x.x
Code (text): ({ unmute : function(user){ sys.saveVal('muted' + sys.ip(user),false); return; } , beforeChatMessage: function(src, message) { if (sys.auth(src) < 2 && sys.getVal('muted' + sys.ip(src)) == true) { sys.stopEvent(); sys.sendMessage(src, "~~Server~~: You are muted."); return; } if ((message[0] == '/' || message[0] == '!') && message.length > 1) { print("Command -- " + sys.name(src) + ": " + message); sys.stopEvent(); var command; var commandData; var pos = message.indexOf(' '); if (pos != -1) { command = message.substring(1, pos).toLowerCase(); commandData = message.substr(pos+1); } else { command = message.substr(1).toLowerCase(); } var tar = sys.id(commandData); } /** Moderator Commands **/ if (sys.auth(src) < 1) { sys.sendMessage(src, "CommandBot: The command " + command + " can not be used by users."); return; } if (command == "mute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) { sys.sendMessage("Bot: you dont have sufficient auth to mute " + commandData + "."); return; } sys.sendAll("Bot: " + commandData + " was muted by " + sys.name(src) + "!"); sys.saveVal('muted' + sys.ip(tar),true); return; } if (command == "unmute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) { sys.sendMessage("Bot: you dont have sufficient auth to unmute " + commandData + "."); return; } sys.sendAll("Bot: " + commandData + " was unmuted by " + sys.name(src) + "!"); this.unmute(tar); return; } } }) Newest fail.
it says CommandBot: The command undefined can not be used by users. Every time a non admin posts a message
Thanks to lutra, it now works, but the command bot thing still happens... Code (text): ({ unmute : function(tar){ sys.saveVal('muted' + sys.ip(tar),0); return; } , beforeChatMessage: function(src, message) { if (sys.auth(src) < 2 && sys.getVal('muted' + sys.ip(src)) == 1) { sys.stopEvent(); sys.sendMessage(src, "~~Server~~: You are muted."); return; } if ((message[0] == '/' || message[0] == '!') && message.length > 1) { print("Command -- " + sys.name(src) + ": " + message); sys.stopEvent(); var command; var commandData; var pos = message.indexOf(' '); if (pos != -1) { command = message.substring(1, pos).toLowerCase(); commandData = message.substr(pos+1); } else { command = message.substr(1).toLowerCase(); } var tar = sys.id(commandData); } /** Moderator Commands **/ if (sys.auth(src) < 1) { sys.sendMessage(src, "CommandBot: The command " + command + " can not be used by users."); return; } if (command == "mute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) { sys.sendMessage("Bot: you dont have sufficient auth to mute " + commandData + "."); return; } sys.sendAll("Bot: " + commandData + " was muted by " + sys.name(src) + "!"); sys.saveVal('muted' + sys.ip(tar),1); return; } if (command == "unmute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) { sys.sendMessage("Bot: you dont have sufficient auth to unmute " + commandData + "."); return; } sys.sendAll("Bot: " + commandData + " was unmuted by " + sys.name(src) + "!"); this.unmute(tar); return; } } })
Fixed, finally. New script, "Mute IP": Code (text): ({ unmute : function(tar){ sys.saveVal('muted' + sys.ip(tar),0); return; } , beforeChatMessage: function(src, message) { if (sys.auth(src) < 2 && sys.getVal('muted' + sys.ip(src)) == 1) { sys.stopEvent(); sys.sendMessage(src, "~~Server~~: You are muted."); return; } if ((message[0] == '/' || message[0] == '!') && message.length > 1) {print("Command -- " + sys.name(src) + ": " + message); sys.stopEvent(); var command; var commandData; var pos = message.indexOf(' '); if (pos != -1) { command = message.substring(1, pos).toLowerCase(); commandData = message.substr(pos+1); } else { command = message.substr(1).toLowerCase(); } var tar = sys.id(commandData); /** Moderator Commands **/ if (sys.auth(src) < 1) {sys.sendMessage(src, "CommandBot: The command " + command + " can not be used by normal users or does not exist."); return; } if (command == "mute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) {sys.sendMessage("Bot: you dont have sufficient auth to mute " + commandData + "."); return; } sys.sendAll("~~Server~~: " + commandData + " was muted by " + sys.name(src) + "!"); sys.saveVal('muted' + sys.ip(tar),1); return; } if (command == "unmute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) {sys.sendMessage("Bot: you dont have sufficient auth to unmute " + commandData + "."); return; } sys.sendAll("~~Server~~: " + commandData + " was unmuted by " + sys.name(src) + "!"); this.unmute(tar); return; } } } /** end **/ })
Specifically, this isn't working: Code (text): if (command == "tempmute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) {sys.sendMessage("~~Server~~: you dont have sufficient auth to mute " + commandData + "."); return; } sys.sendAll("~~Server~~: " + commandData + " was temp muted by " + sys.name(src) + "!"); sys.callLater('{this.unmute('+tar+');}',5); sys.saveVal('muted' + sys.ip(tar),1); return; } But here is the rest just in case: Code (text): ({ unmute : function(tar){ sys.saveVal('muted' + sys.ip(tar),0); return; } , unblock : function(tar){ sys.saveVal('blocked' + sys.ip(tar),0); return; } , beforeChallengeIssued : function(src, target, clauses) { if (sys.auth(src) < 2 && sys.getVal('blocked' + sys.ip(src)) == 1) { sys.stopEvent(); sys.sendMessage(src, "~~Server~~: You are blocked from sending challenges."); return; } if (sys.auth(src) < 2 && sys.getVal('stop') == 1) { sys.stopEvent(); sys.sendMessage(src, "~~Server~~: The battles are stoped."); return; } } , beforeChatMessage: function(src, message) { if (sys.auth(src) < 2 && sys.getVal('muted' + sys.ip(src)) == 1) { sys.stopEvent(); sys.sendMessage(src, "~~Server~~: You are muted."); return; } if (sys.auth(src) < 2 && sys.getVal('hush') == 1) { sys.stopEvent(); sys.sendMessage(src, "~~Server~~: The chat is hushed."); return; } if ((message[0] == '/' || message[0] == '!') && message.length > 1) {print("Command -- " + sys.name(src) + ": " + message); sys.stopEvent(); var command; var commandData; var pos = message.indexOf(' '); if (pos != -1) { command = message.substring(1, pos).toLowerCase(); commandData = message.substr(pos+1); } else { command = message.substr(1).toLowerCase(); } var tar = sys.id(commandData); /** Moderator Commands **/ if (sys.auth(src) < 1) {sys.sendMessage(src, "~~Server~~: The command " + command + " can not be used by normal users or does not exist."); return; } if (command == "mute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) {sys.sendMessage("~~Server~~: you dont have sufficient auth to mute " + commandData + "."); return; } sys.sendAll("~~Server~~: " + commandData + " was muted by " + sys.name(src) + "!"); sys.saveVal('muted' + sys.ip(tar),1); return; } if (command == "ipmute") { sys.sendAll("~~Server~~: " + commandData + " was muted by " + sys.name(src) + "!"); sys.saveVal('muted' + commandData,1); return; } if (command == "ipunmute") { sys.sendAll("~~Server~~: " + commandData + " was unmuted by " + sys.name(src) + "!"); sys.saveVal('muted' + commandData,0); return; } if (command == "tempmute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) {sys.sendMessage("~~Server~~: you dont have sufficient auth to mute " + commandData + "."); return; } sys.sendAll("~~Server~~: " + commandData + " was temp muted by " + sys.name(src) + "!"); sys.callLater('{this.unmute('+tar+');}',5); sys.saveVal('muted' + sys.ip(tar),1); return; } if (command == "smute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) {sys.sendMessage("~~Server~~: you dont have sufficient auth to mute " + commandData + "."); return; } print(commandData + " was silently muted by " + sys.name(src) + "."); sys.saveVal('muted' + sys.ip(tar),1); return; } if (command == "unmute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) {sys.sendMessage("~~Server~~: You dont have sufficient auth to unmute " + commandData + "."); return; } sys.sendAll("~~Server~~: " + commandData + " was unmuted by " + sys.name(src) + "!"); this.unmute(tar); return; } if (command == "sunmute") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) {sys.sendMessage("~~Server~~: You dont have sufficient auth to unmute " + commandData + "."); return; } this.unmute(tar); print(commandData + " was silently unmuted by " + sys.name(src) + "."); return; } if (command == "kick") { if (tar == undefined) { return; } sys.sendAll("~~Server~~: " + commandData + " was kicked by " + sys.name(src) + "!"); sys.kick(tar); return; } if (command == "skick") { if (tar == undefined) { return; } sys.kick(tar); print(commandData + " was silently kicked by " + sys.name(src) + "."); return; } if (command == "block") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) {sys.sendMessage("~~Server~~: you dont have sufficient auth to block " + commandData + "."); return; } sys.sendAll("~~Server~~: " + commandData + " was blocked from issuing challenges by " + sys.name(src) + "!"); sys.saveVal('blocked' + sys.ip(tar),1); return; } if (command == "unblock") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) {sys.sendMessage("~~Server~~: You dont have sufficient auth to unblock " + commandData + "."); return; } sys.sendAll("~~Server~~: " + commandData + " was unblocked by " + sys.name(src) + "!"); this.unblock(tar); return; } if (command == "sblock") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) {sys.sendMessage("~~Server~~: you dont have sufficient auth to block " + commandData + "."); return; } print(commandData + " was silently blocked from issuing challenges by " + sys.name(src) + "."); sys.saveVal('blocked' + sys.ip(tar),1); return; } if (command == "sunblock") { if (tar == undefined) { return; } if (sys.auth(tar) >= sys.auth(src)) {sys.sendMessage("~~Server~~: You dont have sufficient auth to unblock " + commandData + "."); return; } this.unblock(tar); print(commandData + " was silently unblocked by " + sys.name(src) + "."); return; } if (command == "hush") { sys.saveVal('hush',1); sys.sendAll("~~Server~~: The chat has been hushed by " + sys.name(src) + "!"); return; } if (command == "unhush") { sys.saveVal('hush',0); sys.sendAll("~~Server~~: The chat has been unhushed by " + sys.name(src) + "!"); return; } if (command == "stop") { sys.saveVal('stop',1); sys.sendAll("~~Server~~: The battles have been stoped by " + sys.name(src) + "!"); return; } if (command == "unstop") { sys.saveVal('stop',0); sys.sendAll("~~Server~~: The battles have been resumed by " + sys.name(src) + "!"); return; } } } /** end **/ })
Three suggestions, try either: sys.callLater('this.unmute('+tar+');',5); or sys.callLater('({this.unmute('+tar+');})',5); or sys.callLater(this.unmute(tar),5); I would be amazed if one of those didn't work.
I tried, none of those worked... I know this.unmute works since I use it in the unmute command... no idea whats not working. PS: Has anyone ever got the sys.callLater to work?
Yes, sys.callLater works. It's some problem to do with this.function() being used in the sys.callLater. I also have a problem when it's used in a user defined function [ i.e. function: function()], it won't access another user defined function for some reason. Edit: The problem I have is specifically to do with the .sort I think.
Lutra, then post a short script reproducing your problem in another topic, so we can tell what's wrong.
Code (text): if (command == "tempmute") { if (tar == undefined) { return; } if (sys.getVal('protected' + sys.ip(src)) == 1) {sys.sendMessage(src,"~~Server~~: " + commandData + " is protected and can not be muted."); return; } if (sys.auth(tar) >= sys.auth(src)) {sys.sendMessage(src,"~~Server~~: you dont have sufficient auth to mute " + commandData + "."); return; } sys.sendAll("~~Server~~: " + commandData + " was temp muted by " + sys.name(src) + "!"); sys.callLater('({sys.saveVal("muted' + sys.ip(tar) + '",0); })',5); sys.saveVal('muted' + sys.ip(tar),1); return; } Wont work, newest version...
sys.callLater("sys.saveVal('muted' + sys.ip(" + tar + "),0);",5); <<< I think the sys.callLater line should be this.
It started working now that I used lutra`s, but I still have no clue why any of my previous didn't work. I think it may be because before I was using the this.blabla and maybe it doesn't work inside a function or something.
Well, yeah, you can't use this. directly in a call like that, (i think), and you can't put '({' and ')}' surrounding your code.
You also have to do "...(" + variable + ")...", otherwise it doesn't apply it to what the variable represents.