Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

y_dialog and inline response

$
0
0
PHP Code:

hook OnPlayerConnect(playerid)
{
        new
            
Query150 ], 
            
DBResultResult
            
nameMAX_PLAYER_NAME ]
        ;
        new
            
ipstring[16],
            
ipbyte[4];
        
// SPAWN INFO
        
SetSpawnInfo(playeridNO_TEAM0DEFAULT_POS_XDEFAULT_POS_YDEFAULT_POS_Z0.0000000);
        
SpawnPlayer(playerid);

        
//
        
GetPlayerIp(playeridipstring16);
        
BanCheck(playerid);
        
sscanf(ipstring"p<.>a<d>[4]"ipbyte);
        
Player_IP[playerid] = ((ipbyte[0] << 24) | (ipbyte[1] << 16) | (ipbyte[2] << 8) | ipbyte[3]);        
        
GetPlayerName(playeridnamesizeof(name));
       
        
format(Querysizeof(Query), "SELECT `name` FROM `users` WHERE `name` = '%s'"DB_Escape(name));
        
Result db_query(MainDBQuery);
        if(
db_num_rows(Result))
        {
            
inline Response(piddialogidresponselistitemstring:inputtext[])
            { 
                
#pragma unused pid, dialogid, listitem
                
if(response
                {
                    if(
strlen(inputtext) > 24 || strlen(inputtext) < 3)
                    {
                        
format(Querysizeof(Query), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF} to the server, you're "COL_RED"not{FFFFFF} registered\n\nPlease log in by inputting your password."nameplayerid);
                        
ShowPlayerDialog(playerid0DIALOG_STYLE_INPUT"{FFFFFF}Register System"Query"Register""Leave");
                        
SendClientMessage(playerid, -1"Your password length must be from 3 - 24 characters!");
                    }
                    else
                    {
                        
format(Querysizeof(Query), "INSERT INTO `users` (`name`, `password`, `ip`, `Level`, `cash`, `adminlevel`) VALUES('%s','%s','%d','1','500','0')"DB_Escape(name), DB_Escape(inputtext), GetPlayerIpAsInt(playerid));
                        
db_query(MainDBQuery);
                        
SetPVarInt(playerid"LoggedIn"1);
                        
GivePlayerMoney(playerid500); 
                        
SetPlayerScore(playerid0);
                        
SendClientMessage(playerid, -1"You have "COL_GREEN"successfully{FFFFFF} registered! You have been automatically logged in!");
                    }
                }
            }   
            
format(Querysizeof(Query), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF} to the server, you're registered\n\nPlease log in by inputting your password."nameplayerid); 
            
Dialog_ShowCallback(playeridusing inline ResponseDIALOG_STYLE_INPUT"{FFFFFF}Register System"Query"Login""Leave");
        }
        else 
        {
            
inline Response(piddialogidresponselistitemstring:inputtext[])
            {
                
#pragma unused pid, dialogid, listitem
                
if(response)
                {   
                    
format(Querysizeof(Query), "SELECT * FROM `users` WHERE `name` = '%s' AND `password` = '%s'"DB_Escape(name), DB_Escape(inputtext));
                    
Result db_query(MainDBQuery);
                    if(
db_num_rows(Result))
                    {
                        
SetPVarInt(playerid"SQLID"db_get_field_assoc_int(Result"sqlid"));
                        
SetPVarInt(playerid"Level"db_get_field_assoc_int(Result"Level"));
                        
SetPlayerScore(playeridGetPVarInt(playerid"Level"));
                        
SetPVarInt(playerid"Admin"db_get_field_assoc_int(Result"adminlevel"));
                        
SetPVarInt(playerid"Cash"db_get_field_assoc_int(Result"cash"));
                        
GivePlayerMoney(playeridGetPVarInt(playerid"Cash"));
                        
SetPVarInt(playerid"LoggedIn"1);
                        
SendPlayerToSpawn(playerid);
                        
SendClientMessage(playerid, -1"Tqven Warmatebit Giaret "COL_GREEN"Avtorizacia{FFFFFF}");
                    }
                    else
                    {    
                        
format(Querysizeof(Query), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF} to the server, you're registered\n\nPlease log in by inputting your password."nameplayerid);
                        
ShowPlayerDialog(playerid1DIALOG_STYLE_INPUT"{FFFFFF}Register System"Query"Login""Leave");
                        
SendClientMessage(playerid, -1""COL_RED"Araswori{FFFFFF} Paroli, Scadet Axlidan!");
                    }
                }
                else 
Kick(playerid);                            
            }
            
format(Querysizeof(Query), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF} to the server, you're "COL_RED"not{FFFFFF} registered\n\nPlease log in by inputting your password."nameplayerid);
            
Dialog_ShowCallback(playeridusing inline ResponseDIALOG_STYLE_INPUT"{FFFFFF}Register System"Query"Register""Leave");
        }
        
db_free_result(Result);
        
//db_free_result_hook(Result);
        
return 1;


Heres my register system, but its always calling REGISTER response. i mean its saying that i'm registered, but when i write my password its going to register response. why?

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>