.db

Humzasajjad

  • Newbie
  • Posts: 24
.db
«  »
Can anyone give me admin.db..or where admins data will be saved....
Admin data saved in database.db?

Mahmoud Tornado

  • Full Member
  • Posts: 220
Re: .db
« Reply #1,  »
Saved in database.db like levels.
Code: [Select]
QuerySQL(db, "create table if not exists Database ( Name TEXT, LowerName TEXT, Password VARCHAR(255), Level NUMERIC DEFAULT 1, IP VARCHAR(255) ");

Or you can make another one with all things like an new account system.

class PlayerClass - Stats[player.ID].Level
Code: [Select]
Level = 0;

onScriptLoad() - New database to make admin levels.
Code: [Select]
Admindb <- ConnectSQL("AdminsDataBase.db");
 QuerySQL(Admindb, "create table if not exists Admins ( Name TEXT, LowerName TEXT, Level NUMERIC DEFAULT 0 ) ");
 Stats <- array(GetMaxPlayers(), null);

onPlayerJoin( player ) - Getting admin stats.
Code: [Select]
IfAdmin(player);
Stats[ player.ID ] = PlayerClass();

If Admin Function.
Code: [Select]
function IfAdmin(player)
{
 local q = QuerySQL(Admindb, "SELECT * FROM Admins WHERE Name = '" + escapeSQLString(player.Name) + "'");
 if (q)
 {
  Stats[ player.ID ].Level = GetSQLColumnData(q, 1);
 }
}

Setlevel Command.
Code: [Select]
if ( cmd == "setlevel" )
{
if ( !text ) MessagePlayer( "/"+cmd+" <Nick/id> <Level>", player );
   else
   {
      local
         plr = GetPlayer( GetTok( text, " ", 1 ) ),
         lvl = GetTok( text, " ", 2),
      if ( !plr ) MessagePlayer( "Unknown Player..", player );
     else if ( !lvl ) MessagePlayer("You must put a level.", player);
      else if ( !IsNum( lvl ) ) MessagePlayer("Level must be in numbers.", player);
      else
      {
  local q = QuerySQL(Admindb, "SELECT * FROM Admins WHERE Name = '" + escapeSQLString(plr.Name) + "'");
if (!q)   QuerySQL( DataBase, "INSERT INTO Accounts ( Name, LowerName, Level ) VALUES ( '" + escapeSQLString(plr.Name) + "','" + escapeSQLString(plr.Name) + "','" + 0 + "')" );
else
{
         Stats[ plr.ID ].Level = lvl.tointeger();
QuerySQL( Admindb, "UPDATE Admins SET Level='"+lvl+"' WHERE Name LIKE '" + plr.Name + "'" );
         Message("Administration Command: Admin "+player.Name+" Has Set "+plr.Name+" As an admin level: "+lvl+".");
      }
    }
   }
}

doxuanhien2002

  • Newbie
  • Posts: 9
Re: .db
« Reply #2,  »
Quote from Humzasajjad on September 19th, 2018, 09:01 PM
Can anyone give me admin.db..or where admins data will be saved....
Admin data saved in database.db?
https://forum.vc-mp.org/?topic=3364.0
Code: [Select]
Flooding the board with separate requests for many disparate items is not allowed.
If you need a whole set of things for your server, you should list them all in one thread rather than spamming this board with fifteen threads about each of the things you want your server to do.

Humzasajjad

  • Newbie
  • Posts: 24
Re: .db
« Reply #3,  »
 QuerySQL(db, "create table if not exists Database ( Name TEXT, LowerName TEXT, Password VARCHAR(255), Level NUMERIC DEFAULT 1, IP VARCHAR(255) ");
