I've worked on this a few times and each time I've had questions. I think I've been heading in the right direction with this so far but I'm not sure. One problem that I have yet solve and so far think is impossible is being able to do chat functions with a server command, without having multiple message variables. But as of right now I think I'm doing this all right. If I'm doing something way to over complicated please let me know
package Chat
{
function serverCmdMessageSent(%client,%msg)
{
%firstWord = strupr(getWord(%msg, 0));
%firstChar = getSubStr(%msg,0,1);
if(%firstChar $= "^")
{
%msg = removeWord(%msg, 0);
%target = findClientByName(getFirstWord(%msg));
if(%firstWord $= "^OOC")
{
messageAll('',"\c2[OOC]\c7" SPC %client.clanprefix @ "\c3" @ %client.name @ "\c7" @ %client.clansuffix @ "\c6:" SPC %msg);
return;
}
if(%firstWord $= "^whisper")
{
%msg = emoveWord(%msg, 0);
messageClient(%target, '',"\c3[Whisper]\c7" SPC %client.clanprefix @ "\c3" @ %client.name @ "\c7" @ %client.clansuffix @ "\c6:" SPC %msg);
return;
}
messageClient(%client,'',"You did not enter a valid type of chat!");
return;
}
%position = %client.player.position;
InitContainerRadiusSearch(%position,30,$TypeMasks::PlayerObjectType);
while((%targetObject=containerSearchNext()) !$= 0)
{
%c = %targetObject.client;
messageClient(%c,'',"\c4[Local] \c7" SPC %client.clanprefix @ "\c3" @ %client.name @ "\c7" @ %client.clansuffix @ "\c6:" SPC %msg);
}
}
};