17.06.2014, 17:39
I have just followed NewbieNoob's tutorial and set everything. No warnings/errors but when player has registered, it gives them random stats and after relogging the account isn't saving. I am new to MySQL stuffs so can someone help me out?
These are the scripts that i have added to my server. I can't find the mistakes as i don't know where they are. So need help!
pawn Код:
//OnPlayerConnect
new query[128];
mysql_format(mysql, query, sizeof(query),"SELECT `Password` FROM `players` WHERE `Name` = '%e' LIMIT 1", pInfo[playerid][PlayerName]);
mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
// Login and Register dialogs
Dialog_Register(playerid, response, inputtext[])
{
new str[128], Name[24];
GetPlayerName(playerid, Name, sizeof(Name));
if (!response)
{
format(str, 129, "%s has been kicked from the server! [Quitting the Register Dialog]", Name);
SendClientMessageToAll(RED, str);
SendClientMessage(playerid, DARK_RED, "You must Register your Account before entering the server!");
Timer_Disconnect[playerid] = SetTimerEx("DisconnectPlayer", 100, false, "d", playerid);
}
if(response)
{
new query[300];
if(strlen(inputtext) > 6)
{
WP_Hash(pInfo[playerid][Password], 129, inputtext);
mysql_format(mysql, query, sizeof(query), "INSERT INTO `players` (`Name`, `Password`, `Level`, `Money`, `Score`, `VIP`, `MoneyBoost` ,`BoostTime`, `Jailed`, `Wanted`, `Banned`, `TBanned`, `TBanTime`, `License`, `PoliceStats`, `MetersDriven`, `TruckerJobs`, `Assisted`, `Convoys`, `Flights`, `Fines`, `JailedPlayers`) VALUES ('%e', '%s', '%s', 0,0,0,0,0,0,0,0,0,0,0,0.0,0,0,0,0,0,0)",
Name,
pInfo[playerid][Password],
pInfo[playerid][AdminLevel],
pInfo[playerid][Money],
pInfo[playerid][Score],
pInfo[playerid][VIP],
pInfo[playerid][MoneyBoost],
pInfo[playerid][BoostTime],
pInfo[playerid][Jailed],
pInfo[playerid][WantedLevel],
pInfo[playerid][Banned],
pInfo[playerid][TempBanned],
pInfo[playerid][BanTime],
pInfo[playerid][TruckerLicense],
pInfo[playerid][PoliceStats],
pInfo[playerid][StatsMetersDriven],
pInfo[playerid][StatsTruckerJobs],
pInfo[playerid][StatsMechanic],
pInfo[playerid][StatsConvoyJobs],
pInfo[playerid][StatsPilotJobs],
pInfo[playerid][StatsPoliceFined],
pInfo[playerid][StatsPoliceJailed]);
mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
pInfo[playerid][LoggedIn] = true;
}
else
{
SendClientMessage(playerid, RED, "Your Password must contain at least 6 characters!");
ShowPlayerDialog(playerid, DialogRegister, DIALOG_STYLE_PASSWORD, "{FFFFFF}REGISTER", "{FF8000}This account is not registered!\n\n{FFFFFF}Enter your Password bellow to register:", "Register", "");
}
}
return 1;
}
Dialog_Login(playerid, response, inputtext[])
{
new msg[128], Name[24];
GetPlayerName(playerid, Name, sizeof(Name));
if(!response)
{
format(msg, 128, "%s has been kicked from the server! [Quitting the Login Dialog]", Name);
SendClientMessageToAll(RED, msg);
SendClientMessage(playerid, DARK_RED, "You must Login to your Account before entering the server!");
Timer_Disconnect[playerid] = SetTimerEx("DisconnectPlayer", 100, false, "d", playerid);
}
if(response)
{
new hpass[129]; new query[100];
WP_Hash(hpass, 129, inputtext);
if(!strcmp(hpass, pInfo[playerid][Password]))
{
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `players` WHERE `Name` = '%e' LIMIT 1", Name);
mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
BankFile_Load(playerid);
pInfo[playerid][LoggedIn] = true;
}
else
{
ShowPlayerDialog(playerid, DialogRegister, DIALOG_STYLE_PASSWORD, "{FFFFFF}REGISTER", "{FF8000}This account is not registered!\n\n{FFFFFF}Enter your Password bellow to register:", "Register", "");
}
}
return 1;
}
// Stock to save player's file
stock PlayerFile_Save(playerid)
{
new query[128];
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Level`=%d, `Money`=%d, `Score`=%d, `VIP`=%d, `MoneyBoost`=%d, `BoostTime`=%d, `Jailed`=%d, `Wanted`=%d, `Banned`=%d, `TBanned`=%d, `TBanTime`=%d, `License`=%d, `PoliceStats`=%d, `MetersDriven`=%d, `TruckerJobs`=%d, `Assisted`=%d, `Convoys`=%d, `Flights`=%d, `Fines`=%d, `JailedPlayers`=%d WHERE `Name`= '%s'",
pInfo[playerid][AdminLevel],
pInfo[playerid][Money],
pInfo[playerid][Score],
pInfo[playerid][VIP],
pInfo[playerid][MoneyBoost],
pInfo[playerid][BoostTime],
pInfo[playerid][Jailed],
pInfo[playerid][WantedLevel],
pInfo[playerid][Banned],
pInfo[playerid][TempBanned],
pInfo[playerid][BanTime],
pInfo[playerid][TruckerLicense],
pInfo[playerid][RulesRead],
pInfo[playerid][PoliceStats],
pInfo[playerid][StatsMetersDriven],
pInfo[playerid][StatsTruckerJobs],
pInfo[playerid][StatsMechanic],
pInfo[playerid][StatsConvoyJobs],
pInfo[playerid][StatsPilotJobs],
pInfo[playerid][StatsPoliceFined],
pInfo[playerid][StatsPoliceJailed]);
mysql_tquery(mysql, query, "", "");
return 1;
}
//Functions to load accounts
forward OnAccountLoad(playerid);
public OnAccountLoad(playerid)
{
pInfo[playerid][AdminLevel] = cache_get_field_content_int(0, "Level");
pInfo[playerid][Money] = cache_get_field_content_int(0, "Money");
pInfo[playerid][Score] = cache_get_field_content_int(0, "Score");
pInfo[playerid][VIP] = cache_get_field_content_int(0, "VIP");
pInfo[playerid][MoneyBoost] = cache_get_field_content_int(0, "MoneyBoost");
pInfo[playerid][BoostTime] = cache_get_field_content_int(0, "BoostTime");
pInfo[playerid][Jailed] = cache_get_field_content_int(0, "Jailed");
pInfo[playerid][WantedLevel] = cache_get_field_content_int(0, "Wanted");
pInfo[playerid][Banned] = cache_get_field_content_int(0, "Banned");
pInfo[playerid][TempBanned] = cache_get_field_content_int(0, "Tbanned");
pInfo[playerid][BanTime] = cache_get_field_content_int(0, "TBanTime");
pInfo[playerid][TruckerLicense] = cache_get_field_content_int(0, "License");
pInfo[playerid][PoliceStats] = cache_get_field_content_int(0, "PoliceStats");
pInfo[playerid][StatsMetersDriven] = cache_get_field_content_int(0, "MetersDriven");
pInfo[playerid][StatsTruckerJobs] = cache_get_field_content_int(0, "TruckerJobs");
pInfo[playerid][StatsMechanic] = cache_get_field_content_int(0, "Assisted");
pInfo[playerid][StatsConvoyJobs] = cache_get_field_content_int(0, "Convoys");
pInfo[playerid][StatsPilotJobs] = cache_get_field_content_int(0, "Flights");
pInfo[playerid][StatsPoliceFined] = cache_get_field_content_int(0, "Fines");
pInfo[playerid][StatsPoliceJailed] = cache_get_field_content_int(0, "JailedPlayers");
return 1;
}
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
cache_get_field_content(0, "PASS", pInfo[playerid][Password], mysql, 129);
ShowPlayerDialog(playerid, DialogLogin, DIALOG_STYLE_PASSWORD, "{FFFFFF}LOGIN", "{00FF00}Welcome back!\n\n{FFFFFF}Please enter your Password bellow to login:", "Login", "");
}
else
{
ShowPlayerDialog(playerid, DialogRegister, DIALOG_STYLE_PASSWORD, "{FFFFFF}REGISTER", "{FF8000}This account is not registered!\n\n{FFFFFF}Enter your Password bellow to register:", "Register", "");
}
return 1;
}