Optimization
#1

pawn Код:
new
      string[ 80 ];

    new ip[ 128 ];
    GetPlayerIp(playerid, ip, 24);

    format      ( string, 80,
             "SELECT `ip` FROM `banai` WHERE `ip`='%s' LIMIT 1",
                      ip );
    mysql_query    ( string );
    mysql_store_result( );

    if ( mysql_fetch_row( string ) )
    {
            format           ( string, 62,
                              "SELECT * FROM `banai` WHERE `ip`='%s'",
                          ip );
            mysql_query    ( string );
            mysql_store_result( );

            new
              line[ 512 ],
                priezastis[64],
                admin[24],
                data[64],
                tmp;

      mysql_fetch_row_format( line, "|" );
      sscanf        ( line, "p<|>s[128]s[64]s[24]s[64]",
      tmp,
      priezastis,
      admin,
      data
      );
      SendClientMessage( playerid, COLOR_GREY, " " );
      SendClientMessage( playerid, COLOR_GREY, " " );
      SendClientMessage( playerid, COLOR_GREY, " " );
      SendClientMessage( playerid, COLOR_GREY, " " );
      SendClientMessage( playerid, COLOR_GREY, " " );
      SendClientMessage( playerid, COLOR_GREY, " " );
      SendClientMessage( playerid, COLOR_RED, "Tu esi uюbanintas");
      format(line, sizeof(line), "Prieюastis: %s", priezastis);
      SendClientMessage(playerid, COLOR_RED, line);
      format(line, sizeof(line), "Administratorius: %s",admin);
      SendClientMessage(playerid, COLOR_RED, line);
      format(line, sizeof(line), "Data: %s",data);
      SendClientMessage(playerid, COLOR_RED, line);
      SendClientMessage( playerid, COLOR_GREY, " " );
      SendClientMessage( playerid, COLOR_GREY, " " );
      Kick( playerid );
    }
This code checks if players ip is in database table "banai",
sends some messages if true, and kicks player.

Is this the fastest way to do this?
maybe there is some more optimized ways?

- Simas
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)