PDA

View Full Version : Problem show dialog!


Cerealguy
01/12/2016, 05:14 AM
BanCheck(playerid)
{
new
retrieveName[MAX_PLAYER_NAME],
retrieveBannedBy[MAX_PLAYER_NAME],
retrieveReason[50],
retrieveBanDate,
retrieveDuration,
retrieveGCPI[60],
retrieveIP[16 + 1],
Query[380]
;

GetPlayerIp(playerid, retrieveIP, sizeof(retrieveIP));
gpci(playerid, retrieveGCPI, sizeof(retrieveGCPI));

format(Query, sizeof(Query), "SELECT * FROM `Bans` WHERE `Name` = '%q' COLLATE NOCASE OR `GPCI` = '%q' OR `IP` = '%q' LIMIT 1", GetPlayerName(playerid), retrieveGCPI, retrieveIP);
queryresult = db_query(Database, Query);

if(db_num_rows(queryresult))
{
db_get_field_assoc(queryresult, "Name", retrieveName, sizeof(retrieveName));
db_get_field_assoc(queryresult, "BannerName", retrieveBannedBy, sizeof(retrieveBannedBy));
db_get_field_assoc(queryresult, "Reason", retrieveReason, sizeof(retrieveReason));
retrieveBanDate = db_get_field_assoc_int(queryresult, "BANDATE");
retrieveDuration = db_get_field_assoc_int(queryresult, "UNBANDATE");

if(gettime() - retrieveDuration > (retrieveDuration - retrieveBanDate))
{
format(Query, sizeof(Query), "Your ban expired on %s \nWelcome back %s!", TimestampToDateTime(retrieveDuration), GetPlayerName(playerid));
SendClientMessage(playerid, COLOR_SERVER, Query);
//Remove ban fuction heree working bla bla
}
else
{

format(Query, sizeof(Query), "\
"COL_RED"Username: "COL_WHITE"%s\n\
"COL_RED"Banned IP: "COL_WHITE"%s\n\
"COL_RED"Admin banned you: "COL_WHITE"%s\n\
"COL_RED"Reason of Ban: "COL_WHITE"%s\n\
"COL_RED"Date of Ban: "COL_WHITE"%s\n\
"COL_RED"Date of Unban: "COL_WHITE"%s", retrieveName, retrieveIP, retrieveBannedBy,
retrieveReason, TimestampToDateTime(retrieveBanDate), TimestampToDateTime(retrieveDuration));
ShowPlayerDialog(playerid, 500, DIALOG_STYLE_MSGBOX, "Account Banned!", Query, "Exit", "");

defer KickEx(playerid);
return 1;
}
}
return 1;
}

public OnPlayerConnect(playerid)
{

SendDeathMessage(INVALID_PLAYER_ID, playerid, 200);
for( new i; i < _: PlayerInfo; ++i ) pInfo[ playerid ][ PlayerInfo: i ] = 0;
//------------------[ANTI-BOTS]------------------
new ConnIP[16];
GetPlayerIp(playerid,ConnIP,16);
new compare_IP[16];
new number_IP = 0;
for(new i=GetPlayerPoolSize(); i != -1; i--) {
if(IsPlayerConnected(i)) {
GetPlayerIp(i,compare_IP,16);
if(!strcmp(compare_IP,ConnIP)) number_IP++;
}
}
if((GetTickCount() - Join_Stamp) < Time_Limit)
exceed=1;
else
exceed=0;
if(strcmp(ban_s, ConnIP, false) == 0 && exceed == 1 )
{
Same_IP++;
if(Same_IP > SAME_IP_CONNECT)
{
BanEx(playerid, "BOTS");
Same_IP=0;
}
}
else
{
Same_IP=0;
}
if(number_IP > IP_LIMIT)
Kick(playerid);
GetStampIP(playerid);

if(IsPlayerNPC(playerid))
{
new server_IP[16];
format(server_IP, 16, "127.0.0.1");

if(strcmp(ConnIP,server_IP,true) != 0)
{
BanEx(playerid, "BOTS"); // Ban is the safest thing here, as if you kick, they can still flood you with endless connections
return 0;
}
}
//----------------------------------------------
//-------------[CHECK BAN]--------------
BanCheck(playerid);
//----------------------------------------------
//-------------[Login-Register]--------------
new
Query[ 256 ] // Create a Query
;

pInfo[playerid][USER_LOGGED_IN] = false;


format(Query, sizeof(Query), "SELECT `Username` FROM `users` WHERE `Username` = '%s' COLLATE NOCASE", DB_Escape(GetPlayerName(playerid)));

queryresult = db_query(Database, Query);

if(db_num_rows(queryresult))
{

format(Query, sizeof(Query), ""COL_WHITE"Welcome, this account ("COL_BLUE"%s)"COL_WHITE" is registered\nPlease enter the password to login\n\n"COL_GRIS"If you are not the owner of this account, leave and rejoin with a different nickname", GetPlayerName(playerid), playerid);

ShowPlayerDialog(playerid, dlogin, DIALOG_STYLE_PASSWORD, ""COL_BLUE"Login Panel", Query, "Login", "Leave");
}
else
{

format(Query, sizeof(Query), ""COL_WHITE"Welcome, this account ("COL_RED"%s)"COL_WHITE" is not registered\nPlease enter your desired password for this account\n\n"COL_GRIS"Once you are registered, do not share your password with anyone besides yourself!", GetPlayerName(playerid), playerid);
ShowPlayerDialog(playerid, dregister, DIALOG_STYLE_PASSWORD, ""COL_BLUE"Register Panel", Query, "Register", "Leave");
}
db_free_result(queryresult);
return 1;
}


