18.07.2018, 05:02
My Tested Script: https://imgur.com/a/Uu9w3WB
My Script:
My 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 5
#define GetPageCount(%0,%1) floatround(%1 / %0, floatround_floor) + 1
enum
{
DIALOG_BANLISTX,
DIALOG_InfoBan,
DIALOG_OK,
DIALOG_BAN_LIST
}
new SQL = -1, EroareDeConectare = 0;
new aswstring[2400];
new pLastPage[MAX_PLAYERS];
enum VarInfo
{
vName[255],
vNameBanList[255]
};
//new UniversalVar[1000][VarInfo];
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)
{
EroareDeConectare = 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
{
EroareDeConectare = 1;
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");
return 1;
}
public OnPlayerConnect(playerid)
{
if(EroareDeConectare == 0)
{
return 1;
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_OK: return 1;
case DIALOG_BAN_LIST:
{
if(!response) return 1;
else if(response)
{
pLastPage[playerid] ++;
ShowBanList(playerid);
}
}
}
return 1;
}
FC OnInfoBanCalled(playerid, Player[])
{
new Rows, Fields, DDay, DMonth, DYear, BReason[ 100 ], BAdmin[ 100 ], BBanDate[ 200 ], BBanTime[ 100 ], BBanDays[ 100 ], BID[ 100 ], BIP[ 100 ];
cache_get_data( Rows, Fields, SQL );
cache_get_field_content( 0, "Reason", BReason, 1, 100 );// MOTIV
cache_get_field_content( 0, "AdminName", BAdmin, 1, 100 );// ADN N
cache_get_field_content( 0, "BanTimeDate", BBanDate, 1, 200 );
cache_get_field_content( 0, "Permanent", BBanTime, 1, 100 );
cache_get_field_content( 0, "Days", BBanDays, 1, 100 );
cache_get_field_content( 0, "IP", BIP, 1, 100 );
cache_get_field_content( 0, "ID", BID, 1, 100 );
sscanf(BBanDate, "p<->ddd", DYear, DMonth, DDay);
format(aswstring, sizeof(aswstring), "{FF0000}- {FFFFFF}Cu motivul: {FF0000}'{FFFFFF}%s{FF0000}'\n{FF0000}- {FFFFFF}Data Banarii: {FF0000}'{FFFFFF}%d/%d/%d\n{FF0000}- {FFFFFF}Ban permanent (0= NU 1= DA): {FF0000}'{FFFFFF}%s{FF0000}'\n{FF0000}- {FFFFFF}UnBan dupa: {FF0000}'{FFFFFF}%s{FF0000}' {FFFFFF}zile", BReason, DDay, DMonth, DYear, BBanTime, BBanDays );
format(aswstring, sizeof(aswstring), "{FF0000}'{FFFFFF} Detalii jucator Banat: {FF0000}'{FF0000}%s{FF0000}'\n\n{FF0000}- {FFFFFF}ID Ban: {FF0000}'{FFFFFF}%s{FF0000}'\n{FF0000}- {FFFFFF}IP jucator Banat: {FF0000}'{FFFFFF}%s{FF0000}'\n{FF0000}- {FFFFFF}De catre Adminul: {FF0000}'{FFFFFF}%s{FF0000}'\n%s", Player, BID, BIP, BAdmin, aswstring );
ShowPlayerDialog(playerid, DIALOG_InfoBan, DIALOG_STYLE_MSGBOX, "{FFFFFF}IBan Sistem:", aswstring, "OK", "");
return ( 1 );
}
CMD:banlist(playerid, params[])
{
new strt[226];
format(strt, sizeof(strt), "SELECT * FROM `bans` WHERE `ID` > 0");
mysql_tquery(SQL, strt, "ShowBanList", "");
pLastPage[playerid] = 1;
return 1;
}
FC ShowBanList(playerid)
{
new OnName[ MAX_PLAYER_NAME ], OnName2[ MAX_PLAYER_NAME ], BBanDate[200];
new IDD = cache_num_rows();
new title[128], string[300], pages = GetPageCount(MAX_RESULTS, IDD) ,resultcount = ((MAX_RESULTS * pLastPage[playerid]) - MAX_RESULTS), bool:nextpage = false;
strcat(string, "ID\tName\tAName\tDate");
new sdg[226];
format(sdg, sizeof(sdg), "%d | %d", pages, IDD);
SCM(playerid, -1, sdg);
for(new i = resultcount; i < IDD; i ++)
{
resultcount ++;
cache_get_field_content( i, "PlayerName", OnName );
cache_get_field_content( i, "AdminName", OnName2 );
cache_get_field_content( i, "BanTimeDate", BBanDate, 1, 200 );
if(resultcount <= MAX_RESULTS * pLastPage[playerid])
{
format(string, sizeof(string), "%s\n%d\t%s\t%s\t%s", string, resultcount, OnName, OnName2, BBanDate);
// SCM(playerid, -1, string);
}
if(resultcount > MAX_RESULTS * pLastPage[playerid])
{
nextpage = true;
break;
}
}
format(title, sizeof(title), "{FFFF00}Bans - Page %d of %d", pLastPage[playerid], pages);
if(nextpage) return ShowPlayerDialog(playerid, DIALOG_BAN_LIST, DIALOG_STYLE_TABLIST_HEADERS, title, string, "Next", "Close");
return ShowPlayerDialog(playerid, DIALOG_OK, DIALOG_STYLE_TABLIST_HEADERS, title, string, "Select", "Cancel");
}
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;
}

