Time delay on commands
#2

Could remove the timers and use GetTickCount.

pawn Код:
// Global Variable
new CommandTimeStamp[ MAX_PLAYERS ];

// OnPlayerConnect
CommandTimeStamp[ MAX_PLAYERS ] = 0;

// OnPlayerCommandText
if ( !strcmp( "/mycommand", cmdtext, true ) )
{
  if ( ( GetTickCount() - CommandTimeStamp[ playerid ] ) < 10000 ) // If difference in time is less than 10000 ms (10 seconds)
    return SendClientMessage( playerid, "You must wait 10 seconds before using this command again." );
  else
  {
    CommandTimeStamp[ playerid ] = GetTickCount( );
   
    // Your code!
  }
}
Reply


Messages In This Thread
Time delay on commands - by lol2112 - 26.05.2009, 21:20
Re: Time delay on commands - by Simon - 27.05.2009, 11:49
Re: Time delay on commands - by lol2112 - 27.05.2009, 12:01
Re: Time delay on commands - by yom - 27.05.2009, 12:10
Re: Time delay on commands - by lol2112 - 27.05.2009, 12:26
Re: Time delay on commands - by yom - 27.05.2009, 12:45
Re: Time delay on commands - by lol2112 - 27.05.2009, 13:25
Re: Time delay on commands - by yom - 27.05.2009, 14:06
Re: Time delay on commands - by lol2112 - 27.05.2009, 14:33
Re: Time delay on commands - by yom - 27.05.2009, 14:37

Forum Jump:


Users browsing this thread: 1 Guest(s)