if ( cmd == "setlevel" )
{
if ( !text ) MessagePlayer( "/"+cmd+" <Nick/id> <Level>", player );
   else
   {
      local
         plr = GetPlayer( GetTok( text, " ", 1 ) ),
         lvl = GetTok( text, " ", 2),
      if ( !plr ) MessagePlayer( "Unknown Player..", player );
     else if ( !lvl ) MessagePlayer("You must put a level.", player);
      else if ( !IsNum( lvl ) ) MessagePlayer("Level must be in numbers.", player);
      else
      {
   local q = QuerySQL(Admindb, "SELECT * FROM Admins WHERE Name = '" + escapeSQLString(plr.Name) + "'");
  if (!q)   QuerySQL( DataBase, "INSERT INTO Accounts ( Name, LowerName, Level ) VALUES ( '" + escapeSQLString(plr.Name) + "','" + escapeSQLString(plr.Name) + "','" + 0 + "')" );
  else
 {
         Stats[ plr.ID ].Level = lvl.tointeger();
  QuerySQL( Admindb, "UPDATE Admins SET Level='"+lvl+"' WHERE Name LIKE '" + plr.Name + "'" );
         Message("Administration Command: Admin "+player.Name+" Has Set "+plr.Name+" As an admin level: "+lvl+".");
      }
    }
   }
}
bro when i add this there was on script load error comes

Mahmoud Tornado

  • Full Member
  • Posts: 220
Re: .db
« Reply #4,  »
Quote from Humzasajjad on September 20th, 2018, 12:49 PM
QuerySQL(db, "create table if not exists Database ( Name TEXT, LowerName TEXT, Password VARCHAR(255), Level NUMERIC DEFAULT 1, IP VARCHAR(255) ");
if ( cmd == "setlevel" )
{
if ( !text ) MessagePlayer( "/"+cmd+" <Nick/id> <Level>", player );
   else
   {
      local
         plr = GetPlayer( GetTok( text, " ", 1 ) ),
         lvl = GetTok( text, " ", 2),
      if ( !plr ) MessagePlayer( "Unknown Player..", player );
     else if ( !lvl ) MessagePlayer("You must put a level.", player);
      else if ( !IsNum( lvl ) ) MessagePlayer("Level must be in numbers.", player);
      else
      {
   local q = QuerySQL(Admindb, "SELECT * FROM Admins WHERE Name = '" + escapeSQLString(plr.Name) + "'");
  if (!q)   QuerySQL( DataBase, "INSERT INTO Accounts ( Name, LowerName, Level ) VALUES ( '" + escapeSQLString(plr.Name) + "','" + escapeSQLString(plr.Name) + "','" + 0 + "')" );
  else
 {
         Stats[ plr.ID ].Level = lvl.tointeger();
  QuerySQL( Admindb, "UPDATE Admins SET Level='"+lvl+"' WHERE Name LIKE '" + plr.Name + "'" );
         Message("Administration Command: Admin "+player.Name+" Has Set "+plr.Name+" As an admin level: "+lvl+".");
      }
    }
   }
}
bro when i add this there was on script load error comes
This /setlevel command, for the second system not the first.
For the first will being like that,
Code: [Select]
else if ( cmd == "setlevel" )
{
   if ( !text ) MessagePlayer( "/"+cmd+" <Nick/id> <Level>", player );
   else
   {
      local
         plr = GetPlayer( GetTok( text, " ", 1 ) ),
         lvl = GetTok( text, " ", 2);
      if ( !plr ) MessagePlayer( "Unknown Player..", player );
     else if ( !lvl ) MessagePlayer("You must put a level.", player);
      else if ( !IsNum( lvl ) ) MessagePlayer("Level must be in numbers.", player);
      else
      {
         Stats[ plr.ID ].Level = lvl.tointeger();
         QuerySQL( db,"UPDATE Database SET Level='"+lvl+"' WHERE lower(Name) LIKE '"+plr.Name+"'");
         Message("Administration Command: Admin "+player.Name+" Has Set level of "+plr.Name+" to: "+lvl+".");
      }
   }
}

Humzasajjad

  • Newbie
  • Posts: 24
