help!

Started by wilber32, Nov 16, 2015, 01:20 AM

Previous topic - Next topic

wilber32

When I add joins in this system tells me an error,  How to add Joins?
class PlayerClass{
// ------------------------------------------------------------------- //

LastUsedIP = "0.0.0.0";
Cash = 0;
Bank = 0;
Kills = 0;
Deaths = 0;
Level = 0;
Logged = false;

// ------------------------------------------------------------------- //

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

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;
::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() + "'" );
}

function Register( player, password, dbGlobal ){
::QuerySQL( dbGlobal, "INSERT INTO Accounts VALUES('" + player.Name + "', '" + player.Name.tolower() + "', '" + ::SHA256( password ) + "', 0, 0, 0, 0, 1, '" + player.IP + "')" );
Level = 1;
LastUsedIP = player.IP;
Logged = true;
::MessagePlayer( "Successfully registered.", player );
::MessagePlayer( "Don't forget your password. [" + password + "]", player );
}

function Login( player, password, dbGlobal ){
local query = ::QuerySQL( dbGlobal, "SELECT Password FROM Accounts WHERE Name='" + player.Name + "' AND NameLower='" + player.Name.tolower() + "'" );
if( ::GetSQLColumnData( query, 0 ) == null ){
::MessagePlayer( "You are not registered.", player );
}
else if( ::SHA256( password ) != ::GetSQLColumnData( query, 0 ) ){
::MessagePlayer( "Wrong password.", player );
}
else{
LastUsedIP = player.IP;
Logged = true;
::MessagePlayer( "Successfully logged in.", player );
}
}
}
data base
CREATE TABLE Accounts ( Name VARCHAR(255), NameLower VARCHAR(255), Password VARCHAR(255), Cash INT, Bank INT, Kills INT, Deaths INT, Level INT, LastUsedIP VARCHAR(255) )

MacTavish

Now i wont help you anymore you asshole when i posted an solution you just erased the topic

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

wilber32

I'm sorry What happened was that you post something that no one would understand, I just want to add joins to this system

jayant

Omg..I am now afraid that no one will help now..

In your database add a new columns "join".In PlayerClass  Joins = 0;.Increase the Joins when a player joins your server.

wilber32

Thanks You But things have yet to add

KAKAN

In your databASE
oh no

MacTavish

#6
To add Joins column use this as i posted in your old topic

Quote from: From old topicyea sure you can just use this Query only once

KEEP IN MIND USE IT ONLY ONCE
QuerySQL( sqliteDB, "ALTER TABLE Accounts ADD COLUMN Joins NUMERIC DEFAULT 0" );

and your scrips code

class PlayerClass{
// ------------------------------------------------------------------- //
 
 LastUsedIP = "0.0.0.0";
 Cash = 0;
 Bank = 0;
 Kills = 0;
 Deaths = 0;
 Level = 0;
 Logged = false;
Joins = 0;
 
// ------------------------------------------------------------------- //
 
 constructor( playerName, dbGlobal ){
 local query = ::QuerySQL( dbGlobal, "SELECT Cash, Bank, Kills, Deaths, Level, LastUsedIP, Joins 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 );
Joins =  ::GetSQLColumnData( query, 6 );
 }
 ::FreeSQLQuery( query );
 }
 
 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;
Joins+1;
 ::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 + "', Joins='" + Joins + "' WHERE Name='" + player.Name + "' AND NameLower='" + player.Name.tolower() + "'" );
 }
 
 function Register( player, password, dbGlobal ){
 ::QuerySQL( dbGlobal, "INSERT INTO Accounts VALUES('" + player.Name + "', '" + player.Name.tolower() + "', '" + ::SHA256( password ) + "', 0, 0, 0, 0, 1, '" + player.IP + "', 1)" );
 Level = 1;
 LastUsedIP = player.IP;
 Logged = true;
Joins+1;
 ::MessagePlayer( "Successfully registered.", player );
 ::MessagePlayer( "Don't forget your password. [" + password + "]", player );
 }
 
 function Login( player, password, dbGlobal ){
 local query = ::QuerySQL( dbGlobal, "SELECT Password FROM Accounts WHERE Name='" + player.Name + "' AND NameLower='" + player.Name.tolower() + "'" );
 if( ::GetSQLColumnData( query, 0 ) == null ){
 ::MessagePlayer( "You are not registered.", player );
 }
 else if( ::SHA256( password ) != ::GetSQLColumnData( query, 0 ) ){
 ::MessagePlayer( "Wrong password.", player );
 }
 else{
 LastUsedIP = player.IP;
 Logged = true;
Joins+1;
 ::MessagePlayer( "Successfully logged in.", player );
 }
 }
}

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

KAKAN

Change this:-
local query = ::QuerySQL( dbGlobal, "SELECT Cash, Bank, Kills, Deaths, Level, LastUsedIP FROM Accounts WHERE Name='" + playerName + "' AND NameLower='" + playerName.tolower() + "'" );
 
To this:-
local query = ::QuerySQL( dbGlobal, "SELECT Cash, Bank, Kills, Deaths, Level, LastUsedIP, Joins FROM Accounts WHERE Name='" + playerName + "' AND NameLower='" + playerName.tolower() + "'" );
 
Make sure u have joins thing in your db
oh no

wilber32

Thanks ilove to all :D