Author Topic: Code causes console spam (errors)  (Read 1152 times)

A custom script for my server keeps spamming the console.
Quote
RECV: ADDCONSOLE   % Add-Ons/Script_ClearSpam/server.cs (7): Unknown command getPlayerName.
RECV: ADDCONSOLE   % Object AutoClearSpamBot(4294) AutoClearSpamBot -> ScriptObject -> SimObject
Sourcecode: http://pastebin.com/Sa2w9yCN

I'm just hitting from afar here but doesn't this have to be like this in the new ScriptObject part?
new AIConnection(AutoClearSpamBot) {
       name = "SpamBot";
       isAdmin = 1;
};

Didn't fix it. It's still getting errors. It works ingame, but the client message is off, it should say "CONSOLE cleared spam bricks." but instead it just says " cleared spam bricks."

Define aiConnection::getPlayerName. Do something like this:

Code: [Select]
function AIConnection::getPlayerName(%this)
{
    return %this.name;
}

Define aiConnection::getPlayerName. Do something like this:

Code: [Select]
function AIConnection::getPlayerName(%this)
{
    return %this.name;
}

That is a blocked function, even on AiClients and AiConnections.

RECV: ADDCONSOLE   % Add-Ons/Script_ClearSpam/server.cs (7): Unknown command getPlayerName.

Probably being called on a non-player. Make sure that every time you call that you have something like:

if(%thingThatMightBeAPlayer.getClassName() $= "Player")
{
     %name = %thingThatMightBeAPlayer.getPlayerName();
}

RECV: ADDCONSOLE   % Add-Ons/Script_ClearSpam/server.cs (7): Unknown command getPlayerName.

It's being called by a default function.
That is a blocked function, even on AiClients and AiConnections.
In that case, switch it back to a ScriptObject and define function ScriptObject::getPlayerName(%this) { return %this.name; }

In that case, switch it back to a ScriptObject and define function ScriptObject::getPlayerName(%this) { return %this.name; }
It's blocked on any type of object. You cannot define a getPlayerName method.

Just copy the code out of the clear-spam command into its own function with no client check.