Client side script

This script will allow you do do several things in any server, all you have to do is put it in your autoexec folder.

>Highlight certain words or peoples text
>Bind chat commands and text to a key ingame
>Ignore anyone you choose completely
>Use simple ROT encryption


I'll add to it when ever i think of something else to add :p the chat commands binding is to die for tho.

Comments

  • It looks a bit interesting... not sure many people will find use for it though, perhaps you might add keybinds for some functions, maybe a little gui window to change options and things.
  • package CustomChat{
    	function clientCmdChatMessage(%sender, %voice, %pitch,%msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10){
    	%NewMsg = TextCatchIncoming(%sender, %voice, %pitch, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10);
    	if(%NewMsg !$= "" || %a1 $= "")
    		Parent::clientCmdChatMessage(%sender, %voice, %pitch, %msgString, %a1, %NewMsg, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10);
    	}
    
    In that part of the code where is the actual message the player sends? is it %msgString or one of the %a1 - %a10?

    and how can i use a chat command to work with my script? say i have a fucntion die(){ in my own script how can i call that fucntion through the chat hud?
  • Wow, your rot script makes mine look sexxy!
    $Rot::ActivationKey = "%";
    
    
    function Rot_encodeMessage(%message)
    {
    	%encode = getsubstr(strlwr(getword(%message, 0)), 0,1);
    	%message = strlwr(getwords(%message, 1));
    
    	%len = strlen(%message);
    	%rot = strcmp(getsubstr(%encode, 0,1), "a")+1;
    
    	%encode = "~ "@ %encode @" ";
    	for(%i = 0; %i < %len; %i++)
    	{
    		%char = getsubstr(%message, %i,1);
    		%cmp = strcmp(%char, "a");
    		if(%rot != 0 && %cmp >= 0 && %cmp < 26)
    			%char = rotChar(%char, %rot);
    
    		%encode = %encode @ %char;
    	}
    	return %encode;
    }
    
    
    function Rot_decodeMessage(%message)
    {
    	%encode = strlwr(getword(%message, 1));
    	%message = strlwr(getwords(%message, 2));
    
    	%len = strlen(%message);
    	%rot = strcmp(getsubstr(%encode, 0,1), "a")+1;
    
    	for(%i = 0; %i < %len; %i++)
    	{
    		%char = getsubstr(%message, %i,1);
    		%cmp = strcmp(%char, "a");
    		if(%rot != 0 && %cmp >= 0 && %cmp < 26)
    			%char = rotChar(%char, -%rot);
    
    		%decode = %decode @ %char;
    	}
    	return %decode;
    }
    
    
    function rotChar(%char, %dist)
    {
    	%cmp = strcmp(%char, "") + %dist;
    
    	if(%cmp > 122)	%cmp -= 26;
    	if(%cmp < 97)	%cmp += 26;
    
    	return collapseEscape("\\x" @ decToHex(%cmp));
    }
    


    And, all these "here's my super-awesome script" posts are making me contemplate releasing some of mine. . .
  • Those Encyrption functions look vera familiar
  • package CustomChat{
    	function clientCmdChatMessage(%sender, %voice, %pitch,%msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10){
    	%NewMsg = TextCatchIncoming(%sender, %voice, %pitch, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10);
    	if(%NewMsg !$= "" || %a1 $= "")
    		Parent::clientCmdChatMessage(%sender, %voice, %pitch, %msgString, %a1, %NewMsg, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10);
    	}
    
    In that part of the code where is the actual message the player sends? is it %msgString or one of the %a1 - %a10?

    and how can i use a chat command to work with my script? say i have a fucntion die(){ in my own script how can i call that function through the chat hud?
  • The correct function you're probably looking for is "function MessageHud_Edit::eval(%this)"...
  • Here is a piece of my chat encryption script (well the hud)
    //Phantom
    $RemapName[$RemapCount] = "Encode Chat";
    $RemapCmd[$RemapCount] = "ToggleEncoderHud";
    $RemapCount++;
    //Dark Dragon DX
    $RemapName[$RemapCount] = "Unicode Chat";
    $RemapCmd[$RemapCount] = "ToggleUnicoderHud";
    $RemapCount++;
    
    //Phantom's Fixes(modifications)
    function ToggleMessageHud(%make)
    {
       if(%make)
       {
          MessageHud.isTeamMsg = false;
          MessageHud.isencoded = false;
          MessageHud.isunicoded = false;
          MessageHud.toggleState();
       }
    }
    
    function TeamMessageHud(%make)
    {
       if(%make)
       {
          MessageHud.isTeamMsg = true;
          MessageHud.isencoded = false;
          MessageHud.isunicoded = false;
          MessageHud.toggleState();
       }
    }
    
    function ToggleEncoderHud(%make)
    {
       if(%make)
       {
          MessageHud.isencoded = true;
          MessageHud.isunicoded = false;
          MessageHud.isTeamMsg = false;
          MessageHud.toggleState();
       }
    }
    
    
    function ToggleUnicoderHud(%make)
    {
       if(%make)
       {
          MessageHud.isunicoded = true;
          MessageHud.isencoded = false;
          MessageHud.isTeamMsg = false;
          MessageHud.toggleState();
       }
    }
    
    //Other
    function MessageHud_Edit::eval(%this)
    {
       %text = trim(%this.getValue());
       if(%text !$= "")
       {
          if(MessageHud.isTeamMsg)
             commandToServer('teamMessageSent', %text);
          else if(MessageHud.isencoded){
             encode(%text);
             }
          else if(MessageHud.isunicoded){
            %EN = Unicode_Encrypt(%text);
            commandtoserver('messagesent',"\c5DUD:\c4" SPC %EN);
            }
          else{
             commandToServer('messageSent', %text);
       }
    
       MessageHud.close();
    }
    }
    
    function MessageHud::open(%this)
    {
       %offset = 6;
    
       if(%this.isVisible())
          return;
    
       if(%this.isTeamMsg)
          %text = "TEAM:";
       else if(%this.isencoded)
          %text = "ENCODE:";
       else if(%this.isunicoded)
          %text = "DUD:";
       else
          %text = "GLOBAL:";
    
       MessageHud_Text.setValue(%text);
    
       %windowPos = "8 " @ ( getWord( outerChatHud.position, 1 ) + getWord( outerChatHud.extent, 1 ) + 1 );
       %windowExt = getWord( OuterChatHud.extent, 0 ) @ " " @ getWord( MessageHud_Frame.extent, 1 );
    
       if( MainVoteHud.isVisible() )
       {
          %votePos = firstWord( MainVoteHud.position ) @ " " @ ( getWord( OuterChatHud.extent, 1 ) + getWord( messageHud_Frame.extent, 1 ) + 10 );
          MainVoteHud.position = %votePos;
       }
    
        if( voiceCommHud.isVisible() )
        {
            %vCommPos = firstWord( voiceCommHud.position ) SPC ( getWord( OuterChatHud.extent, 1 ) + getWord( messageHud_Frame.extent, 1 ) + 18 );
            voiceCommHud.position = %vCommPos;
        }
    
       %textExtent = getWord(MessageHud_Text.extent, 0);
       %ctrlExtent = getWord(MessageHud_Frame.extent, 0);
    
       Canvas.pushDialog(%this);
    
       messageHud_Frame.position = %windowPos;
       messageHud_Frame.extent = %windowExt;
       MessageHud_Edit.position = setWord(MessageHud_Edit.position, 0, %textExtent + %offset);
       MessageHud_Edit.extent = setWord(MessageHud_Edit.extent, 0, %ctrlExtent - %textExtent - (2 * %offset));
    
       %this.setVisible(true);
       deactivateKeyboard();
       MessageHud_Edit.makeFirstResponder(true);
    }
    
  • function clientCmdChatMessage(%sender, %voice, %pitch,%msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10){
    

    can someone explain whats in each of those %a#?
  • %a1 = sender
    %a2 = message

    the others aren't really important
  • lol thank you naosyth

    but if %a2 is the message... what is %msgString?
    and if %a1 is the sender.... why is there a %sender?
  • lol thank you naosyth

    but if %a2 is the message... what is %msgString?
    and if %a1 is the sender.... why is there a %sender?

    %a1 is the name of the sender.
    %sender is the client ID.

    I don't really know what %msgstring is for. I think it's generated when you call addtaggedstring(%a2);
  • If I recall properly, %msgstring is "sender_name: message", effectively what you see displayed in the Chat HUD.
  • $Chat::WordSearch = "BlitzTorque";
    
    function TextCatchIncoming(%sender, %voice, %pitch, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10){
    	%origin = getWords(%a1, 1, getWordCount(%a1));
    	%id = plnametocid(%origin);
    
    	if (%a1 $= "")
    		return "";
    
            %msgCount = getwordcount(%a2);
    	for(%i=0;%i<%msgCount;%i++){
    
    		%listcount = getwordcount($Chat::WordSearch);
    		for(%iB=0;%iB<%listcount;%iB++){
    
    			%MsgWord  = strlwr(getWord(%a2,%i));
    			%ListWord = strlwr(getWord($Chat::WordSearch,%iB));
    
    
    			trim(%MsgWord);
    			trim(%ListWord);
    			if(strstr(%ListWord,%MsgWord) != -1 && strLen(%MsgWord) >= $Chat::MinWordLenght){
    //				if (%i > 0)
    //					%first = getWords(%a2,0,%i-1);
    
    //				if (%i < %msgcount)
    //					%last = getWords(%a2,%i+1,getWordCount(%a2));
    
    			}
    		}
    	}
    

    Ok.... i have no idea what im doing... How do i search in a message to see if there is a certain word in that message?
  • If you just need to check if the word is in the string at all, you can use strstr(message,"word"); - or strpos if you want to give it an offset - which would work if you just want to play a sound or highlight the whole message. If that's the case you'd use something like:

    if ( strstr( strlwr(%a2),"blitz") != -1 )


    Of course, if you wanted to find a specific word and highlight it, you could do something like:
    for (%i=0;%i<%msgCount;%i++)
        if ( stricmp( getWord( %a2,%i ), "BlitzTorque" ) == 0 )
          %a2 = setWord(%a2,%i,"\c5" @ getWord(%a2,%i) @ "\c4");
    
  • so if i use
    strstr(%a2, "BlitzTorque");
    That would check the whole message to see if the word "blitztorque is in it? And if i use $WordSearch instead of blitztorque and set
    $WordSearch = "BlitzTorque", "Blitz";
    Would it search for both names?
  • so if i use
    strstr(%a2, "BlitzTorque");
    That would check the whole message to see if the word "blitztorque is in it?
    Yes, but it is case sensitive (unlike stricmp), so make sure you use strlwr on %a2 and have your search string all lowercase.
    And if i use $WordSearch instead of blitztorque and set
    $WordSearch = "blitzTorque blitz";
    Would it search for both names?
    Nope. If the words in $WordSearch are seperated by a space, you could use a for loop such as the one in the previous post, where the word count of $WordSearch would replace %msgCount, and you use strstr to search for getWord($WordSearch,%i).
  • %Message = strlwr(%a2);
                if($Chat::AFK == 1){
                   if(strstr(%Message, "blitztorque") != 1 || strstr(%Message, "blitz") != 1){
                      Do stuff here if "blitz" or "blitztorque" is in the message.....
                   }
                }
    

    is that the correct way to use it?
  • Not exactly. strstr will return -1 if it doesn't find the word in the string, not 1. Also, having it search for "blitztorque" would be redundant if you're already searching for "blitz".
  • lol yeah sorry, the 1 was supposed to be -1,
    and it would work for blitz even if the whole word is blitztorque?
  • Yep. It doesn't search for words, it searches for and returns the position of the first occurence of string b in string a.
  • lol yeah sorry, the 1 was supposed to be -1,
    and it would work for blitz even if the whole word is blitztorque?

    I believe it would.
  • %Message = strlwr(%a2);
                if($Chat::AFK == 1){
                   if(strstr(%Message, "blitz") != -1){
                      commandtoserver('messagesent', "Test...");
                   }
                }
    
    i placed this code inside Mazo's Client script inside the function
    function TextCatchIncoming(%sender, %voice, %pitch, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10){
    
    But when someone says blitz nothing happens, but when i do a voice command it sends the message "test..."
  • function clientCmdChatMessage(%sender, %voice, %pitch,%msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10){
    
    i also placed it in this code and the same thing happened
  • How do you revert a button back to its old key?
  • But when someone says blitz nothing happens, but when i do a voice command it sends the message "test..."


    Experiment, experiment, experiment! Waiting around for somebody else to figure out what's been done wrong doesn't help. The code works, find out what's gone wrong. Use echo to find out the values of your variables, see what each is checking.
    If it's going through only when you send a message, doesn't that sound like it's checking names? :p
    How do you revert a button back to its old key?
    If you're running Mazo's script you'll have to open it up and change or remove the movemap.bind lines. If you don't use the script, you can just change the key in your settings.
  • Okay, got that, now how do I add more than 1 bind?
  • Okay, got that, now how do I add more than 1 bind?
    package custombinds{
    function OptionsDlg::onWake(%this)
    {
    if (!$CBinds)
    {
    
    $RemapName[$RemapCount] = "Name";
    $RemapCmd[$RemapCount] = "Function";
    $RemapCount++;
    
    $RemapName[$RemapCount] = Name";
    $RemapCmd[$RemapCount] = "Function";
    $RemapCount++;
    
    $CBinds = true;
    }
    parent::onwake(%this);
    }
    };
    activatepackage(custombinds);
    

    That's how I'd do it.
Sign In or Register to comment.