#1

guys i need to make antispam command for /shout and /me commands so the player should stay 10 sec. till using them again also i need when the player use shout or me it appear with their job colour
Reply
#2

Quote:
Originally Posted by Joe Vagos
Посмотреть сообщение
guys i need to make antispam command for /shout and /me commands so the player should stay 10 sec. till using them again also i need when the player use shout or me it appear with their job colour
pawn Код:
new ShoutTime[ MAX_PLAYERS ],
    MeTime[ MAX_PLAYERS ]; // top
   
#define ME_TIME     (10000) // 10 seconds at top
#define SHOUT_TIME  (10000) // 10 seconds at top

CMD:me( playerid, params[ ] )
{

    new szString[ 50 ];
    format( szString, sizeof( szString ), "Wait for %i seconds before using it again!", ( MeTime[ playerid ] - GetTickCount( ) )/1000 );

    if( MeTime[ playerid ] > GetTickCount( ) ) return SendClientMessage( playerid, -1, szString );

    MeTime[ playerid ] = GetTickCount( ) + ME_TIME; // he can't do it in the next 10 seconds
   
    if( isnull( params ) ) return SendClientMessage( playerid, -1, "Usage: /me [message]" );
   
    new szStr[ 128 ], szPname[ MAX_PLAYER_NAME ];
   
    GetPlayerName( playerid, szPname, sizeof( szPname ) );
   
    format( szStr, sizeof( szStr ), "* %s %s", szPname, params  );
    SendClientMessageToAll( -1, szStr );
    return 1;
}

CMD:shout( playerid, params[ ] )
{
    new szString[ 50 ];
    format( szString, sizeof( szString ), "Wait for %i seconds before using it again!", ( ShoutTime[ playerid ] - GetTickCount( ) )/1000 );

    if( ShoutTime[ playerid ] > GetTickCount( ) ) return SendClientMessage( playerid, -1, szString );

    ShoutTime[ playerid ] = GetTickCount( ) + SHOUT_TIME; // he can't do it in the next 10 seconds

    if( isnull( params ) ) return SendClientMessage( playerid, -1, "Usage: /shout [message]" );
   
    new szStr[ 128 ], szPname[ MAX_PLAYER_NAME ];

    GetPlayerName( playerid, szPname, sizeof( szPname ) );

    format( szStr, sizeof( szStr ), "* %s shouts %s", szPname, params  );
    SendClientMessageToAll( -1, szStr );
    return 1;
}
Heres your complete commands with antispam..
Reply
#3

Flcone srry but could u make it with
if(scanf......
Reply
#4

Quote:
Originally Posted by Joe Vagos
Посмотреть сообщение
Flcone srry but could u make it with
if(scanf......
This doesn't need sscanf it can be done with "if( isnull( params ) )" I edited my post and I think it should work.

Regards,
FalconX
Reply
#5

i need it in scanf cause i have my own code so i need it in scanf to adpt in ma code
Reply
#6

Quote:
Originally Posted by Joe Vagos
Посмотреть сообщение
i need it in scanf cause i have my own code so i need it in scanf to adpt in ma code
My dear this will work even if it isn't sscanf.... :/

Here you go:

pawn Код:
new ShoutTime[ MAX_PLAYERS ],
    MeTime[ MAX_PLAYERS ]; // top
   
#define ME_TIME     (10000) // 10 seconds at top
#define SHOUT_TIME  (10000) // 10 seconds at top

CMD:me( playerid, params[ ] )
{

    new szString[ 50 ];
    format( szString, sizeof( szString ), "Wait for %i seconds before using it again!", ( MeTime[ playerid ] - GetTickCount( ) )/1000 );

    if( MeTime[ playerid ] > GetTickCount( ) ) return SendClientMessage( playerid, -1, szString );

    MeTime[ playerid ] = GetTickCount( ) + ME_TIME; // he can't do it in the next 10 seconds

    new message[ 128 ];
    if( sscanf( params, "s[128]", message ) ) return SendClientMessage( playerid, -1, "/me [message]" );
   

    new szStr[ 128 ], szPname[ MAX_PLAYER_NAME ];

    GetPlayerName( playerid, szPname, sizeof( szPname ) );

    format( szStr, sizeof( szStr ), "* %s %s", szPname, message  );
    SendClientMessageToAll( -1, szStr );
    return 1;
}

CMD:shout( playerid, params[ ] )
{
    new szString[ 50 ];
    format( szString, sizeof( szString ), "Wait for %i seconds before using it again!", ( ShoutTime[ playerid ] - GetTickCount( ) )/1000 );

    if( ShoutTime[ playerid ] > GetTickCount( ) ) return SendClientMessage( playerid, -1, szString );

    ShoutTime[ playerid ] = GetTickCount( ) + SHOUT_TIME; // he can't do it in the next 10 seconds

    new message[ 128 ];
    if( sscanf( params, "s[128]", message ) ) return SendClientMessage( playerid, -1, "Usage: /shout [message]" );

    new szStr[ 128 ], szPname[ MAX_PLAYER_NAME ];

    GetPlayerName( playerid, szPname, sizeof( szPname ) );

    format( szStr, sizeof( szStr ), "* %s shouts %s", szPname, message  );
    SendClientMessageToAll( -1, szStr );
    return 1;
}
Reply
#7

C:\Users\joe\Desktop\pcash.pwn(302) : error 001: expected token: ";", but found "{"
C:\Users\joe\Desktop\pcash.pwn(325) : error 017: undefined symbol "MeTime"
C:\Users\joe\Desktop\pcash.pwn(325) : error 029: invalid expression, assumed zero
C:\Users\joe\Desktop\pcash.pwn(325) : error 029: invalid expression, assumed zero
C:\Users\joe\Desktop\pcash.pwn(325) : fatal error 107: too many error messages on one line

i use the me command only
Reply
#8

Quote:
Originally Posted by Joe Vagos
Посмотреть сообщение
C:\Users\joe\Desktop\pcash.pwn(302) : error 001: expected token: ";", but found "{"
C:\Users\joe\Desktop\pcash.pwn(325) : error 017: undefined symbol "MeTime"
C:\Users\joe\Desktop\pcash.pwn(325) : error 029: invalid expression, assumed zero
C:\Users\joe\Desktop\pcash.pwn(325) : error 029: invalid expression, assumed zero
C:\Users\joe\Desktop\pcash.pwn(325) : fatal error 107: too many error messages on one line

i use the me command only
Lines please?
Reply
#9

format( szString, sizeof( szString ), "Wait for %i seconds before using it again!", ( MeTime[ playerid ] - GetTickCount( ) )/1000 ); here is the line 325 ,, 302 is another error in ma code i will fix it
Reply
#10

Quote:
Originally Posted by Joe Vagos
Посмотреть сообщение
format( szString, sizeof( szString ), "Wait for %i seconds before using it again!", ( MeTime[ playerid ] - GetTickCount( ) )/1000 ); here is the line 325 ,, 302 is another error in ma code i will fix it
If you're using only ME command then did you put this at top?

pawn Код:
new MeTime[ MAX_PLAYERS ]; // top
   
#define ME_TIME     (10000) // 10 seconds at top
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)