Blockland Forums > Modification Help
Simple Script Help
¥ola:
Alright, I'm trying to refresh myself with Torque's functions and whatnot
And somehow I seem to run into a problem
--- Code: ---if(!$JoinMessage::Binds)
{
$remapDivision[$remapCount]="Join Message";
$remapName[$remapCount]="Toggle On/Off";
$remapCmd[$remapCount]="toggleJoinMessage";
$remapCount++;
$JoinMessage::Binds=1;
}
function ClientCmd_ClientJoin(%client)
{
messageAll('',"Welcome, %client.");
}
function toggleJoinMessage(%a)
{
if(!%a)
return;
if($JoinMessage::On)
{
$JoinMessage::On = false;
clientcmdcenterPrint("\c6Join message disabled.", 2);
}
else
{
$JoinMessage::On = true;
clientcmdcenterPrint("\c6Join Message enabled.", 2);
}
}
--- End code ---
I realize it's a JoinMessage, I'm not planning on using it, simply to learn a few things
¥ola:
Help?
jes00:
--- Quote from: ¥ola on June 08, 2012, 07:53:33 PM ---Alright, I'm trying to refresh myself with Torque's functions and whatnot
And somehow I seem to run into a problem
--- Code: ---if(!$JoinMessage::Binds)
{
$remapDivision[$remapCount]="Join Message";
$remapName[$remapCount]="Toggle On/Off";
$remapCmd[$remapCount]="toggleJoinMessage";
$remapCount++;
$JoinMessage::Binds=1;
}
function ClientCmd_ClientJoin(%client)
{
messageAll('',"Welcome, %client.");
}
function toggleJoinMessage(%a)
{
if(!%a)
return;
if($JoinMessage::On)
{
$JoinMessage::On = false;
clientcmdcenterPrint("\c6Join message disabled.", 2);
}
else
{
$JoinMessage::On = true;
clientcmdcenterPrint("\c6Join Message enabled.", 2);
}
}
--- End code ---
I realize it's a JoinMessage, I'm not planning on using it, simply to learn a few things
--- End quote ---
Few things.
1. ClientCmd_ClientJoin is a non existant function.
2. messageAll is server sided.
¥ola:
--- Quote from: jes00 on June 09, 2012, 11:18:07 AM ---Few things.
1. ClientCmd_ClientJoin is a non existant function.
2. messageAll is server sided.
--- End quote ---
What the function for when a player joins?
How would I sent a chat message to the entire server through my players chat?
otto-san:
Since this is clientsided, you don't have access to messageAll. If you want to display a message to everyone, you have to use chat. commandToServer('messageSent', "message");
Second, you have to package the ClientCmd_ClientJoin (if it were a function, because the way you're using it, i'm guessing you thought it already existed).
package duckoverlords
{
function ClientCmd_ClientJoin(%client)
{
parent::ClientCmd_ClientJoin(%client);
commandToServer('messageSent', "Welcome, %client.");
}
};
activatePackage(duckoverlords);
But the above code still wouldn't work as intended.
When you want to append a non-string thing onto a string, you have to use things like @ and SPC. (There's also NL and TAB, but you don't need those here.)
package duckoverlords
{
function ClientCmd_ClientJoin(%client)
{
parent::ClientCmd_ClientJoin(%client);
commandToServer('messageSent', "Welcome," SPC %client);
}
};
activatePackage(duckoverlords);
@ appends whatever with no space, SPC appends it with a space. (obviously)
Now, one last thing. You appear to want to be able to toggle this. So we have to actually factor in whether it's on or not to the actual function.
package duckoverlords
{
function ClientCmd_ClientJoin(%client)
{
parent::ClientCmd_ClientJoin(%client);
if($JoinMessage::On)
commandToServer('messageSent', "Welcome," SPC %client);
}
};
activatePackage(duckoverlords);
Now, given that ClientCmd_ClientJoin actually existed and did what you thought it would do and had the only argument as %client, which is a string containing the player's name, that would work. (unless i made an error)