Re: .db
« Reply #5,  »
Quote from Mahmoud Tornado on September 20th, 2018, 02:03 PM
Quote from Humzasajjad on September 20th, 2018, 12:49 PM
QuerySQL(db, "create table if not exists Database ( Name TEXT, LowerName TEXT, Password VARCHAR(255), Level NUMERIC DEFAULT 1, IP VARCHAR(255) ");
if ( cmd == "setlevel" )
{
if ( !text ) MessagePlayer( "/"+cmd+" <Nick/id> <Level>", player );
   else
   {
      local
         plr = GetPlayer( GetTok( text, " ", 1 ) ),
         lvl = GetTok( text, " ", 2),
      if ( !plr ) MessagePlayer( "Unknown Player..", player );
     else if ( !lvl ) MessagePlayer("You must put a level.", player);
      else if ( !IsNum( lvl ) ) MessagePlayer("Level must be in numbers.", player);
      else
      {
   local q = QuerySQL(Admindb, "SELECT * FROM Admins WHERE Name = '" + escapeSQLString(plr.Name) + "'");
  if (!q)   QuerySQL( DataBase, "INSERT INTO Accounts ( Name, LowerName, Level ) VALUES ( '" + escapeSQLString(plr.Name) + "','" + escapeSQLString(plr.Name) + "','" + 0 + "')" );
  else
 {
         Stats[ plr.ID ].Level = lvl.tointeger();
  QuerySQL( Admindb, "UPDATE Admins SET Level='"+lvl+"' WHERE Name LIKE '" + plr.Name + "'" );
         Message("Administration Command: Admin "+player.Name+" Has Set "+plr.Name+" As an admin level: "+lvl+".");
      }
    }
   }
}
bro when i add this there was on script load error comes
This /setlevel command, for the second system not the first.
For the first will being like that,
Code: [Select]
else if ( cmd == "setlevel" )
{
   if ( !text ) MessagePlayer( "/"+cmd+" <Nick/id> <Level>", player );
   else
   {
      local
         plr = GetPlayer( GetTok( text, " ", 1 ) ),
         lvl = GetTok( text, " ", 2);
      if ( !plr ) MessagePlayer( "Unknown Player..", player );
     else if ( !lvl ) MessagePlayer("You must put a level.", player);
      else if ( !IsNum( lvl ) ) MessagePlayer("Level must be in numbers.", player);
      else
      {
         Stats[ plr.ID ].Level = lvl.tointeger();
         QuerySQL( db,"UPDATE Database SET Level='"+lvl+"' WHERE lower(Name) LIKE '"+plr.Name+"'");
         Message("Administration Command: Admin "+player.Name+" Has Set level of "+plr.Name+" to: "+lvl+".");
      }
   }
}
it works but when i type /setlevel <myname> <lvl>there was no message and change...what to do?

=RK=MarineForce

  • Sr. Member
  • WAR IS HELL!
  • Posts: 430
