Ok... First off we are going to need a character to start the command.. TRPG uses #. We will use ! for this purpose.
function remoteSay(%clientId, %team, %message)
{
%msg = %clientId @ " \"" @ escapeString(%message) @ "\"";
// check for flooding if it's a broadcast OR if it's team in FFA
if($Server::FloodProtectionEnabled && (!$Server::TourneyMode || !%team))
{
// we use getIntTime here because getSimTime gets reset.
// time is measured in 32 ms chunks... so approx 32 to the sec
%time = getIntegerTime(true) >> 5;
if(%clientId.floodMute)
{
%delta = %clientId.muteDoneTime - %time;
if(%delta > 0)
{
Client::sendMessage(%clientId, $MSGTypeGame, "FLOOD! You cannot talk for " @ %delta @ " seconds.");
return;
}
%clientId.floodMute = "";
%clientId.muteDoneTime = "";
}
%clientId.floodMessageCount++;
// funky use of schedule here:
schedule(%clientId @ ".floodMessageCount--;", 5, %clientId);
if(%clientId.floodMessageCount > 4)
{
%clientId.floodMute = true;
%clientId.muteDoneTime = %time + 10;
Client::sendMessage(%clientId, $MSGTypeGame, "FLOOD! You cannot talk for 10 seconds.");
return;
}
}
%Command = False; // We want it to start off on false so things keep ticking
if(String::getSubStr(%message, 0, 1) == "!") //We are adding this in to see if it has the command sign In this case !
%command = True; // If it does take a turn down a different road
%word = GetWord(%message, 0); //We will need this to find out what the command is after the !
if(%command) // The heart of the commands
{
if(%word == "!tk") // the trigger for the command
{
Client::sendMessage(%TrueClientId, 1, "Team Killing will NOT be tolerated!"); // This will display this message in red to the person who types !tk
return; //We need to make sure !tk isn't displayed in the chat box
}
else
{
Client::sendMessage(%TrueClientId, 1, "Invalid Command"); This message goes tot he client if they type a command that doesn't exist
return; //We still don't want everyone to see what they are trying to say
}
}
if(%team)
{
if($dedicated)
echo("SAYTEAM: " @ %msg);
%team = Client::getTeam(%clientId);
for(%cl = Client::getFirst(); %cl != -1; %cl = Client::getNext(%cl))
if(Client::getTeam(%cl) == %team && !%cl.muted[%clientId])
Client::sendMessage(%cl, $MsgTypeTeamChat, %message, %clientId);
}
else
{
if($dedicated)
echo("SAY: " @ %msg);
for(%cl = Client::getFirst(); %cl != -1; %cl = Client::getNext(%cl))
if(!%cl.muted[%clientId])
Client::sendMessage(%cl, $MsgTypeChat, %message, %clientId);
}
}
I hope this helps