Author Topic: Parenting  (Read 524 times)

I was making a special script for my server that when you talk with < in front of a word it will do like *Name what ever after <* in chat
i got the script to work but it wont parent right
I added this to the script
Code: (Proper Parent?) [Select]
parent::serverCmdMessageSent(%client, %msg);The code is like this
Code: (My code) [Select]
function serverCmdMessageSent(%client, %msg)
{
if(getsubStr(%msg,0,1) $= "<")
{
messageall('msgClientJoin',"\c5"@%client.getPlayerName()@" "@%msg@"");
}
parent::serverCmdMessageSent(%client, %msg);
}
Anyone see whats wrong with the script?
Do i need to put it in a package?
Edit: I heard that you need to parent Inside a Package;
Im gonna try it inside a package and see if it fixes the problem if not i would like to know how to fix.
« Last Edit: October 07, 2009, 04:36:58 PM by Pah1023 »

Yes you need to package it.
But I also noticed you put 'msgClientJoin' as the first arg, what does that do? =\

Like when someone join it will play that sound, and i tried to exec the script and heres what it says
Something like error at the #'s
parent:#:#serverCmdMessageSent(%client, %Msg);

Sorry for double post but i found out whats wrong with the Parent:: thing i had it at wrong spot, but how can i make them not show the < stuff?

You'll need to put it in a package, like so:

Code: [Select]
package PahPackage
{
function serverCmdMessageSent(%client,%msg)
{
if(getSubStr(%msg,0,1) $= "<")
messageAll('MsgClientJoin',"\c5" @ %client.getPlayerName() SPC %msg);
else
Parent::serverCmdMessageSent(%client,%msg);
}
};
activatePackage(PahPackage);

I also put the Parent:: line in an else statement (since it would logically make sense here).

Thanks, truce but i got it to work all i need to know is how to remove the < from chat when they talk.

Thanks, truce but i got it to work all i need to know is how to remove the < from chat when they talk.

You can use the getSubStr function. You already used it in your if test to check the first character; getSubStr(Source string,Beginning index,String length). See if you can figure out how to use getSubStr to get all the characters after the first one.

This will help you:
http://docs.garagegames.com/tge/official/content/documentation/Reference/Console%20Functions/TorqueScript_Console_Functions_3.html
May I suggest bookmarking it and referring to it before posting tons of help topics here.I realize we all need to start somewhere, however simply continuously asking people how to do things, specific things, and not learning what you are actually doing, does not help you learn torquescript in the long run.