15.07.2018, 16:26
Hi the accounts won't save in the database, It creates the database but it doesn't save the account. What am I doing wrong?
Register dialog
Saving the account.
The database
Register dialog
PHP Code:
if(dialogid == 5)
{
if(!response) return Kick(playerid);
if(response)
{
new oof[32];
GetPVarString(playerid, "confirmpass", oof, 32);
if(strcmp(inputtext, oof, true) == 0)
{
SHA256_PassHash(inputtext, "", PlayerInfo[playerid][pPass], 64);
new handle = SL::Open(SL::INSERT, "players");
SL::ToggleAutoIncrement(handle, true);
SL::WriteString(handle, "Name", GetName(playerid));
SL::WriteString(handle,"Password",PlayerInfo[playerid][pPass]);
SL::WriteInt(handle,"Cash",0);
SL::WriteInt(handle,"Score",0);
SL::WriteInt(handle,"Admin",0);
SL::WriteInt(handle,"Helper",0);
SL::WriteInt(handle,"Kills",0);
SL::WriteInt(handle,"Deaths",0);
SL::WriteInt(handle,"Skin",0);
SL::WriteInt(handle,"Banned", 0);
SL::WriteString(handle, "BannedReason", "N/A");
SL::WriteString(handle, "BannedBy", "N/A");
SL::WriteString(handle, "BannedIP", "N/A");
SL::WriteInt(handle, "HitsoundToggle", 0);
SL::WriteInt(handle, "Donator", 0);
SL::WriteInt(handle, "DonatorSkin", 0);
SL::WriteInt(handle, "ExclusiveSkin", 0);
SL::WriteInt(handle, "UnlockedSkin1", 0);
SL::WriteInt(handle, "UnlockedSkin2", 0);
SL::WriteInt(handle, "UnlockedSkin3", 0);
SL::WriteInt(handle, "UnlockedSkin4", 0);
SL::WriteInt(handle, "UnlockedSkin5", 0);
SL::WriteInt(handle, "UnlockedSkin6", 0);
SL::WriteInt(handle, "UnlockedSkin7", 0);
SL::WriteInt(handle, "UnlockedSkin8", 0);
SL::WriteInt(handle, "UnlockedSkin9", 0);
SL::WriteInt(handle, "UnlockedSkin10", 0);
SL::WriteInt(handle, "UnlockedSkin11", 0);
SL::WriteInt(handle, "UnlockedSkin12", 0);
SL::WriteString(handle, "pClan", "None");
SL::WriteInt(handle, "pClanID", 0);
SL::WriteInt(handle, "pLeader", 0);
SL::WriteInt(handle, "Mutes", 0);
SL::WriteInt(handle, "Bans", 0);
SL::WriteInt(handle, "Kicks", 0);
SL::WriteInt(handle, "Warns", 0);
SL::WriteInt(handle, "pTitle", 0);
SL::WriteString(handle, "CTitle", "");
SL::WriteInt(handle, "Headshots", 0);
SL::WriteInt(handle, "Achievement1", 0);
SL::WriteInt(handle, "Achievement2", 0);
SL::WriteInt(handle, "Achievement3", 0);
SL::WriteInt(handle, "Achievement4", 0);
SL::WriteInt(handle, "Achievement5", 0);
PlayerInfo[playerid][pID] = SL::Close(handle);
SetPlayerColor(playerid, 0xBAFFFDFF);
InLobby[playerid] = 1;
SaveAccountStats(playerid);
IsLogged[playerid] = 1;
TogglePlayerSpectating(playerid, 0);
SetPlayerClassPosition(playerid);
new string[128];
format(string, sizeof(string), "~ %s has registered a new account. Welcome to the server!", GetName(playerid));
SendClientMessageToAll(COLOR_GREEN, string);
PHP Code:
public SaveAccountStats(playerid)
{
// if(IsLogged[playerid] == 1)
new handle = SL::Open(SL::UPDATE, "players", "ID", PlayerInfo[playerid][pID]);
SL::WriteInt(handle, "Cash", GetPlayerCash(playerid));
SL::WriteInt(handle, "Score", GetPlayerScore(playerid));
SL::WriteInt(handle, "Admin", PlayerInfo[playerid][pAdmin]);
SL::WriteInt(handle, "Kills",PlayerInfo[playerid][pKills]);
SL::WriteInt(handle, "Deaths",PlayerInfo[playerid][pDeaths]);
SL::WriteInt(handle, "Banned", PlayerInfo[playerid][pBanned]);
SL::WriteInt(handle, "BannedReason", PlayerInfo[playerid][pBanReason]);
SL::WriteInt(handle, "BannedBy", PlayerInfo[playerid][pBannedBy]);
SL::WriteInt(handle, "BannedIP", PlayerInfo[playerid][pBannedIP]);
SL::WriteInt(handle, "HitsoundToggle", PlayerInfo[playerid][pHitsound]);
SL::WriteInt(handle, "Donator", PlayerInfo[playerid][pDonator]);
SL::WriteInt(handle, "DonatorSkin", PlayerInfo[playerid][pDonatorSkin]);
SL::WriteInt(handle, "ExclusiveSkin", PlayerInfo[playerid][pExclusiveSkin]);
SL::WriteInt(handle, "UnlockedSkin1", PlayerInfo[playerid][UnlockedSkin1]);
SL::WriteInt(handle, "UnlockedSkin2", PlayerInfo[playerid][UnlockedSkin2]);
SL::WriteInt(handle, "UnlockedSkin3", PlayerInfo[playerid][UnlockedSkin3]);
SL::WriteInt(handle, "UnlockedSkin4", PlayerInfo[playerid][UnlockedSkin4]);
SL::WriteInt(handle, "UnlockedSkin5", PlayerInfo[playerid][UnlockedSkin4]);
SL::WriteInt(handle, "UnlockedSkin6", PlayerInfo[playerid][UnlockedSkin4]);
SL::WriteInt(handle, "UnlockedSkin7", PlayerInfo[playerid][UnlockedSkin4]);
SL::WriteInt(handle, "UnlockedSkin8", PlayerInfo[playerid][UnlockedSkin4]);
SL::WriteInt(handle, "UnlockedSkin9", PlayerInfo[playerid][UnlockedSkin4]);
SL::WriteInt(handle, "UnlockedSkin10", PlayerInfo[playerid][UnlockedSkin4]);
SL::WriteInt(handle, "UnlockedSkin11", PlayerInfo[playerid][UnlockedSkin4]);
SL::WriteInt(handle, "UnlockedSkin12", PlayerInfo[playerid][UnlockedSkin4]);
SL::WriteInt(handle, "pClan", PlayerInfo[playerid][pClan]);
SL::WriteInt(handle, "pClanID", PlayerInfo[playerid][pClanID]);
SL::WriteInt(handle, "pLeader", PlayerInfo[playerid][pLeader]);
SL::WriteInt(handle, "Mutes", PlayerInfo[playerid][pMutes]);
SL::WriteInt(handle, "Bans", PlayerInfo[playerid][pBans]);
SL::WriteInt(handle, "Kicks", PlayerInfo[playerid][pKicks]);
SL::WriteInt(handle, "Warns", PlayerInfo[playerid][pWarns]);
SL::WriteInt(handle, "CTitle", PlayerInfo[playerid][CTitle]);
SL::WriteInt(handle, "Headshots", PlayerInfo[playerid][Headshots]);
SL::WriteInt(handle, "Achievement1", PlayerInfo[playerid][Achievement1]);
SL::WriteInt(handle, "Achievement2", PlayerInfo[playerid][Achievement2]);
SL::WriteInt(handle, "Achievement3", PlayerInfo[playerid][Achievement3]);
SL::WriteInt(handle, "Achievement4", PlayerInfo[playerid][Achievement4]);
SL::WriteInt(handle, "Achievement5", PlayerInfo[playerid][Achievement5]);
SL::Close(handle);
return 1;
}
PHP Code:
SL::Connect("rdm.db");
if(!SL::ExistsTable("players"))
{
new handle = SL::Open(SL::CREATE, "players");
SL::AddTableEntry(handle, "ID", SL_TYPE_INT, 11, true);
SL::AddTableEntry(handle, "Name", SL_TYPE_VCHAR, 24);
SL::AddTableEntry(handle, "Password", SL_TYPE_VCHAR, 64);
SL::AddTableEntry(handle, "Cash", SL_TYPE_INT);
SL::AddTableEntry(handle, "Score", SL_TYPE_INT);
SL::AddTableEntry(handle, "Admin", SL_TYPE_INT);
SL::AddTableEntry(handle, "Kills", SL_TYPE_INT);
SL::AddTableEntry(handle, "Deaths", SL_TYPE_INT);
SL::AddTableEntry(handle, "Banned", SL_TYPE_INT);
SL::AddTableEntry(handle, "BannedBy", SL_TYPE_VCHAR, 24);
SL::AddTableEntry(handle, "BanReason", SL_TYPE_VCHAR, 128);
SL::AddTableEntry(handle, "BannedIP", SL_TYPE_VCHAR, 16);
SL::AddTableEntry(handle, "HitsoundToggle", SL_TYPE_INT);
SL::AddTableEntry(handle, "Donator", SL_TYPE_INT);
SL::AddTableEntry(handle, "DonatorSkin", SL_TYPE_INT);
SL::AddTableEntry(handle, "ExclusiveSkin", SL_TYPE_INT);
SL::AddTableEntry(handle, "UnlockedSkin1", SL_TYPE_INT);
SL::AddTableEntry(handle, "UnlockedSkin2", SL_TYPE_INT);
SL::AddTableEntry(handle, "UnlockedSkin3", SL_TYPE_INT);
SL::AddTableEntry(handle, "UnlockedSkin4", SL_TYPE_INT);
SL::AddTableEntry(handle, "UnlockedSkin5", SL_TYPE_INT);
SL::AddTableEntry(handle, "UnlockedSkin6", SL_TYPE_INT);
SL::AddTableEntry(handle, "UnlockedSkin7", SL_TYPE_INT);
SL::AddTableEntry(handle, "UnlockedSkin8", SL_TYPE_INT);
SL::AddTableEntry(handle, "UnlockedSkin9", SL_TYPE_INT);
SL::AddTableEntry(handle, "UnlockedSkin10", SL_TYPE_INT);
SL::AddTableEntry(handle, "UnlockedSkin11", SL_TYPE_INT);
SL::AddTableEntry(handle, "UnlockedSkin12", SL_TYPE_INT);
SL::AddTableEntry(handle, "pClan", SL_TYPE_VCHAR, 64);
SL::AddTableEntry(handle, "pClanID", SL_TYPE_INT);
SL::AddTableEntry(handle, "pLeader", SL_TYPE_INT);
SL::AddTableEntry(handle, "Mutes", SL_TYPE_INT);
SL::AddTableEntry(handle, "Bans", SL_TYPE_INT);
SL::AddTableEntry(handle, "Kicks", SL_TYPE_INT);
SL::AddTableEntry(handle, "Warns", SL_TYPE_INT);
SL::AddTableEntry(handle, "CTitle", SL_TYPE_VCHAR, 128);
SL::AddTableEntry(handle, "Headshots", SL_TYPE_INT);
SL::AddTableEntry(handle, "Achievement1", SL_TYPE_INT);
SL::AddTableEntry(handle, "Achievement2", SL_TYPE_INT);
SL::AddTableEntry(handle, "Achievement3", SL_TYPE_INT);
SL::AddTableEntry(handle, "Achievement4", SL_TYPE_INT);
SL::AddTableEntry(handle, "Achievement5", SL_TYPE_INT);
SL::Close(handle);
print("Table 'players' was successfully created");
}
else
{
print("Table 'players' was successfully loaded");
}