PHP код:
public OnPlayerConnect(playerid)
{
// connexion message
new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s has joined The Aviation Life.", name);
SendClientMessageToAll(COULEUR_BLEUCLAIR, string);
SendClientMessage(playerid, COULEUR_ROUGE, "[WARNING]press the spawn button.");
new query[128], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
mysql_format(mysql, query, sizeof(query), "SELECT `Password`, `ID` FROM `accounts` WHERE `Name` = '%e' LIMIT 1", playername);
mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
return true;
}
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
cache_get_field_content(0, "Password", Player[playerid][Password], mysql, 129);
Player[playerid][ID] = cache_get_field_content_int(0, "ID");
ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_INPUT, "Login", "Welcome player!\nYour account has been found in our database. Please fill in your password:", "Login", "Quit");
}
else
{
ShowPlayerDialog(playerid, RegisterDialog, DIALOG_STYLE_INPUT, "Register", "Welcome player!\nYour account has not been registered yet. Please fill in your desired password:", "Register", "Quit");
}
return true;
}
PHP код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_CLASSES)
{
if(response)
{
switch(listitem)
{
case 0: ShowPlayerDialog(playerid, DIALOG_CLASSESPILOTSPAWN, DIALOG_STYLE_LIST, "Where you to want spawn ?", "Las Venturas\nSan Fierro\nLos Santos", "Select", "Cancel");
case 1: ShowPlayerDialog(playerid, DIALOG_CLASSESTRUCKERSPAWN, DIALOG_STYLE_LIST,"Where you to want spawn ?", "Las Venturas\nSan Fierro\nLos Santos", "Select", "Cancel");
case 2: SetPlayerPos(playerid,0.0,0.0,3.0);
case 3: SetPlayerPos(playerid,0.0,0.0,3.0);
}
}
return 1;
}
if(dialogid == DIALOG_CLASSESPILOTSPAWN)
{
if(response)
{
switch(listitem)
{
case 0: SetPlayerPos(playerid, 1319.7030,1262.4758,10.8472);
case 1: SetPlayerPos(playerid, -1263.0552,31.6843,14.1484);
case 2: SetPlayerPos(playerid, 2015.8444,-2445.6909,13.5469);
}
}
}
switch(dialogid)
{
case LoginDialog:
{
if(!response) Kick(playerid);
new
hashpass[129],
query[100],
playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
WP_Hash(hashpass, sizeof(hashpass), inputtext);
if(!strcmp(hashpass, Player[playerid][Password]))
{
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `accounts` WHERE `Name` = '%e' LIMIT 1", playername);
mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
}
else
{
SendClientMessage(playerid, -1, "You have specified an incorrect password!");
ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_INPUT, "Login", "Welcome player!\nYour account has been found in our database. Please fill in your password:", "Login", "Quit");
}
}
case RegisterDialog:
{
if(!response) return Kick(playerid);
if(strlen(inputtext) < 5)
{
SendClientMessage(playerid, -1, "Your password must at least contain more than 4 characters.");
return ShowPlayerDialog(playerid, RegisterDialog, DIALOG_STYLE_INPUT, "Register", "Welcome player!\nYour account has not been registered yet. Please fill in your desired password:", "Register", "Quit");
}
new
query[512],
playername[MAX_PLAYER_NAME],
playerip[16];
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerIp(playerid, playerip, sizeof(playerip));
WP_Hash(Player[playerid][Password], 129, inputtext);
mysql_format(mysql, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX`, `PosY`, `PosZ`, `PosA`) VALUES ('%e', '%e', '%e', 0, 0, 0, %f, %f, %f, %f)", playername, Player[playerid][Password], playerip, SPAWN_X, SPAWN_Y, SPAWN_Z, SPAWN_A);
mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
}
}
return 1;
}
As far as I can see there's nothing wrong with it. You get the player's name twice in OnPlayerConnect, which is redundant, but that in itself shouldn't cause a problem. Check the logs.
fixed. i have write the wrong database.