10.03.2016, 22:24
For some reason, this dialog is refusing to show under any conditions. I added some debug lines and 'a' and 'c' print. 'b' does not print because it never makes it to the existing file condition because the registration dialog does not appear.
pawn Код:
#define dialog_login 1
#define dialog_register 2
stock ShowPlayerRegister(playerid)
{
ShowPlayerDialog(playerid, dialog_register, DIALOG_STYLE_INPUT, "Welcome to ARP!", "Enter a password to register your account.", "Register", "Cancel");
}
forward CheckPlayerExists(playerid);
public CheckPlayerExists(playerid)
{
new rows, fields;
cache_get_data(rows, fields, sHandle);
if(rows)
{
cache_get_field_content(0, "password", PlayerInfo[playerid][Password], sHandle, 129);
ShowPlayerLogin(playerid);
print("b");
}
else
{
print("c");
ShowPlayerRegister(playerid);
}
return 1;
}
public OnPlayerConnect(playerid)
{
new query[128];
mysql_format(sHandle, query, sizeof(query), "SELECT `password` FROM `users` WHERE `name` = '%e' LIMIT 1", GetPName(playerid));
mysql_tquery(sHandle, query, "CheckPlayerExists", "i", "playerid");
print("a");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case dialog_login:
{
if(!response) Kick(playerid);
new hash[129], query[128];
WP_Hash(hash, sizeof(hash), inputtext);
if(strcmp(hash, PlayerInfo[playerid][Password])== 0)
{
mysql_format(sHandle, query, sizeof(query), "SELECT * FROM `users` WHERE `name` = '%e' LIMIT 1", GetPName(playerid));
mysql_tquery(sHandle, query, "OnAccountLoad", "i", "playerid");
}
else
{
ShowBadLogin(playerid);
}
}
case dialog_register:
{
if(!response) Kick(playerid);
if(!strlen(inputtext)) ShowBadRegister(playerid);
new query[512];
new ip[24];
GetPlayerIp(playerid, ip, 24);
WP_Hash(PlayerInfo[playerid][Password], 129, inputtext);
mysql_format(sHandle, query, sizeof(query), "INSERT INTO `users` (`name`, `password`, `ip`, `adminlevel`, `posx`, `posy`, `posz`, `posa`, `money`, `bank`) VALUES ('%e', '%e', '%e', 0, '%f', '%f', '%f', '%f', 0, 0)", GetPName(playerid), PlayerInfo[playerid][Password], ip, 0, 0, 0, 0, 0, 0);
mysql_tquery(sHandle, query, "SendQuery");
}
}
return 1;
}