Blockland Forums > Modification Help

ServerCmd Delay

Pages: (1/5) > >>

Jasa1:

How would I go about putting a delay between commands to prevent spamming? I am very clueless on how to do so. Simplest way please.

xcruso:


--- Quote from: Jasa1 on July 27, 2011, 04:00:43 PM ---How would I go about putting a delay between commands to prevent spamming? I am very clueless on how to do so. Simplest way please.

--- End quote ---

What he meant was that if someone say /stuff they have to wait 5 sec or more before they can do it again.

Jasa1:

I have a prototype

infiniteLoop:

It should look something like this


--- Code: ---function serverCmdSomeCommand(%client)
{
     %time = getSimTime();
     if(%client.lastTimeSomeCommand $= "" || %time - %client.lastTimeSomeCommand > 5000)
     {
          //your code here

          %client.lastTimeSomeCommand = %time;
     }
     else
     {
          messageClient(%client,'',"You can't use this command right now.");
     }

}
--- End code ---

This should work..

otto-san:


--- Code: ---function serverCmdDoSomething(%client)
{
  if(%client.somethingCooldown)
    return;
  //stuff
  %client.somethingCooldown = 1;
  schedule(5000,0,cooledDown,%client);
}

function cooledDown(%obj)
{
   %obj.somethingCooldown = 0;
}
--- End code ---

something like that but there's probably a better way to do it, i don't know if that works or not

Warning - while you were typing a new reply has been posted. You may wish to review your post.
ah i see

Pages: (1/5) > >>

Go to full version