this is a simple function to find clan members that i made
function FindMemberClan( player )
{
local q = QuerySQL( clanstat, "SELECT * FROM ClanUsers WHERE Clans LIKE '"+GetTag( player.Name )+"'" );
if ( q )
{
if ( GetSQLColumnData( q, 1 ) == player.Name )
{
_MessagePlayer( white+"[ "+pink+GetTag( player.Name )+white+" ]- MEMBER: "+purple+TruncateClan( player.Name )+"", white+"[ "+pink+GetTag( player.Name )+white+" ]- MIEMBRO: "+purple+TruncateClan( player.Name )+"", player );
}
else
{
_MessagePlayer("You are not "+GetTag( player.Name )+" member you will be jailed and then kicked.", "No eres miembro de el clan "+GetTag( player.Name )+", seras encarcelado y despues kickeado.", player)
}
}
FreeSQLQuery( q )
}
but only the first player registered in clan's database is recognized as a member what is wrong with it? here some pictures...
this is the database the first player is recognized as member the second one as not clan member.
(https://1.bp.blogspot.com/-NoKigA6pQ6E/XHL_rkv3k-I/AAAAAAAAA1Y/HWHeCO7pAMwZETnch4PqyXV-TQF0FloGgCLcBGAs/s1600/a5207b00-76a4-4244-a46f-20e9e71e8ca6.jpg)
first account, recognized.
(https://3.bp.blogspot.com/-QrAllp8KZLs/XHL_rwR9DtI/AAAAAAAAA1c/ruLRZrKedRMc3oSQY-MfuYCDw-L6kcVLACLcBGAs/s1600/42e4ea80-35f4-4e26-b47b-20f520fad5fb.jpg)
second account, not recognized.
(https://2.bp.blogspot.com/-El_MSBQ6Dic/XHL_rjGZ2oI/AAAAAAAAA1U/nkir2turPR8HqJEHA4Z7tFE8VhpUtfNOQCLcBGAs/s1600/10fb503c-7cc4-4973-93a5-704ac07e9807.jpg)
You're only checking the first row of the result data which means that the check if ( GetSQLColumnData( q, 1 ) == player.Name )
never is true for anyone but the first player of the clan.
EDIT: What you want is probably something like this:
function FindMemberClan( player )
{
local q = QuerySQL( clanstat, "SELECT * FROM ClanUsers WHERE Clans LIKE '" +
GetTag( player.Name )+"'" );
if ( q )
{
while ( GetSQLNextRow(q) )
{
if ( GetSQLColumnData( q, 1 ) == player.Name )
{
_MessagePlayer( white + "[ " + pink + GetTag( player.Name ) + white +
" ]- MEMBER: " + purple + TruncateClan( player.Name ), player );
}
else
{
_MessagePlayer("You are not " + GetTag( player.Name ) +
" member you will be jailed and then kicked.", player);
}
}
}
FreeSQLQuery( q );
}
no work! now either accounts are detected as members
Try it like this?
function FindMemberClan( player )
{
local q = QuerySQL( clanstat, "SELECT * FROM ClanUsers WHERE Clans LIKE '" +
GetTag( player.Name )+"'" );
if ( q )
{
do
{
if ( GetSQLColumnData( q, 1 ) == player.Name )
{
_MessagePlayer( white + "[ " + pink + GetTag( player.Name ) + white +
" ]- MEMBER: " + purple + TruncateClan( player.Name ), player );
}
else
{
_MessagePlayer("You are not " + GetTag( player.Name ) +
" member you will be jailed and then kicked.", player);
}
}
while ( GetSQLNextRow(q) );
}
FreeSQLQuery( q );
}
solved, thank u so much !!
Previous code had a bug (could output both "you are not a member" and "you are a member"). Please consider using this instead:
function FindMemberClan( player )
{
local q = QuerySQL( clanstat, "SELECT * FROM ClanUsers WHERE Clans LIKE '" +
GetTag( player.Name )+"'" );
if ( q )
{
do
{
if ( GetSQLColumnData( q, 1 ) == player.Name )
{
_MessagePlayer( white + "[ " + pink + GetTag( player.Name ) + white +
" ]- MEMBER: " + purple + TruncateClan( player.Name ), player );
FreeSQLQuery( q );
return;
}
}
while ( GetSQLNextRow(q) );
_MessagePlayer("You are not " + GetTag( player.Name ) +
" member you will be jailed and then kicked.", player);
}
else
{
print( "SQLite query failed" );
}
FreeSQLQuery( q );
}
oh yeah, thank u for fixed it up..