Recent Posts
1
Quote from =RK=MarineForce Yesterday at 02:53 PM
Code: [Select]
class PlayerStats
{
login = false;
register = false;
}

function onScriptLoad()
{
db <- ConnectSQL( "DataBase.db" );
QuerySQL( db, "CREATE TABLE IF NOT EXISTS Stats ( Name VARCHAR(32), IP VARCHAR(25), Admin TEXT, Reason TEXT )" );

database<- ConnectSQL( "database.db" );
QuerySQL( database, "CREATE TABLE IF NOT EXISTS Stats ( player VARCHAR(255), password VARCHAR(255), uid VARCHAR(255) " );
Stats <- array(GetMaxPlayers(), null);
print("Register,Login System Has Been Loaded by MarineForce");
}

function onScriptUnload()
{
DisconnectSQL( db );
DisconnectSQL( database );
}

function onPlayerJoin( player )
{
Stats[player.ID] = PlayerStats();
Message(" " + player.Name + " Has Joined The server  : " + player.IP + " ");

}

function onPlayerCommand( player, cmd, text )
{
if ( cmd == "register" )
{
  if ( ( Stats[ player.ID ].register ) || ( Stats[ player.ID ].login ) ) PrivMessage( player, "Error: You are already registered." );
  else if ( !text ) PrivMessage( player, format( "Error: Use /%s <password>", cmd ) );
  else
  {
   QuerySQL( database, "INSERT INTO Stats ( player, password, uid) VALUES ( '" + player.Name.tolower() + "', '" + SHA256( text ) + "', '" + player.UniqueID + "', '0', '0', '0', '1', '0', '1', 'on' )" );
   Stats[player.ID].register = true;
   Stats[player.ID].login = true;
   PrivMessage( player, format( "You have been successfully registered! Nickname:[ %s ] Password:[ %s ]", player.Name, text ) );
   MessageAllExcept( format( "[#00FF00]>> %s has been successfully registered.", player.Name ), player );
  }
}

else if ( cmd == "login" )
{
  if ( Stats[ player.ID ].login ) PrivMessage( player, "Error: You are already logged-in." );
  else if ( !text ) PrivMessage( player, format( "Error: Use /%s <password>", cmd ) );
  else if ( SHA256( text ) != GetSQLColumnData( QuerySQL( database, "SELECT password FROM Stats WHERE player = '" + player.Name.tolower() + "'" ), 0 ) ) PrivMessage( player, "INVALID PASSWORD." );
  else
  {
   local query = QuerySQL( database, "SELECT * FROM Stats WHERE player = '" + player.Name.tolower() + "'" );
   if ( query )
   {
   Stats[player.ID].register = true;
   Stats[player.ID].login = true;
   Message(" Welcome Back To Server " + player.Name + " ");
   }
   else PrivMessage( player, "wtf" );
  }
}
}
its not save the data when i quit. Commands Made by =TRC=Kelvin. i can but i need to know about steps.

///if i learn this thing i hope i will make my own Account System :P

///Some Things From Kelvin aCCOUNT system which i don't understand its only in cmd

Can u tell me, how to use it and what is . it

Code: [Select]
//what is GetSQLColumnData ??? and tolower

 ' + player.Name.tolower()+"' ");  what it Tolower?

