Author Topic: "/" command help  (Read 2016 times)

This is how you do it
Code: [Select]
function serverCmdWhatEverYouWantHere
replace WhatEverYouWantHere with what you want people to say when they type the command using the slash
read thead pls

read thead pls
I did, let me guess you didn't? Oh and please spell right. Its not pls is please and its not thead is thread.

Hi, I'm new to scripting and I needed some help on simple forward slash commands. I just need to be able to set up an in game command to toggle on and off a line of code. If you could help it would be nice.

BlockStar, shut up and read the thread. All you read was the damn title. Quoted above is the topic post, and he's only asking how to toggle a variable using a / command. He needs help with toggling, not / commands themselves.

BlockStar, shut up and read the thread. All you read was the damn title. Quoted above is the topic post, and he's only asking how to toggle a variable using a / command. He needs help with toggling, not / commands themselves.
I know im just telling him in advanced.


Code: [Select]
function servercmdtoggle(%client)
{
$a = !$a;
}
toggletoggletoggle

Code: [Select]
$a = 0;
function servercmdtoggleup(%client)
{
$a++;
if($a>8)
$a = 0;
}

$a = 0;
function servercmdtoggledown(%client)
{
$a--;
if($a<0)
$a = 8;
}

toggletoggletoggle from 0 to 8

Once again I'm sorry for being noobish but how would I make it so a line of code would only execute if a variable was equal to 1?

Code: [Select]
if($variable)
{
      //code to execute
}


Thanks, testing now.

why are you trying to use / commands for a clientsided script, especially this one?

you need keybinds.

If you could tell me how to add keybinds I'd gladly do it.

Code: [Select]
$remapDivision[$remapCount] = "Section Title";
$remapName[$remapCount] = "Bind Title";
$remapCmd[$remapCount] = "function";
$remapCount++;

Would make a keybind Called Bind Title under Section Title that when activated will execute the command: function();

If you wanted to add two binds to the same section:

Code: [Select]
$remapDivision[$remapCount] = "Some Section";
$remapName[$remapCount] = "Bind1";
$remapCmd[$remapCount] = "function";
$remapCount++;
$remapName[$remapCount] = "Bind2";
$remapCmd[$remapCount] = "function";
$remapCount++;
« Last Edit: January 08, 2011, 03:52:16 PM by Fluff-is-back »

Ok, I just added the keybind like you said to but now nothing works, here's my current script...
Code: [Select]
///Colored Avatar
//by boomlinde
//Edited by Tylerman
//Re-edited by Erif/Baeshra/BL_ID 19049

{
   $remapDivision[$remapCount] = "Rainbow Avatar";
   $remapName[$remapCount] = "Toggle Head";
   $remapCmd[$remapCount] = "togglehead";
   $remapCount++;
}

if (!$RainbowAvatarBindings)
{
   $remapDivision[$remapCount] = "Rainbow Avatar";
   $remapName[$remapCount] = "Activate/Deactivate";
   $remapCmd[$remapCount] = "RainbowAvatarToggle";
   $remapCount++;
   $RainbowAvatarBindings=true;
}

$RainbowAvatarCount=0;
$RainbowAvatarFlag=0;
$RainbowAvatarTempPack=$pref::Avatar::PackColor;
$RainbowAvatarTempHat=$pref::Avatar::HatColor;
$RainbowAvatarTempLLeg=$pref::Avatar::LLegColor;
$RainbowAvatarTempRLeg=$pref::Avatar::RLegColor;
$RainbowAvatarTempAccent=$pref::Avatar::AccentColor;
funtion togglehead
{
$RainbowAvatarTempHead=$pref::Avatar::HeadColor;
}
$RainbowAvatarTempTorso=$pref::Avatar::TorsoColor;
$RainbowAvatarTempHip=$pref::Avatar::HipColor;
$RainbowAvatarTempLArm=$pref::Avatar::LArmColor;
$RainbowAvatarTempLHand=$pref::Avatar::LHandColor;
$RainbowAvatarTempRArm=$pref::Avatar::RArmColor;
$RainbowAvatarTempRHand=$pref::Avatar::RHandColor;
$RainbowAvatarTempSecondPack=$pref::Avatar::SecondPackColor;

