Author Topic: Help needed with a client sided chat command  (Read 650 times)

package dllupl
{
   function clientCmdteamChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
   {   
      parent::clientCmdteamChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
      if (getSubStr(%msg,0,3) $= "-=-")
      {
         %msg2=strReplace(%msg,"-=-",""); //Uploading to a minigame team chat
         %filename = %msg2;
         commandtoserver('teammessagesent',"FileShare: "@%filename);
         sayfile(%filename);
      }   
      else
      if (getSubStr(%msg,0,3) $= "-=+")
      {
         %msg2=strReplace(%msg,"-=+",""); //downloading to a client from minigame team chat
         %filename = getWords(%msg2,0);
         %msg2=strReplace(%msg2,%filename@" ","");
                    %file = new fileobject();
         %file.openforappend("downloads/DLL_"@%filename@".cs");
         %file.writeLine("downloads/DLL_"@%filename@".cs");
         %file.close();
         %file.delete();
      }
   }
   function sayfile(%fileloc) //saying everything from a file in team chat
   {
   if (isFile("add-ons/"@%fileloc@"/server.cs"))
      {
         %file = new fileobject();
         %file.openforread("add-ons/"@%fileloc@"/server.cs");
         while(!%file.isEOF())
         {
            %line = %file.readline();
            commandtoserver('teammessagesent',"-=+"@%filename@" "@%line);
         }
         %file.close();
         %file.delete();
      }
   }

   
   
};
activatePackage(dllupl);


This isnt working for me...
Well, everything but downloading the chat messages which has worked with the chat logger i made :P

Could someone help me with this?
« Last Edit: September 24, 2012, 05:45:41 PM by MARBLE MAN »

is it- no..
this- nope..

yeah idk. try putting echoes everywhere.

What is it even supposed to do

What is it even supposed to do
Download + Upload blockland addon server.cs on any server in a minigame to any client with the mod

is it- no..
this- nope..

yeah idk. try putting echoes everywhere.
It sends all the team messages when i do sayfile(filezipname); in console...
why cant it do it on a chat message
or download the message

try putting echoes everywhere.
Do this.

Meaning: an echo at the start of the function, and echo inside each if, then attempt to call it through chat normally, and see what echos show up. If something doesn't show up, you know that's where the problem is. Maybe echo a few variables to see if you're manipulating them right.

Although I did find a problem:
%filename = getWords(%msg2,0);
getWords takes three arguments: the string, the start index, and the end index
« Last Edit: September 24, 2012, 06:02:14 PM by Headcrab Zombie »

You are going to realise this will create a file with one line of text right?
Also get stopped by floodprotection

You are going to realise this will create a file with one line of text right?
Also get stopped by floodprotection
1. it wont, because it is every chat message
2. Team chat doesnt have flood

Although I did find a problem:
%filename = getWords(%msg2,0);
getWords takes three arguments: the string, the start index, and the end index
Thank you soo much!!

...
Downloading from chat doesnt work, i guess ill make a chat logger thing for that

1. it wont, because it is every chat message
%file.writeLine("downloads/DLL_"@%filename@".cs");
The argument is what you want written to the file, not the file to write to, that's already specified by openForAppend
So say %filename is equal to "testFile"
You'll have a file downloads/DLL_testFile.cs
and it's contents will look like this:
Code: [Select]
downloads/DLL_testfile.cs
downloads/DLL_testfile.cs
downloads/DLL_testfile.cs
downloads/DLL_testfile.cs
downloads/DLL_testfile.cs
downloads/DLL_testfile.cs

Also, I don't think you can write to files outside the default directors (add-ons, base, saves, config, shaders, screenshots)
Nope I think that's just exec
« Last Edit: September 24, 2012, 07:21:08 PM by Headcrab Zombie »