Re: .db
« Reply #6,  »
i made this only :( :'( ...

Mahmoud Teach me on discord :P

Code: [Select]
class PlayerStats
{
Level = 1;
}

function onScriptLoad()
{
QuerySQL(level, "create table if not exists Level ( Name Text, Password VARCHAR(255), Level NUMERIC, IP VARCHAR(255) ");
Ldb <- ConnectSQL("LevelDatabase.db");
}

Function OnScriptUnload()
{
DisconnectSQL("level" )
}

function onPlayerJoin( player )
{
Stats[ player.ID ] = PlayerStats();
}


else if ( cmd == "setlevel" )
{
if(!text) MessagePlayer(" /" + cmd + " <Nick> <Level> ",player);
else{
local plr = FindPlayer(text);
if(!plr) MessagePlayer(" [#ff0000] Error " + text + " is not online ",player);
else{
Stats[ plr.ID ].Level = text.tointeger();
}
}
}
Try to UnderStand ME!

Mahmoud Tornado

  • Full Member
  • Posts: 220
Re: .db
« Reply #7,  »
@Humzasajjad, If you use the first on in your account system use this one.
Code: [Select]
else if ( cmd == "setlevel" )
{
   if ( !text ) MessagePlayer( "/"+cmd+" <Nick/id> <Level>", player );
   else
   {
      local
         plr = GetPlayer( GetTok( text, " ", 1 ) ),
         lvl = GetTok( text, " ", 2);
      if ( !plr ) MessagePlayer( "Unknown Player..", player );
     else if ( !lvl ) MessagePlayer("You must put a level.", player);
      else if ( !IsNum( lvl ) ) MessagePlayer("Level must be in numbers.", player);
      else
      {
         Stats[ plr.ID ].Level = lvl.tointeger();
         QuerySQL( db,"UPDATE Database SET Level='"+lvl+"' WHERE lower(Name) LIKE '"+plr.Name+"'");
         Message("Administration Command: Admin "+player.Name+" Has Set level of "+plr.Name+" to: "+lvl+".");
      }
   }
}

If you using the second one use this,
Code: [Select]
if ( cmd == "setlevel" )
{
if ( !text ) MessagePlayer( "/"+cmd+" <Nick/id> <Level>", player );
   else
   {
      local
         plr = GetPlayer( GetTok( text, " ", 1 ) ),
         lvl = GetTok( text, " ", 2),
      if ( !plr ) MessagePlayer( "Unknown Player..", player );
     else if ( !lvl ) MessagePlayer("You must put a level.", player);
      else if ( !IsNum( lvl ) ) MessagePlayer("Level must be in numbers.", player);
      else
      {
   local q = QuerySQL(Admindb, "SELECT * FROM Admins WHERE Name = '" + escapeSQLString(plr.Name) + "'");
  if (!q)   QuerySQL( DataBase, "INSERT INTO Accounts ( Name, LowerName, Level ) VALUES ( '" + escapeSQLString(plr.Name) + "','" + escapeSQLString(plr.Name) + "','" + 0 + "')" );
  else
 {
         Stats[ plr.ID ].Level = lvl.tointeger();
  QuerySQL( Admindb, "UPDATE Admins SET Level='"+lvl+"' WHERE Name LIKE '" + plr.Name + "'" );
         Message("Administration Command: Admin "+player.Name+" Has Set "+plr.Name+" As an admin level: "+lvl+".");
      }
    }
   }
}

It's not doing thing, as you are using the two systems together, and you can't make two level stats for the player.
Quote from Humzasajjad on September 20th, 2018, 12:49 PM
QuerySQL(db, "create table if not exists Database ( Name TEXT, LowerName TEXT, Password VARCHAR(255), Level NUMERIC DEFAULT 1, IP VARCHAR(255) ");
This is the first system, this is a addition to accounts system.

But the command which you used is for the admins db.
Quote from Humzasajjad on September 20th, 2018, 12:49 PM
if ( cmd == "setlevel" )
{
if ( !text ) MessagePlayer( "/"+cmd+" <Nick/id> <Level>", player );
   else
   {
      local
         plr = GetPlayer( GetTok( text, " ", 1 ) ),
         lvl = GetTok( text, " ", 2),
      if ( !plr ) MessagePlayer( "Unknown Player..", player );
     else if ( !lvl ) MessagePlayer("You must put a level.", player);
      else if ( !IsNum( lvl ) ) MessagePlayer("Level must be in numbers.", player);
      else
      {
   local q = QuerySQL(Admindb, "SELECT * FROM Admins WHERE Name = '" + escapeSQLString(plr.Name) + "'");
  if (!q)   QuerySQL( DataBase, "INSERT INTO Accounts ( Name, LowerName, Level ) VALUES ( '" + escapeSQLString(plr.Name) + "','" + escapeSQLString(plr.Name) + "','" + 0 + "')" );
  else
 {
         Stats[ plr.ID ].Level = lvl.tointeger();
  QuerySQL( Admindb, "UPDATE Admins SET Level='"+lvl+"' WHERE Name LIKE '" + plr.Name + "'" );
         Message("Administration Command: Admin "+player.Name+" Has Set "+plr.Name+" As an admin level: "+lvl+".");
      }
    }
   }
}
So it must get error.

=RK=MarineForce

  • Sr. Member
  • WAR IS HELL!
  • Posts: 430
Re: .db
« Reply #8,  »Last edited
Code: [Select]
class PlayerStats
{
Level = 0;
Cash = 1;
Kills = 1;
Deaths = 1;
}

function OnScriptLoad()
{
Yesdb <- ConnectSQL("YesDatabase.db");
QuerySQL(Yesdb, "CREATE TABLE IF NOT EXISTS Admins ( Name TEXT, LowerName TEXT, Level NUMERIC DEFAULT 0 ) ");
QuerySQL(Yesdb, "CREATE TABLE IF NOT EXISTS Kills ( Name TEXT, LowerName TEXT, Kills NUMERIC DEFAULT 1 ) ");
QuerySQL(Yesdb, "CREATE TABLE IF NOT EXISTS Deaths ( Name TEXT, LowerName TEXT,Deaths NUMERIC DEFAULT 1 ) ");
QuerySQL(Yesdb, "CREATETABLE IF NOT EXISTS Cash ( Name TEXT, LowerName TEXT, Cash NUMERIC DEFAULT 1 ) ");
Stats <- array(GetMaxPlayers(), null);
}
function onPlayerJoin( player )
{
Stats[ player.ID ] = PlayerStats();
}
i made some thing like this but i don't know how can i save kills deaths etc. help..
Try to UnderStand ME!

KrooB

  • Full Member
  • BEN TÜRKÜM
  • Posts: 116
Re: .db
« Reply #10,  »Last edited
Quote from =RK=MarineForce on May 18th, 03:23 AM
Code: [Select]
class PlayerStats
{
Level = 0;
Cash = 1;
Kills = 1;
Deaths = 1;
}

function OnScriptLoad()
{
Yesdb <- ConnectSQL("YesDatabase.db");
QuerySQL(Yesdb, "CREATE TABLE IF NOT EXISTS Admins ( Name TEXT, LowerName TEXT, Level NUMERIC DEFAULT 0 ) ");
QuerySQL(Yesdb, "CREATE TABLE IF NOT EXISTS Kills ( Name TEXT, LowerName TEXT, Kills NUMERIC DEFAULT 1 ) ");
QuerySQL(Yesdb, "CREATE TABLE IF NOT EXISTS Deaths ( Name TEXT, LowerName TEXT,Deaths NUMERIC DEFAULT 1 ) ");
QuerySQL(Yesdb, "CREATETABLE IF NOT EXISTS Cash ( Name TEXT, LowerName TEXT, Cash NUMERIC DEFAULT 1 ) ");
Stats <- array(GetMaxPlayers(), null);
}
function onPlayerJoin( player )
{
Stats[ player.ID ] = PlayerStats();
}
i made some thing like this but i don't know how can i save kills deaths etc. help..
why did u split them ?

Code: [Select]

class PlayerSystem
{
 Level = 0; // For Admin system
 Kills = 0;
 Deaths = 0;
 Cash = 0;
 Bank = 0;
...
...
...
}
QuerySQL(System, "create table if not exists Accounts ( Name TEXT, LowerName TEXT,  Level NUMERIC DEFAULT 1, Kills NUMERIC DEFAULT 0, Deaths NUMERIC DEFAULT 0, Cash NUMERIC DEFAULT 0, Bank NUMERIC DEFAULT 0 ) ");

...
We are his people !
Who can challange us ?

=RK=MarineForce

  • Sr. Member
  • WAR IS HELL!
  • Posts: 430
Re: .db
« Reply #11,  »
Thanks Bro:

but how can i add kill system when players kill a player a die.
Try to UnderStand ME!

KrooB

  • Full Member
  • BEN TÜRKÜM
  • Posts: 116
Re: .db
« Reply #12,  »Last edited
if u're using 7. Muhammed's Account System


and for onPlayerKill
Code: [Select]
stats[ killer.ID ].Kills ++;
stats[ player.ID ].Deaths ++;

Re: .db
« Reply #13,  »
@Mohamed already add this in his script so u don't have to do this just download it and try to understand
We are his people !
Who can challange us ?