repeating announcements

Author Topic: repeating announcements  (Read 1298 times)

i am modifying the admin slay command so i know if someone used it and i found that when i use slay all (/slayall) it repeates the message alot can some one help
Code: [Select]
function serverCmdSlay(%client, %victim)
{
if(%client.isSuperAdmin) {
   if(%victim $= "")
  {
      messageClient(%client, "", "\c0One or more of the required fields has been left blank.");
      return;
   }

   for(%i = 0; %i < ClientGroup.getCount(); %i++)
   {
      %cl = ClientGroup.getObject(%i);
      if(%cl.name $= %victim && isObject(%cl.player))
      {
          %cl.player.kill();
          announce("A person has died.");
          break;
      }
}
}
}
function serverCmdSlayID(%client, %victim)
{
if(%client.isSuperAdmin) {
   if(%victim <= 0)
  {
      messageClient(%client, "", "\c0One or more of the required fields has been left blank.");
      return;
   }

   for(%i = 0; %i < ClientGroup.getCount(); %i++)
   {
      %cl = ClientGroup.getObject(%i);
      if(%cl.bl_id $= %victim && isObject(%cl.player))
      {
          %cl.player.kill();
           announce("A person has died.");
           break;
      }
}
}
}
function serverCmdSlayAll(%client)
{
if(%client.isSuperAdmin)
{
   for(%i = 0; %i < ClientGroup.getCount(); %i++)
   {
      %cl = ClientGroup.getObject(%i);
      if(isObject(%cl.player))
      {
          %cl.player.kill();
          announce("Everyone  has died.");
      }
}
}
}
« Last Edit: February 19, 2008, 09:05:23 PM by General Omega »

Well first of all
YOUR DOING IT WRONG
and wanyways
its because you have the announcement in the for() loop, so everytime it runs through the loop it says it again(once per player I believe). Move it out of the loop.

Just a tip : use FindClientByName and FindClientByID

Just a tip : thats a script that was made a VERY long time ago by several members of the community, he's just editing it, horribly.

1 i tried the message to client cmd and it killed run time i tried to make it ony show up once by makeing it execute inividually but no luck any ideas it is for personal use and i want the code not tips if you say i should make it say

       %cl = ClientGroup.getObject(%i);
      if(isObject(%cl.player))
      {
          %cl.player.kill();
      }
     {
      announce("Everyone  has died.");
     }


 
then why didnt you say so
« Last Edit: February 21, 2008, 07:07:26 PM by General Omega »

i want the code not tips

So, what? You want others to do it for you? If you mean something else by this, use punctuation in your message so we can see that there is more to that quote.

General, go take a coding class, we're not going to give you code beyond our own add-ons we release. Also you still have it wrong, thats not what I was implying, and I'm not going give you it if its something that simple. If it were something more than moving a line out of the For() loop, I would help more than just saying "move the announcement out of the For() loop".

I would give you tips but you seem to despise them too much.

If no one helps him, he won't try and rip off other people's scripts successfully, but will wallow in his pool of failure.

If no one helps him, he won't try and rip off other people's scripts successfully, but will wallow in his pool of failure.

He must have a large pool since hes still here...

did i not metion above it is for personal use

doesnt change anything.

screw you guys i fixed it on my own

Where was the "I'm in a bit of a pickle"?

screw you guys i fixed it on my own
I bet your going to distribute it to nubs and make the hacked-out add-ons situation even worse than it is currently.

nope i just wanted the announcement to find out what they typed in