SA-MP Forums Archive
Problem show dialog! - 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)
+--- Thread: Problem show dialog! (/showthread.php?tid=623390)



Problem show dialog! - Cerealguy - 01.12.2016

PHP код:
BanCheck(playerid)
{
    new
        
retrieveName[MAX_PLAYER_NAME],
        
retrieveBannedBy[MAX_PLAYER_NAME],
        
retrieveReason[50],
        
retrieveBanDate,
        
retrieveDuration,
        
retrieveGCPI[60],
        
retrieveIP[16 1],
        
Query[380]
    ;
    
GetPlayerIp(playeridretrieveIPsizeof(retrieveIP));
    
gpci(playeridretrieveGCPIsizeof(retrieveGCPI));
    
    
format(Querysizeof(Query), "SELECT * FROM `Bans` WHERE `Name` = '%q' COLLATE NOCASE OR `GPCI` = '%q' OR `IP` = '%q' LIMIT 1"GetPlayerName(playerid), retrieveGCPIretrieveIP);
    
queryresult db_query(DatabaseQuery);
    if(
db_num_rows(queryresult))
    {
        
db_get_field_assoc(queryresult"Name"retrieveNamesizeof(retrieveName));
        
db_get_field_assoc(queryresult"BannerName"retrieveBannedBysizeof(retrieveBannedBy));
        
db_get_field_assoc(queryresult"Reason"retrieveReasonsizeof(retrieveReason));
        
retrieveBanDate db_get_field_assoc_int(queryresult"BANDATE");
        
retrieveDuration db_get_field_assoc_int(queryresult"UNBANDATE");
        if(
gettime() - retrieveDuration > (retrieveDuration retrieveBanDate))
        {
            
format(Querysizeof(Query), "Your ban expired on %s \nWelcome back %s!"TimestampToDateTime(retrieveDuration), GetPlayerName(playerid));
            
SendClientMessage(playeridCOLOR_SERVERQuery);
            
//Remove ban fuction heree working bla bla
        
}
        else
        {
            
            
format(Querysizeof(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"retrieveNameretrieveIPretrieveBannedBy,
             
retrieveReasonTimestampToDateTime(retrieveBanDate), TimestampToDateTime(retrieveDuration));
            
ShowPlayerDialog(playerid500DIALOG_STYLE_MSGBOX"Account Banned!"Query"Exit""");
            
defer KickEx(playerid);
            return 
1;
        }
    }
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
SendDeathMessage(INVALID_PLAYER_IDplayerid200);
    for( new 
i_PlayerInfo; ++pInfoplayerid ][ PlayerInfo] = 0;
    
//------------------[ANTI-BOTS]------------------
    
new ConnIP[16];
    
GetPlayerIp(playerid,ConnIP,16);
    new 
compare_IP[16];
    new 
number_IP 0;
    for(new 
i=GetPlayerPoolSize(); != -1i--) {
        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_sConnIPfalse) == && exceed == )
     {
         
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_IP16"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
        
Query256 // Create a Query
    
;
    
pInfo[playerid][USER_LOGGED_IN] = false
   
    
format(Querysizeof(Query), "SELECT `Username` FROM `users` WHERE `Username` = '%s' COLLATE NOCASE"DB_Escape(GetPlayerName(playerid)));
  
    
queryresult db_query(DatabaseQuery);
   
    if(
db_num_rows(queryresult))
    {
        
        
format(Querysizeof(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(playeriddloginDIALOG_STYLE_PASSWORD""COL_BLUE"Login Panel"Query"Login""Leave");
    }
    else
    {
    
        
format(Querysizeof(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(playeriddregisterDIALOG_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


Re: Problem show dialog! - Alpay0098 - 01.12.2016

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.


Respuesta: Re: Problem show dialog! - Cerealguy - 02.12.2016

Quote:
Originally Posted by Alpay0098
Посмотреть сообщение
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


Re: Problem show dialog! - ImVictor - 02.12.2016

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.


Respuesta: Problem show dialog! - Cerealguy - 02.12.2016

defer KickEx(playerid); it a kick timer (500) the problem is that instead of seeing the ban dialog, you see the login panel dialog


Re: Problem show dialog! - Logic_ - 02.12.2016

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?


Respuesta: Problem show dialog! - Cerealguy - 02.12.2016

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

PHP код:
public OnPlayerConnect(playerid)
{
    
SendDeathMessage(INVALID_PLAYER_IDplayerid200);
    for( new 
i_PlayerInfo; ++pInfoplayerid ][ PlayerInfo] = 0;
    
//------------------[ANTI-BOTS]------------------
    
new ConnIP[16];
    
GetPlayerIp(playerid,ConnIP,16);
    new 
compare_IP[16];
    new 
number_IP 0;
    for(new 
i=GetPlayerPoolSize(); != -1i--) {
        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_sConnIPfalse) == && exceed == )
     {
         
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_IP16"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
        
Query256 
    ;
    
pInfo[playerid][USER_LOGGED_IN] = false
   
    
format(Querysizeof(Query), "SELECT `Username` FROM `users` WHERE `Username` = '%s' COLLATE NOCASE"DB_Escape(GetPlayerName(playerid)));
  
    
queryresult db_query(DatabaseQuery);
   
    if(
db_num_rows(queryresult))
    {
        
        
format(Querysizeof(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(playeriddloginDIALOG_STYLE_PASSWORD""COL_BLUE"Login Panel"Query"Login""Leave");
    }
    else
    {
    
        
format(Querysizeof(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(playeriddregisterDIALOG_STYLE_PASSWORD""COL_BLUE"Register Panel"Query"Register""Leave");
    }
    
db_free_result(queryresult);
return 
1;




Respuesta: Problem show dialog! - Cerealguy - 02.12.2016

BUUMP!


Respuesta: Problem show dialog! - Cerealguy - 04.12.2016

BUUMP