18.07.2018, 15:11
Not working..
ScreenShot: https://imgur.com/a/9hcqr65
Script:
ScreenShot: https://imgur.com/a/9hcqr65
Script:
PHP код:
#include <a_samp>
#include <sscanf2>
#include <a_mysql>
#include <zcmd>
#define FC%0(%1) forward%0(%1); public%0(%1)
#define SCM SendClientMessage
#define MAX_STRING 2400
#define MAX_RESULTS 3
new gTotalBans;
new pLastPage[MAX_PLAYERS];
enum
{
DIALOG_BAN_LIST2
}
new SQL = -1;
main()
{
print("New Project");
}
public OnGameModeInit()
{
mysql_log(LOG_ERROR | LOG_WARNING, LOG_TYPE_HTML);
SQL = mysql_connect("localhost","root","test","");
if(mysql_errno(SQL) != 0)
{
print( " ");
print( " ");
print( " ");
print( " #########################################################" );
print( " # #" );
print( " # _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ #" );
print( " # _I_N_F_O_ _S_E_R_V_E_R_ _L_O_A_D_S_ #" );
print( " # #" );
print( " # __________________________________________________ #" );
print( " # MySQL: Failed to connect to the database! (Error) #");
print( " # __________________________________________________ #" );
print( " # Shut up as something went wrong, please check! #" );
print( " # __________________________________________________ #" );
print( " # Thank you for using Script Gold. #" );
print( " # __________________________________________________ #" );
print( " # #" );
print( " # #" );
print( " #########################################################" );
print( " ");
print( " ");
}
else
{
print( " ");
print( " ");
print( " ");
print( " #########################################################" );
print( " # #" );
print( " # _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ #" );
print( " # _I_N_F_O_ _S_E_R_V_E_R_ _L_O_A_D_S_ #" );
print( " # #" );
print( " # __________________________________________________ #" );
print( " # MySQL: Connect to the successful database! #");
print( " # __________________________________________________ #" );
print( " # Thank you for using Script Gold. #" );
print( " # __________________________________________________ #" );
print( " # #" );
print( " #########################################################" );
print( " ");
print( " ");
}
SetGameModeText("NEW Project");
mysql_tquery(SQL, "SELECT COUNT(*) FROM bans;", "OnTotalBansNumberLoad", "");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_BAN_LIST2:
{
if (response)
{
if (MAX_RESULTS + 1 == listitem)
{
// player selected "Next Page");
new strt[226];
format(strt, sizeof(strt), "SELECT * FROM `bans` WHERE `ID` > 0 LIMIT %d,%d", pLastPage[playerid] * MAX_RESULTS, MAX_RESULTS);
mysql_tquery(SQL, strt, "ShowBanList2", "d", playerid);
pLastPage[playerid]++;
}
}
else pLastPage[playerid] = 0;
}
}
return 1;
}
FC OnTotalBansNumberLoad()
{
gTotalBans = cache_get_row_int(0, 0, SQL);
}
CMD:banlist2(playerid, params[])
{
new strt[126];
pLastPage[playerid] = 0;
format(strt, sizeof(strt), "SELECT * FROM `bans` WHERE `ID` > 0 LIMIT 0,%d", MAX_RESULTS);
mysql_tquery(SQL, strt, "ShowBanList2", "d", playerid);
return 1;
}
FC ShowBanList2(playerid)
{
pLastPage[playerid] = 1; //set first page at top
new OnName[ MAX_PLAYER_NAME ], OnName2[ MAX_PLAYER_NAME ], BBanDate[200];
new title[128], string[300];
string = "ID\tName\tAName\tDate";
for(new i = 0, j = cache_num_rows(); i < j; i ++)
{
cache_get_field_content( i, "PlayerName", OnName );
cache_get_field_content( i, "AdminName", OnName2 );
cache_get_field_content( i, "BanTimeDate", BBanDate, 1, 200 );
format(string, sizeof(string), "%s\n%d\t%s\t%s\t%s\n", string, i + 1, OnName, OnName2, BBanDate);
}
if (gTotalBans > pLastPage[playerid] * MAX_RESULTS) //Total bans 5 > 3 (page 1 * 3 items per page) so last option is "Next Page"
{
strcat(string, "Next Page");
}
format(title, sizeof(title), "{FFFF00}Bans - Page %d of %d", pLastPage[playerid], floatround(float(gTotalBans) / float(MAX_RESULTS), floatround_ceil));
ShowPlayerDialog(playerid, DIALOG_BAN_LIST2, DIALOG_STYLE_TABLIST_HEADERS, title, string, "OK", "Close");
return 1;
}
public OnQueryError( errorid, error[ ], callback[ ], query[ ], connectionHandle )
{
print( "====================================================================" );
printf( "Error ID: %d, Error: %s", errorid, error );
printf( "Callback: %s", callback );
printf( "gQuery: %s", query );
print( "====================================================================" );
return 1;
}