Database constructor

Started by Coolkid, Jan 24, 2016, 08:31 AM

Previous topic - Next topic

Coolkid

Hi everyone
                    I am creating a server and i am stuck at a point can u guys plz help me i will e thankful can u tell me how to create databse frm this code constructor( 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() + "'" );
}

.

#1
What's the question again? The actual question. Not the words that pop into your head as a result of learning disabilities.
.

jayant

@Coolkid - If you are unable to use constructor,there are other ways also,think and try..

EK.IceFlake

universaldb <- ConnectSQL("yoursqlnameitwillautomaticallycreateitselfifitdoesntexist.sqli");
<that class name>("NOOB", universaldb);

Thijn

Quote from: Coolkid on Jan 24, 2016, 09:33 PM
Quote from: S.L.C on Jan 24, 2016, 09:22 AMWhat's the question again? The actual question. Not the words that pop into your head as a result of learning disabilities.
slc plz be quiet if u cant speak any good words frm ur mouth
Oh the irony.

Murdock

Quote from: Coolkid on Jan 24, 2016, 09:33 PM
Quote from: S.L.C on Jan 24, 2016, 09:22 AMWhat's the question again? The actual question. Not the words that pop into your head as a result of learning disabilities.
slc plz be quiet if u cant speak any good words frm ur mouth

Someone get this framed.