/newbie command
#4

I wrote an example in a thread few hours ago and like I said there - it's always better to try avoiding timers as much as you can.

That should work.
pawn Код:
new
    Allow_Talk[ MAX_PLAYERS ]
;

public OnPlayerConnect( playerid )
{
    Allow_Talk[ playerid ] = -1;
    return 1;
}

CMD:newbie( playerid, params[ ] )
{
    if( IsPlayerAdmin( playerid ) ) return 1; // non-admins only - change to your variable if you want!
    if( isnull( params ) ) return SendClientMessage( playerid, -1, "Usage: /newbie <message>" );
    if( Allow_Talk[ playerid ] == -1 || ( Allow_Talk[ playerid ] != -1 && ( gettime( ) - Allow_Talk[ playerid ] ) > 30 ) )
    {
        // do your code here and.. send it to all/specific players, depending on your code
        Allow_Talk[ playerid ] = gettime( );
    }
    else if( Allow_Talk[ playerid ] != -1 && ( gettime( ) - Allow_Talk[ playerid ] ) <= 30 )
    {
        new
            error_msg[ 70 ]
        ;
        format( error_msg, sizeof( error_msg ), "Newbie chat: You have to wait %d seconds before using the chat again!", gettime( ) - Allow_Talk[ playerid ] );
        SendClientMessage( playerid, -1, error_msg );
    }
    return 1;
}
Reply


Messages In This Thread
/newbie command - by Wizzy951 - 30.09.2013, 19:00
Re: /newbie command - by Areax - 30.09.2013, 19:49
Re: /newbie command - by Pottus - 30.09.2013, 20:06
Re: /newbie command - by Konstantinos - 30.09.2013, 20:09
Re: /newbie command - by Wizzy951 - 30.09.2013, 20:17
Re: /newbie command - by Konstantinos - 01.10.2013, 08:44

Forum Jump:


Users browsing this thread: 1 Guest(s)