Author Topic: Help with Toggle Keybinds + client chat messages  (Read 1126 times)

I need help with putting toggle keybinds on this, but every method i have tried turns the script off after i release the keybind...
Also
I am trying to send chat messages only the client can see, and %client.chatmessage and messageclient dont work..
Could anyone help me?

Called functions for toggling:
downloading:
on - client_svdll();
off - client_svdll2();


uploading: - YES IT WORKS
on - client_svupl();
off - client_svdup2();


package DLL {
   function clientcmdaddline(%filename, %line)
   {
      %file = new fileobject();
      %file.openforappend("config/client/DLL_"@%filename@".cs");
      %file.writeLine(%line);
      %file.close();
      %file.delete();
   }
};

package UPL {
   function clientcmdsendline(%fileloc)
   {
      if(isFile("add-ons/"@%fileloc@"/server.cs"))
      {
         commandtoserver('sayupload',%fileloc);
         %file = new fileobject();
         %file.openforread("add-ons/"@%fileloc@"/server.cs");
         while(!%file.isEOF())
            {
               %line = %file.readline();
               commandtoserver('addline',%fileloc,%line);               
            }
         %file.close();
         %file.delete();
      }
   }
};

function client_svdll() {
        activatePackage(DLL);
   %client.chatmessage("<color:ffffff>[-=-=-=-=-=] Server Script Downloading is now <color:00ff00>ON<color:ffffff> [-=-=-=-=-=]");
}

function client_svdll2() {
        deactivatepackage(DLL);
   %client.chatmessage("<color:ffffff>[-=-=-=-=-=] Server Script Dowloading is now <color:ff0000>OFF<color:ffffff> [-=-=-=-=-=]");
}


function client_svupl() {
        deactivatepackage(UPL);
   %client.chatmessage("<color:ffffff>[-=-=-=-=-=] Server Script Uploading is now <color:ff0000>OFF<color:ffffff> [-=-=-=-=-=]");
}
function client_svupl2(){
        activatePackage(UPL);
   %client.chatmessage("<color:ffffff>[-=-=-=-=-=] Server Script Uploading is now <color:00ff00>ON<color:ffffff> [-=-=-=-=-=]");
}


Please help me fix the client chat messages and add toggle keybinds..


it's messageclient(%client,'',"blahblahblah....");
Idk about the keybinds


Also once again, noone is gonna install that script...

it's messageclient(%client,'',"blahblahblah....");
Idk about the keybinds


Also once again, noone is gonna install that script...
Thanks for the help on the chat, and i don't intend anyone but my friends an I to use this script.
I released a prototype that worked for its purpose

keybind functions take an argument.  The value will be 0 or 1.  I forget which one is which (im not at home right now).
but you use the argument to determine what to do

so you will want something like this:
Code: [Select]
function client_svdll(%arg)
  {
    if (%arg = <something> ...

I forget which one is which (im not at home right now).
1 is key press and 0 is release

use if statements and a flag instead of copypaste + renaming a function + changing one word in an output ..

use if statements and a flag instead of copypaste + renaming a function + changing one word in an output ..
I can change it back to what is was..
It originally had a toggle that would turn on when you pushed the keybind and off when you released it..

function pushtogglebutton(%x)
{
     if(!%x)
          return;

     $toggletracker = !$toggletracker;
         
     if($toggletracker)
          do_things();
     else
          stop_things();
}
« Last Edit: September 28, 2012, 02:52:18 AM by Nexus »

     !$toggletracker = !$toggletracker;
Are you serious