SA-MP Forums Archive
hey - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: hey (/showthread.php?tid=367376)



hey - Joe Vagos - 09.08.2012

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


Re: hey - FalconX - 09.08.2012

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..


Re: hey - Joe Vagos - 09.08.2012

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


Re: hey - FalconX - 09.08.2012

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


Re: hey - Joe Vagos - 09.08.2012

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


Re: hey - FalconX - 09.08.2012

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;
}



Re: hey - Joe Vagos - 09.08.2012

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


Re: hey - FalconX - 09.08.2012

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?


Re: hey - Joe Vagos - 09.08.2012

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


Re: hey - FalconX - 09.08.2012

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