Author Topic: Chat Mod  (Read 637 times)

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

Code: [Select]
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);
        }
               
    }
};

Code: [Select]
        %firstWord = strupr(getWord(%msg, 0));
You can just use firstWord(%msg); instead of getWord(%msg, 0); not that it really matters.
Code: [Select]
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;
}
You forgot the R in removeWord.

You can just use firstWord(%msg); instead of getWord(%msg, 0); not that it really matters.You forgot the R in removeWord.

Code: [Select]
package Chat
{
    function serverCmdMessageSent(%client,%msg)
    {
        %firstWord = firstWord(%msg);
        %firstChar = firstChar(%msg);

        if(%firstChar $= "^")
        {
            %msg = removeFirstWord(%msg);
%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 = removeFirstWord(%msg);

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!");
        }
       
        else
{
%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);
}
return;               
}
}
};

function removeFirstWord(%msg)
{
%msg = removeWord(%msg, 0);
return(%msg);
}

function firstChar(%msg)
{
%firstChar = getSubStr(%msg,0,1);
return(%firstChar);
}

It's all right? Also is this the right way to go about this or is there a simpler way?