Author Topic: Modify the name of a person (serverCmdmessageSent)  (Read 1514 times)

Code: (Torque) [Select]

%name = "[] " SPC %client.name @ "";
parent::serverCmdmessageSent(%name, %text);


I have that, but my name appears blank....
And in the console it says:

Code: (Console) [Select]
base/server/mainServer.cs (975): Unable to find object '[] Kalphiter' attempting to call function 'schedule'

Which would now mean it's attempting to find the function: [] Kalphiter.schedule

Obviously it found my name, and combined it with the "[]", now why doesn't that work?

Yes, there is, in the void, a %text and a %client.
« Last Edit: January 03, 2009, 12:56:24 PM by Kalphiter »

serverCmdMessageSent is called with the client and the message, not the name.
Thus you're setting your client to "[] Kalphiter", which doesn't exist.

serverCmdMessageSent is called with the client and the message, not the name.
Thus you're setting your client to "[] Kalphiter", which doesn't exist.
How can I solve this?

How can I solve this?

Well, are you just trying to change what appears in the yellow part of the line?

Well, are you just trying to change what appears in the yellow part of the line?
Yes.

Easiest way would be to just do a messageAll with a stripMLControl on the message.

Easiest way would be to just do a messageAll with a stripMLControl on the message.
What?

To accomplish this:

Code: (Torque) [Select]

%name = "[] " SPC %client.name @ "";
parent::serverCmdmessageSent(%name, %text);


You would use this:

Code: [Select]
messageAll('',stripMLControlChars("\c3[] "@%client.name@"\c6:"@%text));
Which turns this:

Quote
<BiTTruceCotB: Why, hello there.

Into this:

Quote
[] Truce: Why, hello there.

(Sorry for readability, but those are the in-game colors.)

To save re-inventing the wheel (checking filters and stuff) it may be easier to try something like this:
Code: [Select]
package nameChanger
{
function serverCmdMessageSent(%client, %msg)
{
%oldName = %client.name;
%client.name = "[]" SPC %oldName;
Parent::serverCmdMessageSent(%client, %msg);
%client.name = %oldName;
}
};
activatePackage(nameChanger);

To save re-inventing the wheel (checking filters and stuff) it may be easier to try something like this:
-code-

Actually, I tested it out, and you can't just edit %client.name. %client.setName(%name) doesn't work either. Only way I could edit it was to open up tree(); and edit the field then apply.

Actually, I tested it out, and you can't just edit %client.name. %client.setName(%name) doesn't work either. Only way I could edit it was to open up tree(); and edit the field then apply.
Editing %client.name works for me, although if you test it in other scenarios you may need to edit lanName or netName.

Editing %client.name works for me, although if you test it in other scenarios you may need to edit lanName or netName.

Meh, probably just my Blockland. It's quite screwed up.
An incident occured yesterday when I used setFaceName...

"Could not locate texture: base/data/shapes/player/base/data/shapes/player/Add-Ons/Face_Default/asciiTerror, using default texture"

D:

Is that all you need to do to finish that Truce?

Meh, probably just my Blockland. It's quite screwed up.
An incident occured yesterday when I used setFaceName...

"Could not locate texture: base/data/shapes/player/base/data/shapes/player/Add-Ons/Face_Default/asciiTerror, using default texture"

D:

That seems to be a problem with Blockland itself. I get the same error whenever I apply my avatar settings, but not when I respawn between that. It's kind of strange...

You shouldn't be able to edit a client's name, anyway... I can't edit an AIConnection's name, yet I could in v8.

AIConnection probably inherits from GameConnection where the name member variable is protected from script editing.