13.02.2014, 16:44
I suggest you using gettime instead of GetTickCount, GetTickCount returns in milliseconds and gettime returns in seconds, also check the disadvantages about GetTickCount, you also need a new variable, so the message won't spam. example code below.
pawn Код:
#include <a_samp>
#if defined MAX_PLAYERS
#undef MAX_PLAYERS
#define MAX_PLAYERS (255)
#endif
static stock
tick[ MAX_PLAYERS char ], bool:tickSpam[ MAX_PLAYERS char];
public OnPlayerUpdate(playerid)
{
if( (gettime( ) - tick{playerid} > 5) && ( !tickSpam{ playerid } ) )
{
tickSpam{ playerid } = true;
SendClientMessage( playerid, -1, "Command Status: UnAvailable" );
}
else if( (gettime( ) - tick{ playerid } < 5) && ( tickSpam{ playerid } ) )
{
tickSpam{ playerid } = false;
SendClientMessage( playerid, -1, "Command Status: Available" );
}
return true;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_ACTION)
{
// rest of the code.
tick{ playerid } = gettime( );
}
return true;
}