Help!!, It disconnects me but does not show the Account Banned dialog, Show the login panel dialogs :S. I need Check ban an return Account Banned dialog with information no login panel dialog, please help :c T.T

Alpay0098
01/12/2016, 10:48 AM
Idk why you wanna break the back of yours.
Just set a timer and put that Kick function in that timer function.
Its much more classy and easy to solve.

Cerealguy
02/12/2016, 03:18 AM
Idk why you wanna break the back of yours.
Just set a timer and put that Kick function in that timer function.
Its much more classy and easy to solve.

I do not need it to look elegant just that it works, and if you do not comment on any possible solution to the problem, do not comment

ImVictor
02/12/2016, 03:23 AM
He is right bro, probably the dialog is showing right before you get kicked, just create a timer with 500 ticks or something and it might work.

Cerealguy
02/12/2016, 03:32 AM
defer KickEx(playerid); it a kick timer (500) the problem is that instead of seeing the ban dialog, you see the login panel dialog

Logic_
02/12/2016, 03:35 AM
You need to add a return 1 in the ban check cuffs to avoid running the code below.

EDIT: add register/ login dialog in the ban check function?

Cerealguy
02/12/2016, 03:41 AM
Check! i have return 1.. and no i not add register/login in the bancheck. Check i paste my code!! In OnPlayer connect i have before Bancheck fuction and after my normal register / login


public OnPlayerConnect(playerid)
{

SendDeathMessage(INVALID_PLAYER_ID, playerid, 200);
for( new i; i < _: PlayerInfo; ++i ) pInfo[ playerid ][ PlayerInfo: i ] = 0;
//------------------[ANTI-BOTS]------------------
new ConnIP[16];
GetPlayerIp(playerid,ConnIP,16);
new compare_IP[16];
new number_IP = 0;
for(new i=GetPlayerPoolSize(); i != -1; i--) {
if(IsPlayerConnected(i)) {
GetPlayerIp(i,compare_IP,16);
if(!strcmp(compare_IP,ConnIP)) number_IP++;
}
}
if((GetTickCount() - Join_Stamp) < Time_Limit)
exceed=1;
else
exceed=0;
if(strcmp(ban_s, ConnIP, false) == 0 && exceed == 1 )
{
Same_IP++;
if(Same_IP > SAME_IP_CONNECT)
{
BanEx(playerid, "BOTS");
Same_IP=0;
}
}
else
{
Same_IP=0;
}
if(number_IP > IP_LIMIT)
Kick(playerid);
GetStampIP(playerid);

if(IsPlayerNPC(playerid))
{
new server_IP[16];
format(server_IP, 16, "127.0.0.1");

if(strcmp(ConnIP,server_IP,true) != 0)
{
BanEx(playerid, "BOTS"); // Ban is the safest thing here, as if you kick, they can still flood you with endless connections
return 0;
}
}
//----------------------------------------------
//-------------[CHECK BAN]--------------
BanCheck(playerid);
//----------------------------------------------
//-------------[Login-Register]--------------
new
Query[ 256 ]
;

pInfo[playerid][USER_LOGGED_IN] = false;


format(Query, sizeof(Query), "SELECT `Username` FROM `users` WHERE `Username` = '%s' COLLATE NOCASE", DB_Escape(GetPlayerName(playerid)));

queryresult = db_query(Database, Query);

if(db_num_rows(queryresult))
{

format(Query, sizeof(Query), ""COL_WHITE"Welcome, this account ("COL_BLUE"%s)"COL_WHITE" is registered\nPlease enter the password to login\n\n"COL_GRIS"If you are not the owner of this account, leave and rejoin with a different nickname", GetPlayerName(playerid), playerid);

ShowPlayerDialog(playerid, dlogin, DIALOG_STYLE_PASSWORD, ""COL_BLUE"Login Panel", Query, "Login", "Leave");
}
else
{

format(Query, sizeof(Query), ""COL_WHITE"Welcome, this account ("COL_RED"%s)"COL_WHITE" is not registered\nPlease enter your desired password for this account\n\n"COL_GRIS"Once you are registered, do not share your password with anyone besides yourself!", GetPlayerName(playerid), playerid);
ShowPlayerDialog(playerid, dregister, DIALOG_STYLE_PASSWORD, ""COL_BLUE"Register Panel", Query, "Register", "Leave");
}
db_free_result(queryresult);
return 1;
}

Cerealguy
02/12/2016, 04:47 AM
BUUMP!

Cerealguy
04/12/2016, 03:36 PM
BUUMP