HI now my databse is loaded and my register login function is also working but when i reconnect my all stats money and kills are back to 0 plzz help me and thanks in advance
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menuconstructor( playerName, dbGlobal )
{
local query = ::QuerySQL( dbGlobal, "SELECT Cash, Bank, Kills, Deaths, Level, LastUsedIP FROM Accounts WHERE Name='" + playerName + "' AND NameLower='" + playerName.tolower() + "'" );
if( ::GetSQLColumnData( query, 5 ) )
{
Cash = ::GetSQLColumnData( query, 0 );
Bank = ::GetSQLColumnData( query, 1 );
Kills = ::GetSQLColumnData( query, 2 );
Deaths = ::GetSQLColumnData( query, 3 );
Level = ::GetSQLColumnData( query, 4 );
LastUsedIP = ::GetSQLColumnData( query, 5 );
}
::FreeSQLQuery( query );
local q = ::QuerySQL( dbGlobal, "SELECT Played, Won, Lost FROM LMS WHERE Name='" + playerName.tolower() + "'" );
if( ::GetSQLColumnData( q, 2 ) )
{
Played = ::GetSQLColumnData( q, 0 );
Wins = ::GetSQLColumnData( q, 1 );
Lost = ::GetSQLColumnData( q, 2 );
}
::FreeSQLQuery( q );
}
function Join( player ){
if( Level == 0 ){
::MessagePlayer( "Please register to play.", player );
::MessagePlayer( "Register with /register <password>", player );
}
else if( LastUsedIP == player.IP ){
Logged = true;
player.Cash = stats[ player.ID ].Cash;
::MessagePlayer( "Welcome back!", player );
}
else{
::MessagePlayer( "Please login to play.", player );
::MessagePlayer( "Login with /login <password>", player );
}
}
function Update( player, dbGlobal ){
::QuerySQL( dbGlobal, "UPDATE Accounts SET Cash=" + Cash + ", Bank=" + Bank + ", Kills=" + Kills + ", Deaths=" + Deaths + ", Level=" + Level + ", LastUsedIP='" + LastUsedIP + "' WHERE Name='" + player.Name + "' AND NameLower='" + player.Name.tolower() + "'" );
::QuerySQL( dbGlobal, "UPDATE LMS SET Lost=" + Lost + ", Played=" + Played + ", Won=" + Wins + " WHERE Name='" + player.Name.tolower() + "'" );
}