Author Topic: Making an emote - Need control help  (Read 2445 times)

I am making a new emote, and I was hoping to get it to appear when the user presses a control. Just like the other emotes, I want it to be able to do the following:

- Appear in the control list in options, and get remapped to whatever key the user wants
- Appear above the player when the user types in  a command in the chat box (for example /alarm)

I am very new to coding and wish to get a grip on addon making, so I need to know where to put the code and (if you don't mind) how it works.


Credit will be given.

Client-side code
Code: [Select]
$remapDivision[$remapCount] = "Category Name";
$remapName[$remapCount] = "Emote Name";
$remapCmd[$remapCount] = "emoteFunction";
$remapCount++;

function emoteFunction(%val)
{
if(%val)
{
                commandtoserver('emoteFunction');
}
}


Server-side code
Code: [Select]
function serverCmdEmoteFunction(%client)
{
    //code to show emote
}

You mean that *censored* you showed me? You'll also need to solve the problem of how it layers itself 50 times and makes it look like some *censored* mass...

The only way I could tell it was an *censored* was when you cleared the *censored*. As if faded, I saw *censored* in it.
« Last Edit: September 20, 2008, 05:44:26 PM by MegaScience »

Megascience - One step at a time. Also I would appreciate it if you don't go running around saying the things I want to make. I purposefully didn't type "I AM MAKING A *Censor lul* EMOTE" because if I don't finish it I don't want someone else picking it up and doing it.



So would the server code go in the server file, and client code go in the emote_*Censor lul*.cs  file?  Also under "emote_funciton" what do I put there? Im not sure what part of the script makes the emote show up! :/
« Last Edit: September 20, 2008, 05:53:18 PM by IcyGamma »

If you want to add it to the existing Emotes division in the controls Gui, here's a script I made for Jervan:

Code: [Select]
function AddBind(%division, %name, %command)
{
for(%i=0;%i<$remapCount;%i++)
{
if($remapDivision[%i] $= %division)
{
%foundDiv = 1;
continue;
}
if(%foundDiv && $remapDivision[%i] !$= "")
{
%position = %i;
break;
}
}
if(!%foundDiv)
{
error("Division not found: " @ %division);
return;
}
if(!%position)
{
$remapName[$remapCount] = %name;
$remapCmd[$remapCount] = %command;
$remapCount++;
return;
}
for(%i=$remapCount;%i>%position;%i--)
{
$remapDivision[%i] = $remapDivision[%i - 1];
$remapName[%i] = $remapName[%i - 1];
$remapCmd[%i] = $remapCmd[%i - 1];
}
$remapDivision[%position] = "";
$remapName[%position] = %name;
$remapCmd[%position] = %command;
$remapCount++;
}

Use it like so:
Code: [Select]
if(!$YourCmdMapped){
AddBind("Emotes", "New Emote Name", "EmoteFunction");
$YourCmdMapped = 1;
}

What do I put in %division?

You mean that *censored* you showed me? You'll also need to solve the problem of how it layers itself 50 times and makes it look like some *censored* mass...

The only way I could tell it was an *censored* was when you cleared the *censored*. As if faded, I saw *censored* in it.
I censored it, you should censor, too.
« Last Edit: September 20, 2008, 05:51:52 PM by MegaScience »

Also censor your quote. :3

Megascience - One step at a time. Also I would appreciate it if you don't go running around saying the things I want to make. I purposefully didn't type "I AM MAKING A *Censor lul* EMOTE" because if I don't finish it I don't want someone else picking it up and doing it.



So would the server code go in the server file, and client code go in the emote_*Censor lul*.cs  file?  Also under "emote_funciton" what do I put there? Im not sure what part of the script makes the emote show up! :/
You forgot one!
« Last Edit: September 20, 2008, 05:54:59 PM by MegaScience »

What do I put in %division?

Also under "emote_funciton" what do I put there? Im not sure what part of the script makes the emote show up! :/

Change the stuff that's coloured to names specific to your emote. Things that are the same colour should match.
Quote from: Client-side code
// This function adds a key binding to an existing division
function AddBind(%division, %name, %command)
{
   for(%i=0;%i<$remapCount;%i++)
   {
      if($remapDivision[%i] $= %division)
      {
         %foundDiv = 1;
         continue;
      }
      if(%foundDiv && $remapDivision[%i] !$= "")
      {
         %position = %i;
         break;
      }
   }
   if(!%foundDiv)
   {
      error("Division not found: " @ %division);
      return;
   }
   if(!%position)
   {
      $remapName[$remapCount] = %name;
      $remapCmd[$remapCount] = %command;
      $remapCount++;
      return;
   }
   for(%i=$remapCount;%i>%position;%i--)
   {
      $remapDivision[%i] = $remapDivision[%i - 1];
      $remapName[%i] = $remapName[%i - 1];
      $remapCmd[%i] = $remapCmd[%i - 1];
   }
   $remapDivision[%position] = "";
   $remapName[%position] = %name;
   $remapCmd[%position] = %command;
   $remapCount++;
}

// This adds the bind to the controls gui (using the above function)
if(!$YourCmdMapped)
{
   AddBind("Emotes", "New Emote Name", "EmoteFunction");
   $YourCmdMapped = 1;
}

// This is the function which is called when the user presses the key bound to this command
function EmoteFunction(%val)
{
   // Tell the server to display the emote
   if(%val)
      commandtoserver('EmoteCmd');
}

Quote from: Server-side code
function serverCmdEmoteCmd(%client)
{
   if(isObject(%client.player))
      %client.player.emote(EmoteImage);
}
« Last Edit: September 20, 2008, 06:13:35 PM by Randy »

Problem - what is the code to show emote? I am using "emote_alarm" as a template!

Added it to the main script.

I keep getting:

Quote
serverCmdEmoteCmd:  Unknow Command.

1: Don't name it EmoteCmd, that's what you replace with the command name for /
2: Scroll up and look for any errors in the script.