Vice City: Multiplayer

Server Development => Scripting and Server Management => Script and Content Requests => Topic started by: Humzasajjad on Sep 19, 2018, 08:01 PM

Title: .db
Post by: Humzasajjad on Sep 19, 2018, 08:01 PM
Can anyone give me admin.db..or where admins data will be saved....
Admin data saved in database.db?
Title: Re: .db
Post by: Mahmoud Tornado on Sep 19, 2018, 11:34 PM
Saved in database.db like levels.
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
Level = 0;

onScriptLoad() - New database to make admin levels.
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.
IfAdmin(player);
Stats[ player.ID ] = PlayerClass();

If Admin Function.
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.
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+".");
      }
    }
   }
}
Title: Re: .db
Post by: doxuanhien2002 on Sep 20, 2018, 04:41 AM
Quote from: Humzasajjad on Sep 19, 2018, 08:01 PMCan 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
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.
Title: Re: .db
Post by: Humzasajjad on Sep 20, 2018, 11:49 AM
 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
Title: Re: .db
Post by: Mahmoud Tornado on Sep 20, 2018, 01:03 PM
Quote from: Humzasajjad on Sep 20, 2018, 11:49 AMQuerySQL(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,
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+".");
      }
   }
}
Title: Re: .db
Post by: Humzasajjad on Sep 20, 2018, 07:21 PM
Quote from: Mahmoud Tornado on Sep 20, 2018, 01:03 PM
Quote from: Humzasajjad on Sep 20, 2018, 11:49 AMQuerySQL(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,
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?
Title: Re: .db
Post by: =RK=MarineForce on Sep 20, 2018, 10:02 PM
i made this only :( :'( ...

Mahmoud Teach me on discord :P

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();
}
}
}
Title: Re: .db
Post by: Mahmoud Tornado on Sep 22, 2018, 12:53 AM
@Humzasajjad, If you use the first on in your account system use this one.
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,
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 Sep 20, 2018, 11:49 AMQuerySQL(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 Sep 20, 2018, 11:49 AMif ( 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.
Title: Re: .db
Post by: =RK=MarineForce on May 18, 2019, 02:23 AM
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..
Title: Re: .db
Post by: KrOoB_ on May 18, 2019, 03:52 AM
pff just search about it

1. Fuzzie's Account System (https://forum.vc-mp.org/?topic=224.0)
2. Anik's Account System (https://forum.vc-mp.org/?topic=4440.0)
3. Kewun Account System_1 (https://forum.vc-mp.org/?topic=3341.0)
4. Kewun Account System_2 (https://forum.vc-mp.org/?topic=3506.0)
5. Luis Account System (https://forum.vc-mp.org/?topic=3499.0)
6. ! Account System (https://forum.vc-mp.org/?topic=5144.0)
7. Muhammed's Account System (https://forum.vc-mp.org/?topic=5571.0)
Title: Re: .db
Post by: KrOoB_ on May 18, 2019, 03:59 AM
Quote from: =RK=MarineForce on May 18, 2019, 02:23 AMclass 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 ?


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 ) ");

...
Title: Re: .db
Post by: =RK=MarineForce on May 18, 2019, 04:08 AM
Thanks Bro:

but how can i add kill system when players kill a player a die.
Title: Re: .db
Post by: KrOoB_ on May 18, 2019, 04:12 AM
if u're using 7. Muhammed's Account System (https://forum.vc-mp.org/?topic=5571.0)


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

Title: Re: .db
Post by: KrOoB_ on May 18, 2019, 04:15 AM
@Mohamed already add this in his script so u don't have to do this just download it and try to understand