Emote problem

Author Topic: Emote problem  (Read 1250 times)

I made an emote, and set it to play for a reaaaaallly loooong time when you type "/afk". I want to know if it's possible to make it so the emote stops if I type "/afk" again. Could someone help me make this happen? Here's the code

Quote
//Emote_Afk.cs
// type /afk, get z's

function serverCmdafk(%client)
{
   if(isObject(%client.player))
      %client.player.emote(afkImage);
}

datablock ParticleData(afkParticle)
{
   dragCoefficient      = 5.0;
   gravityCoefficient   = -0.2;
   inheritedVelFactor   = 0.0;
   constantAcceleration = 0.0;
   lifetimeMS           = 1000;
   lifetimeVarianceMS   = 500;
   useInvAlpha          = true;
   textureName          = "base/data/particles/afk";
   colors[0]     = "0.0 0.0 0.0 1.0";
   colors[1]     = "0.0 0.0 0.0 1.0";
   colors[2]     = "0.0 0.0 0.0 1.0";
   sizes[0]      = 0.5;
   sizes[1]      = 0.5;
   sizes[2]      = 0.5;
   times[0]      = 1.0;
   times[1]      = 1.0;
   times[2]      = 1.0;
};

datablock ParticleEmitterData(afkEmitter)
{
   ejectionPeriodMS = 2500;
   periodVarianceMS = 0;
   ejectionVelocity = 0.5;
   ejectionOffset   = 1.0;
   velocityVariance = 0.49;
   thetaMin         = 0;
   thetaMax         = 120;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "afkParticle";

   uiName = "Emote - Afk";
};

datablock ShapeBaseImageData(afkImage)
{
   shapeFile = "base/data/shapes/empty.dts";
   emap = false;

   mountPoint = $HeadSlot;

   stateName[0]               = "Ready";
   stateTransitionOnTimeout[0]      = "FireA";
   stateTimeoutValue[0]         = 0.01;

   stateName[1]               = "FireA";
   stateTransitionOnTimeout[1]      = "Done";
   stateWaitForTimeout[1]         = True;
   stateTimeoutValue[1]         = 1000000000.0;
   stateEmitter[1]               = afkEmitter;
   stateEmitterTime[1]            = 1000000000.0;

   stateName[2]               = "Done";
   stateScript[2]               = "onDone";
};
function afkImage::onDone(%this,%obj,%slot)
{
   %obj.unMountImage(%slot);
}

Code: [Select]
function serverCmdafk(%client)
{
   if(isObject(%client.player)){
      if(%client.isafk==0){
      %client.player.emote(afkImage);
      %client.isafk=1;
      }else{
      %client.player.emote(hateImage);
      %client.isafk=0;
      }}
}

Umm, 2 things.

1. Where would I put this code?

2.
Code: [Select]
function serverCmdafk(%client)
{
   if(isObject(%client.player)){
      if(%client.isafk==0){
      %client.player.emote(afkImage);
      %client.isafk=1;
      }else{
      %client.player.emote([color=Red]hate[/color]Image);
      %client.isafk=0;
      }}
}
Shouldn't that be afk?

No. That code:
1. Mounts the emote.
2. If the emote is mounted, replaces it with hate (which will disappear).

No. That code:
1. Mounts the emote.
2. If the emote is mounted, replaces it with hate (which will disappear).
(I'm sorry, I'm an utter noob at coding...)
So what would I do with that code?

Copypasta into the bottom of your emote script, I think.


Code: [Select]
function serverCmdafk(%client)
{
   if(isObject(%client.player)){
      if(%client.isafk==0){
      %client.player.emote(afkImage);
      %client.isafk=1;
      echo("AFK works");
      }else{
      %client.player.emote(hateImage);
      %client.isafk=0;
      }}
}
Try it. If 'AFK works' shows up in your console, the code works.

Unless, of course, I did it wrong.

Quote
//Emote_Afk.cs
// type /afk, get z's

function serverCmdafk(%client)
{
   if(isObject(%client.player)){
      if(%client.isafk==0){
      %client.player.emote(afkImage);
      %client.isafk=1;
      }else{
      %client.player.emote(hateImage);
      %client.isafk=0;
      }}
}
datablock ParticleData(afkParticle)
{
   dragCoefficient      = 5.0;
   gravityCoefficient   = -0.2;
   inheritedVelFactor   = 0.0;
   constantAcceleration = 0.0;
   lifetimeMS           = 1000;
   lifetimeVarianceMS   = 500;
   useInvAlpha          = true;
   textureName          = "base/data/particles/afk";
   colors[0]     = "0.0 0.0 0.0 1.0";
   colors[1]     = "0.0 0.0 0.0 1.0";
   colors[2]     = "0.0 0.0 0.0 1.0";
   sizes[0]      = 0.5;
   sizes[1]      = 0.5;
   sizes[2]      = 0.5;
   times[0]      = 1.0;
   times[1]      = 1.0;
   times[2]      = 1.0;
};

datablock ParticleEmitterData(afkEmitter)
{
   ejectionPeriodMS = 2500;
   periodVarianceMS = 0;
   ejectionVelocity = 0.5;
   ejectionOffset   = 1.0;
   velocityVariance = 0.49;
   thetaMin         = 0;
   thetaMax         = 120;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "afkParticle";

   uiName = "Emote - Afk";
};

datablock ShapeBaseImageData(afkImage)
{
   shapeFile = "base/data/shapes/empty.dts";
   emap = false;

   mountPoint = $HeadSlot;

   stateName[0]               = "Ready";
   stateTransitionOnTimeout[0]      = "FireA";
   stateTimeoutValue[0]         = 0.01;

   stateName[1]               = "FireA";
   stateTransitionOnTimeout[1]      = "Done";
   stateWaitForTimeout[1]         = True;
   stateTimeoutValue[1]         = 1000000000.0;
   stateEmitter[1]               = afkEmitter;
   stateEmitterTime[1]            = 1000000000.0;

   stateName[2]               = "Done";
   stateScript[2]               = "onDone";
};
function afkImage::onDone(%this,%obj,%slot)
{
   %obj.unMountImage(%slot);
}