I add this onScriptLoad
random <- [ 1, 2, 3, 4 ];
and add this on Player Register
local team = random[rand()% random.len()]
::QuerySQL( dbGlobal, "INSERT INTO Accounts VALUES( '" + team + "' )" );
and this is Command
if ( cmd == "myteam")
{
if ( GetTeam( player ) == 1 ) MessagePlayer( "[#FF0000]MaaKi", player );
if ( GetTeam( player ) == 2 ) MessagePlayer( "[#66FF33]Fabular", player );
if ( GetTeam( player ) == 3 ) MessagePlayer( "[#6666FF]Cmon Master", player );
if ( GetTeam( player ) == 4 ) MessagePlayer( "[#FFFF00]You are noob", player );
}
Releated Functions
function SetTeam( player, amount )
{
QuerySQL(sqliteDB, "UPDATE Accounts SET Group='" + amount + "' WHERE Name='" + player.Name + "'");
}
function GetTeam( player )
{
local lvl1 = GetSQLColumnData( QuerySQL( sqliteDB, "SELECT Group FROM Accounts WHERE Name='" + player.Name+"'" ), 0 );
if ( lvl1 ) return lvl1;
else return 0;
}
Now When i Registered and check in database it show Group Random sometime 1 or 2 or 3 But when i do /myteam it show nothing i add this on Command
if ( GetTeam( player ) == 0 ) PrivMessage( player, "xD" );
then it show that message but in database it was team 2
Ouch. 4 queries each time you to do /myteam. That's gonna lag like shit when abused.
That insert query makes no sense. Do you really only have 1 column in your Accounts table?
Nah it is this
::QuerySQL( dbGlobal, "INSERT INTO Accounts VALUES('" + player.Name + "', '" + player.Name.tolower() + "', '" + ( password ) + "', 0, 0, 0, 0, 1, '" + player.IP + "', '" + team + "' )" );
Quote from: FinchDon on Sep 27, 2015, 12:13 PMNah it is this
::QuerySQL( dbGlobal, "INSERT INTO Accounts VALUES('" + player.Name + "', '" + player.Name.tolower() + "', '" + ( password ) + "', 0, 0, 0, 0, 1, '" + player.IP + "', '" + team + "' )" );
Invalid Query
actually it would have to be like this
::QuerySQL( dbGlobal, "INSERT INTO Accounts (Name, NameTolower, Password, thingone, thingtwo, thingthree, thingfour, thingfive, IP, Group ) VALUES('" + player.Name + "', '" + player.Name.tolower() + "', '" + ( password ) + "', 0, 0, 0, 0, 1, '" + player.IP + "', '" + team + "' )" );
And second thing your myteam cmd is wrong,
You using
if
if
This prevents operation to check next condition
Actually it should be like this
if ( cmd == "myteam")
{
if ( GetTeam( player ) == 1 ) MessagePlayer( "[#FF0000]MaaKi", player );
else if ( GetTeam( player ) == 2 ) MessagePlayer( "[#66FF33]Fabular", player );
else if ( GetTeam( player ) == 3 ) MessagePlayer( "[#6666FF]Cmon Master", player );
else if ( GetTeam( player ) == 4 ) MessagePlayer( "[#FFFF00]You are noob", player );
}
It's better to use array for it instead of using Query each time, I mean you can save it in DB, but load it on an array onplayerjoin, you can see FAS for more details.
Quote from: Kusanagi on Sep 27, 2015, 12:27 PMQuote from: FinchDon on Sep 27, 2015, 12:13 PMNah it is this
::QuerySQL( dbGlobal, "INSERT INTO Accounts VALUES('" + player.Name + "', '" + player.Name.tolower() + "', '" + ( password ) + "', 0, 0, 0, 0, 1, '" + player.IP + "', '" + team + "' )" );
Invalid Query
actually it would have to be like this
::QuerySQL( dbGlobal, "INSERT INTO Accounts (Name, NameTolower, Password, thingone, thingtwo, thingthree, thingfour, thingfive, IP, Group ) VALUES('" + player.Name + "', '" + player.Name.tolower() + "', '" + ( password ) + "', 0, 0, 0, 0, 1, '" + player.IP + "', '" + team + "' )" );
And second thing your myteam cmd is wrong,
You using
if
if
This prevents operation to check next condition
Actually it should be like this
if ( cmd == "myteam")
{
if ( GetTeam( player ) == 1 ) MessagePlayer( "[#FF0000]MaaKi", player );
else if ( GetTeam( player ) == 2 ) MessagePlayer( "[#66FF33]Fabular", player );
else if ( GetTeam( player ) == 3 ) MessagePlayer( "[#6666FF]Cmon Master", player );
else if ( GetTeam( player ) == 4 ) MessagePlayer( "[#FFFF00]You are noob", player );
}
You're wrong in both occasions. That query is perfectly valid, as long as he defines each column.
And while not using else if, but just if is inefficient, it certainly works.
Quote from: Thijn on Sep 27, 2015, 02:12 PMQuote from: Kusanagi on Sep 27, 2015, 12:27 PMQuote from: FinchDon on Sep 27, 2015, 12:13 PMNah it is this
::QuerySQL( dbGlobal, "INSERT INTO Accounts VALUES('" + player.Name + "', '" + player.Name.tolower() + "', '" + ( password ) + "', 0, 0, 0, 0, 1, '" + player.IP + "', '" + team + "' )" );
Invalid Query
actually it would have to be like this
::QuerySQL( dbGlobal, "INSERT INTO Accounts (Name, NameTolower, Password, thingone, thingtwo, thingthree, thingfour, thingfive, IP, Group ) VALUES('" + player.Name + "', '" + player.Name.tolower() + "', '" + ( password ) + "', 0, 0, 0, 0, 1, '" + player.IP + "', '" + team + "' )" );
And second thing your myteam cmd is wrong,
You using
if
if
This prevents operation to check next condition
Actually it should be like this
if ( cmd == "myteam")
{
if ( GetTeam( player ) == 1 ) MessagePlayer( "[#FF0000]MaaKi", player );
else if ( GetTeam( player ) == 2 ) MessagePlayer( "[#66FF33]Fabular", player );
else if ( GetTeam( player ) == 3 ) MessagePlayer( "[#6666FF]Cmon Master", player );
else if ( GetTeam( player ) == 4 ) MessagePlayer( "[#FFFF00]You are noob", player );
}
You're wrong in both occasions. That query is perfectly valid, as long as he defines each column.
And while not using else if, but just if is inefficient, it certainly works.
Really? i never tested those ways thats why i thought that
So What is Error :\
Do a print on that command.
You really have no clue how to debug stuff, do you? ...
Ya I use That
if ( cmd == "a")
{
PrivMessage( player, " ahh " + GetTeam( player ) + ".");
}
But it too show Group 0 Where it is 2 in Database
function GetTeam( player )
{
local lvl1 = GetSQLColumnData( QuerySQL( sqliteDB, "SELECT Group FROM Accounts WHERE Name='" + player.Name+"'" ), 0 );
if ( lvl1 ) return lvl1;
else return 0;
}
Post your table creating line.
I Create Table By Opening Database I open Database and edit Accounts table and add There. Group NUMERIC
POST your CREATE TABLE IF NOT EXISTS FUNCTION
I dont have that function
Quote from: KAKAN on Sep 28, 2015, 02:18 PMPOST your CREATE TABLE IF NOT EXISTS FUNCTION
He created that column manually by db browser, not by the function
Then this one can be his problem:-
He uses dbGlobal at 1st, then he uses sqliteDB, wth is that?
Wow I used sqliteDB in many places thats works but why not this?
Then why are you using dbGlobal there?
That means you are connecting dbGlobal and sqliteDB to the same db file, which won't work I guess
Its better paste the whole function here
Bhai Ye Fuzzie se baat kr iske bare me
Oh! You can tell that too. He is using functions.
Now post all the functions regarding to your random group system.
And I suggest you to use an array for doing it.
PM me the playerclass, and the DB tables, if u want an array for doing it.
:/ Genius I want in DB!!!!!!! No Array
LoL!
Load it onto the array, save it in the DB, just as Fuziee Account System
Genius Tell me what is the problem i am facing!!!!!!!!
What the....
Quote from: Xmair on Sep 28, 2015, 03:57 PMWhat the....
WHat you mean?
Did I say something wrong? If so, what?
I am not talking about you, I am talking about the person who is told what is the solution still doesn't knows it.
And now, he can never know about it too.
Anyways, I would like to request
@Thijn or any other dev to lock the topic.