Update data after part

Started by umar4911, Feb 06, 2018, 10:15 AM

Previous topic - Next topic

umar4911

I have class in my script. I want that it should auto-update as soon as the player leaves game. Few things already update. Please update this code
QuerySQL(DB, "create table if not exists Accounts ( Name TEXT, LowerName TEXT, Password VARCHAR(255), Level NUMERIC DEFAULT 1, cash VARCHAR(255), Bank VARCHAR(255), TimeRegistered VARCHAR(255) DEFAULT CURRENT_TIMESTAMP, UID VARCHAR(255), IP VARCHAR(255), AutoLogin BOOLEAN DEFAULT true, Banned TEXT, clan VARCHAR ( 255 ), ctag VARCHAR ( 255), clevel VARCHAR(255) ) ");

Please update this
QuerySQL(DB,
    format(@"UPDATE [Accounts] SET
        [Level]='%s',
        [UID]='%s',
        [IP]='%s',
        [Password]='%s',
        [AutoLogin]='%s'
        WHERE [Name]='%s' AND [LowerName]='%s';",
        status[ player.ID ].Level.tostring(),
        status[ player.ID ].UID.tostring(),
        status[ player.ID ].IP.tostring(),
        status[ player.ID ].Password.tostring(),
        status[ player.ID ].AutoLogin.tostring(),
        player.Name,
        player.Name.tolower()
    )

umar4911


Mohamed Boubekri

#2
Umar's Try Thi:-
QuerySQL(DB,
    format(@"UPDATE [Accounts] SET
        [Level]='%s',
        [UID]='%s',
        [IP]='%s',
        [Password]='%s',
        [AutoLogin]='%s'
        [Banned]='%s'
        [clan]='%s'
        [ctag]='%s'
        [clevel]='%s'
        WHERE [Name]='%s' AND [LowerName]='%s';",
        status[ player.ID ].Level.tostring(),
        status[ player.ID ].UID.tostring(),
        status[ player.ID ].IP.tostring(),
        status[ player.ID ].Password.tostring(),
        status[ player.ID ].AutoLogin.tostring(),
        status[ player.ID ].Banned.tostring(),
        status[ player.ID ].clan.tostring(),
        status[ player.ID ].ctag.tostring(),
        status[ player.ID ].clevel.tostring(),
        player.Name,
        player.Name.tolower()
    )

Better If You Update Also It Think Will Solve Your Problem.
function AccInfo(player)
{
 local q = QuerySQL(DB, "SELECT * FROM Accounts WHERE Name = '" + escapeSQLString(player.Name) + "'");
 if (q)
 {
  status[player.ID].Password = GetSQLColumnData(q, 2);
  status[player.ID].Level = GetSQLColumnData(q, 3);
  status[player.ID].UID = GetSQLColumnData(q, 5);
  status[player.ID].IP = GetSQLColumnData(q, 6);
  status[player.ID].AutoLogin = GetSQLColumnData(q, 7);
  status[player.ID].Banned = GetSQLColumnData(q, 8);
  status[player.ID].clan = GetSQLColumnData(q, 9);
  status[player.ID].ctag = GetSQLColumnData(q, 10);
  status[player.ID].Registered = true;
  if ((player.UID == status[player.ID].UID) || (player.IP == status[player.ID].IP))
  {
   if (status[player.ID].AutoLogin == "true")
   {
    MessagePlayer("[#CCFF66]** Welcome back to the server.", player);
    MessagePlayer("[#CCFF66]** You've been auto logged in, to disable this, type /autologin [ Toggles automatically ]", player);
    status[player.ID].LoggedIn = true;
   }
   else
   {
    MessagePlayer("[#CCFF66]** Welcome back to the server.", player);
    MessagePlayer("[#CCFF66]** Your nick is registered. Please login in order to access services.", player);
   }
  }
  else
  {
   MessagePlayer("[#CCFF66]** Welcome back to the server.", player);
   MessagePlayer("[#CCFF66]** Your nick is registered. Please login in order to access services.", player);
  }
 }
 else
 {
  MessagePlayer("[#CCFF66]** Welcome to the server.", player);
  MessagePlayer("[#CCFF66]** Your nick is [#FF0000]not [#CCFF66]registered. Please register in order to access services.", player);
 }
 FreeSQLQuery(q);
}
NOTE: Do Not Forget To Add Class For Banned, clan, ctag, clevel.
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

Xmair

I've left vcmp along with the scripting so there's no point in mentioning me.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

umar4911

There were few more fields to be added. btw Solved it myself