I know QuerySQL( database, "SELECT password FROM Stats WHERE player  = ' " +
//else if ( SHA256( text ) != GetSQLColumnData( QuerySQL( database, "SELECT password FROM account WHERE player = '" + player.Name.tolower() + "'" ), 0 ) ) PrivMessage( player, "INVALID PASSWORD." );
// QuerySQL( database, "INSERT INTO Stats ( player, password, uid)
 //  VALUES ( '" + player.Name.tolower() + "', '" + SHA256( text ) + "', '" + player.UniqueID + "', '0', '0', '0', '1', '0', '1', 'on' )" );
Haven't you written a code where it'll update the player's statistics into the database on the onPlayerPart event?
2
Snippet Showroom / a
« Today at 06:33 AM by Xmair »
No it can work with both.
3
Script and Content Requests / Re: .db
« Today at 01:53 AM by Mahmoud Tornado »
@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, 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, 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.
4
GetSQLColumnData
Tolower
"The C library function int tolower(int c) converts a given letter to lowercase."
6
Support / : Property system bug
« Yesterday at 03:05 PM by Nihongo^ »
Hi thanks for your help i am facing an other problem now cmd not placing Name on DB kindly check the image and function

Code: [Select]
function CreateProperty( name, price, x, y, z, world )
{
    local see_dbProperties = QuerySQL ( dbProperties, "SELECT * FROM sqlite_master WHERE type='table' AND name='Properties'" );
    if( !see_dbProperties ) return print( "[dbProps] There are no properties." );
    else FreeSQLQuery( see_dbProperties );
   
        local p = CreatePickup( PROP_MODEL_FORSALE, world, 0, x, y, z, 255, true );
        if( p )
        {
            prop[ p.ID ] = null;
            prop[ p.ID ] = Property(); // important
            prop[ p.ID ].ID = _srv_Properties;
            prop[ p.ID ].Name = name;
            prop[ p.ID ].Price = price;
            prop[ p.ID ].Owner = NO_OWNER_MSG;
            prop[ p.ID ].Sharing = NO_SHARING_MSG;
            prop[ p.ID ].Description = NO_DESCRIPTION_MSG;
            prop[ p.ID ].x = x;
            prop[ p.ID ].y = y;
            prop[ p.ID ].z = z;
            prop[ p.ID ].World = world;
           
            local   query = format( "INSERT INTO Properties ( ID, Name, Price, Owner, Sharing, Description, x, y, z, World ) VALUES ( %i, '%s', %i, '%s', '%s', '%s', %f, %f, %f, %i )",
                        _srv_Properties, name, price, NO_OWNER_MSG, NO_SHARING_MSG, NO_DESCRIPTION_MSG, x, y, z, world );
                       
            QuerySQL( dbProperties, query );
           
            _srv_Properties += 1;
        }
}

Code: [Select]
else if( cmd == "addprop" )
        {
            if( !text ) return pMSG( "Error - Syntax: /" + cmd + " <price> <name>", player );
            else if( player.Vehicle ) return pMSG( "Error - Exit the vehicle first.", player );
            else if( NumTok( text, " " ) < 2 ) return pMSG( "Error - Syntax: /" + cmd + " <price> <name>", player );
            else if( typeof( GetTok( text, " ", 1 ).tointeger() ) != "integer" ) return pMSG( "Error - Usually 'price' means numbers...", player );
            else if( GetTok( text, " ", 2, NumTok( text, " " ) ).tolower() == "default" ) return pMSG( "Error - The name 'default' cannot be used.", player );
            else
            {
                local   price = GetTok( text, " ", 1 ).tointeger(),
                        name = GetTok( text, " ", 2, NumTok( text, " " ) );
                 
                CreateProperty( name, price, player.Pos.x, player.Pos.y, player.Pos.z, player.World )                 
                pMSG( "[dbProperties]: Property " + name + " was created.", player);
            }
        }
7
Code: [Select]
class PlayerStats
{
login = false;
register = false;
}

function onScriptLoad()
{
db <- ConnectSQL( "DataBase.db" );
QuerySQL( db, "CREATE TABLE IF NOT EXISTS Stats ( Name VARCHAR(32), IP VARCHAR(25), Admin TEXT, Reason TEXT )" );

database<- ConnectSQL( "database.db" );
QuerySQL( database, "CREATE TABLE IF NOT EXISTS Stats ( player VARCHAR(255), password VARCHAR(255), uid VARCHAR(255) " );
Stats <- array(GetMaxPlayers(), null);
print("Register,Login System Has Been Loaded by MarineForce");
}

function onScriptUnload()
{
DisconnectSQL( db );
DisconnectSQL( database );
}

function onPlayerJoin( player )
{
Stats[player.ID] = PlayerStats();
Message(" " + player.Name + " Has Joined The server  : " + player.IP + " ");

}

function onPlayerCommand( player, cmd, text )
{
if ( cmd == "register" )
{
  if ( ( Stats[ player.ID ].register ) || ( Stats[ player.ID ].login ) ) PrivMessage( player, "Error: You are already registered." );
  else if ( !text ) PrivMessage( player, format( "Error: Use /%s <password>", cmd ) );
  else
  {
   QuerySQL( database, "INSERT INTO Stats ( player, password, uid) VALUES ( '" + player.Name.tolower() + "', '" + SHA256( text ) + "', '" + player.UniqueID + "', '0', '0', '0', '1', '0', '1', 'on' )" );
   Stats[player.ID].register = true;
   Stats[player.ID].login = true;
   PrivMessage( player, format( "You have been successfully registered! Nickname:[ %s ] Password:[ %s ]", player.Name, text ) );
   MessageAllExcept( format( "[#00FF00]>> %s has been successfully registered.", player.Name ), player );
  }
}

else if ( cmd == "login" )
{
  if ( Stats[ player.ID ].login ) PrivMessage( player, "Error: You are already logged-in." );
  else if ( !text ) PrivMessage( player, format( "Error: Use /%s <password>", cmd ) );
  else if ( SHA256( text ) != GetSQLColumnData( QuerySQL( database, "SELECT password FROM Stats WHERE player = '" + player.Name.tolower() + "'" ), 0 ) ) PrivMessage( player, "INVALID PASSWORD." );
  else
  {
   local query = QuerySQL( database, "SELECT * FROM Stats WHERE player = '" + player.Name.tolower() + "'" );
   if ( query )
   {
   Stats[player.ID].register = true;
   Stats[player.ID].login = true;
   Message(" Welcome Back To Server " + player.Name + " ");
   }
   else PrivMessage( player, "wtf" );
  }
}
}
its not save the data when i quit. Commands Made by =TRC=Kelvin. i can but i need to know about steps.

///if i learn this thing i hope i will make my own Account System :P

///Some Things From Kelvin aCCOUNT system which i don't understand its only in cmd

Can u tell me, how to use it and what is . it

Code: [Select]
//what is GetSQLColumnData ??? and tolower

 ' + player.Name.tolower()+"' ");  what it Tolower?

I know QuerySQL( database, "SELECT password FROM Stats WHERE player  = ' " +
//else if ( SHA256( text ) != GetSQLColumnData( QuerySQL( database, "SELECT password FROM account WHERE player = '" + player.Name.tolower() + "'" ), 0 ) ) PrivMessage( player, "INVALID PASSWORD." );
// QuerySQL( database, "INSERT INTO Stats ( player, password, uid)
 //  VALUES ( '" + player.Name.tolower() + "', '" + SHA256( text ) + "', '" + player.UniqueID + "', '0', '0', '0', '1', '0', '1', 'on' )" );
8
@xmair its only for customs vehicle? hmm nyc.
9
Looks good
10
You could just..
Code: [Select]
oldGetAutomobileModel <- GetVehicleNameFromModel;
function GetVehicleNameFromModel( intModel ) {
switch( intModel ) {
case 6400:
return "Custom vehicle #1";
break;

case 6401:
return "Custom vehicle #2";
break;

// And so on

default:
return oldGetAutomobileModel( intModel );
break;
}
}