function RainbowAvatarToggle(%val)
{
  if(%val) {
    if($RainbowAvatarFlag==0)
    {
        $RainbowAvatarFlag=1;
        $RainbowAvatarTempPack=$pref::Avatar::PackColor;
      $RainbowAvatarTempHat=$pref::Avatar::HatColor;
      $RainbowAvatarTempLLeg=$pref::Avatar::LLegColor;
      $RainbowAvatarTempRLeg=$pref::Avatar::RLegColor;
      $RainbowAvatarTempAccent=$pref::Avatar::AccentColor;
      funtion togglehead      
      {
      $RainbowAvatarTempHead=$pref::Avatar::HeadColor;
      }
      $RainbowAvatarTempTorso=$pref::Avatar::TorsoColor;
      $RainbowAvatarTempHip=$pref::Avatar::HipColor;
      $RainbowAvatarTempLArm=$pref::Avatar::LArmColor;
      $RainbowAvatarTempLHand=$pref::Avatar::LHandColor;
      $RainbowAvatarTempRArm=$pref::Avatar::RArmColor;
      $RainbowAvatarTempRHand=$pref::Avatar::RHandColor;
      $RainbowAvatarTempSecondPack=$pref::Avatar::SecondPackColor;
        RainbowAvatarLoop();
    }
   else if($RainbowAvatarFlag==1)
    {
        $RainbowAvatarFlag=0;
        cancel($RainbowAvatar);
        $pref::Avatar::PackColor=$RainbowAvatarTempPack;
      $pref::Avatar::HatColor=$RainbowAvatarTempHat;
      $pref::Avatar::LLegColor=$RainbowAvatarTempLLeg;
      $pref::Avatar::RLegColor=$RainbowAvatarTempRLeg;
      $pref::Avatar::AccentColor=$RainbowAvatarTempAccent;
      funtion togglehead      
      {
      $pref::Avatar::HeadColor=$RainbowAvatarTempHead;
      }
      $pref::Avatar::TorsoColor=$RainbowAvatarTempTorso;
      $pref::Avatar::HipColor=$RainbowAvatarTempHip;
      $pref::Avatar::LArmColor=$RainbowAvatarTempLArm;
      $pref::Avatar::LHandColor=$RainbowAvatarTempLHand;
      $pref::Avatar::RArmColor=$RainbowAvatarTempRArm;
      $pref::Avatar::RHandColor=$RainbowAvatarTempRHand;
      $pref::Avatar::SecondPackColor=$RainbowAvatarTempSecondPack;
        clientcmdupdateprefs();
    }
  }
}
function rainbowreset() {
cancel($RainbowAvatar);
$pref::Avatar::PackColor=$RainbowAvatarTempPack;
$pref::Avatar::HatColor=$RainbowAvatarTempHat;
$pref::Avatar::LLegColor=$RainbowAvatarTempLLeg;
$pref::Avatar::RLegColor=$RainbowAvatarTempRLeg;
$pref::Avatar::AccentColor=$RainbowAvatarTempAccent;
funtion togglehead
{
$pref::Avatar::HeadColor=$RainbowAvatarTempHead;
}
$pref::Avatar::TorsoColor=$RainbowAvatarTempTorso;
$pref::Avatar::HipColor=$RainbowAvatarTempHip;
$pref::Avatar::LArmColor=$RainbowAvatarTempLArm;
$pref::Avatar::LHandColor=$RainbowAvatarTempLHand;
$pref::Avatar::RArmColor=$RainbowAvatarTempRArm;
$pref::Avatar::RHandColor=$RainbowAvatarTempRHand;
$pref::Avatar::SecondPackColor=$RainbowAvatarTempSecondPack;
clientcmdupdateprefs();
}
function RainbowAvatarLoop()
{
        if($RainbowAvatarCount > 63) $RainbowAvatarCount=0;
        //Grejer
        $R=0.5+0.5*mSin($RainbowAvatarCount*3.14/16.0);
$G=0.5+0.5*mSin($RainbowAvatarCount*3.14/16.0+21.0);
      $pref::Avatar::PackColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::HatColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::LLegColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::RLegColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::AccentColor=$R SPC $G SPC $B SPC "1";
      funtion togglehead
      {
      $pref::Avatar::HeadColor=$R SPC $G SPC $B SPC "1";
      }
      $pref::Avatar::TorsoColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::HipColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::LArmColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::LHandColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::RArmColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::RHandColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::SecondPackColor=$R SPC $G SPC $B SPC "1";
        clientcmdupdateprefs();
        $RainbowAvatarCount++;
        $RainbowAvatar=schedule(250,0,RainbowAvatarLoop);

I'm not sure whats wrong so please help.
« Last Edit: January 08, 2011, 09:57:20 PM by Baeshra »

Ok, I just added the keybind like you said to but now nothing works, here's my current script...

I'm not sure whats wrong so please help.

Well, first of all the code does not look complete.  To put it in simple terms, if a block of code is opened with a "{", then it must be closed with a "}".  That means you code must end with a }, which it clearly does not.  Also, you didn't add a serverCmd at all, did you change your mind?  AlsoAlso: blockland has a very nice syntax debugger when you start up your server.  after closing the server, you look at the console.txt and look for when it executes your addon.  If it found a syntax error, it puts that error in a ##error## box.

In that code you have two key bindings, which one are you going to use?  Also, you have empty parentheses, {} like that.

You really don't need to mess with that code that you had, it looks like it already had bindings.