SA-MP Forums Archive
Optimization - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Optimization (/showthread.php?tid=124705)



Optimization - kLx - 31.01.2010

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