Invalid String Type Error!

Started by Terror_Styles, Jul 14, 2017, 04:29 PM

Previous topic - Next topic

Terror_Styles

Hey What's Going on Guys?

I am trying to Add Clanstats in Anik GUI Registration System Everything Works Fine But
When Player Join It Pop An Error

Screenshot:



Error Lines

onPlayerJoin AccInfo(player);AccInfo Function FreeSQLQuery( Clan );
AccInfo Function
function AccInfo(player)
{
 local q = QuerySQL(DB, "SELECT * FROM Accounts WHERE Name = '" + escapeSQLString(player.Name) + "'");
 if (q)
 {
  status[player.ID].Password = GetSQLColumnData(q, 2);
  status[player.ID].Level = GetSQLColumnData(q, 3);
  status[player.ID].UID = GetSQLColumnData(q, 5);
  status[player.ID].IP = GetSQLColumnData(q, 6);
  status[player.ID].AutoLogin = GetSQLColumnData(q, 7);
  status[player.ID].Registered = true;
  if ((player.UID == status[player.ID].UID) || (player.IP == status[player.ID].IP))
  {
   if (status[player.ID].AutoLogin == "true")
   {
    MessagePlayer("[#CCFF66]** Welcome back to the server.", player);
    MessagePlayer("[#CCFF66]** You've been auto logged in, to disable this, type /autologin [ Toggles automatically ]", player);
    status[player.ID].LoggedIn = true;
local Clan = GetSQLColumnData( QuerySQL(DB, "SELECT Clan FROM Accounts WHERE Name = '"+player.Name+"' " ), 0 );

local w = QuerySQL( Clans, "SELECT * FROM ClanMembersRequest WHERE Player LIKE '" + player.Name + "' COLLATE NOCASE" );
if (w)
{
status[ player.ID ].ClanRequest = true;
status[ player.ID ].ClaneTag = GetSQLColumnData( w, 1 );
status[ player.ID ].Clane = GetSQLColumnData( w, 2 );
status[ player.ID ].ClaneState = GetSQLColumnData( w, 3 );
MessagePlayer( "[CLAN-Request] Clan [ " + status[ player.ID ].Clane + " ].Use /acceptclan or /rejectclan.",player);
}
FreeSQLQuery( w );

if ( Clan != "None" )
{
local r = QuerySQL( Clans, "SELECT Tag FROM ClanStats WHERE Clan LIKE '"+Clan+"'" );
if (r)
{
local
Tag = GetSQLColumnData( r, 0 ),
t = QuerySQL( Clans, "SELECT * FROM ClanMembers WHERE Clan LIKE '"+Clan+"'" ),
Owner = GetSQLColumnData( t, 1 ),
Leader1 = GetSQLColumnData( t, 2 ),
Leader2 = GetSQLColumnData( t, 3 ),
Leader3 = GetSQLColumnData( t, 4 ),
Users = GetSQLColumnData( t, 5 );
if ( Owner == player.Name )
{
status[ player.ID ].Clan = Clan;
status[ player.ID ].ClanTag = Tag;
status[ player.ID ].ClanState = "Owner";
}
if ( Leader1 == player.Name )
{
status[ player.ID ].Clan = Clan;
status[ player.ID ].ClanTag = Tag;
status[ player.ID ].ClanState = "Leader1";
}
if ( Leader2 == player.Name )
{
status[ player.ID ].Clan = Clan;
status[ player.ID ].ClanTag = Tag;
status[ player.ID ].ClanState = "Leader2";
}
if ( Leader3 == player.Name )
{
status[ player.ID ].Clan = Clan;
status[ player.ID ].ClanTag = Tag;
status[ player.ID ].ClanState = "Leader3";
}
if ( Users.find( player.Name ) )
{
status[ player.ID ].Clan = Clan;
status[ player.ID ].ClanTag = Tag;
status[ player.ID ].ClanState = "Users";
}
FreeSQLQuery(t);
}
FreeSQLQuery(r);
}

CheckPlayerClan( player );
FreeSQLQuery( Clan ); [b]This Line Pop error[/b]
   }
   else
   {
    MessagePlayer("[#CCFF66]** Welcome back to the server.", player);
    MessagePlayer("[#CCFF66]** Your nick is registered. Please login in order to access services.", player);
   }
  }
  else
  {
   MessagePlayer("[#CCFF66]** Welcome back to the server.", player);
   MessagePlayer("[#CCFF66]** Your nick is registered. Please login in order to access services.", player);
  }
 }
 else
 {
  MessagePlayer("[#CCFF66]** Welcome to the server.", player);
  MessagePlayer("[#CCFF66]** Your nick is [#FF0000]not [#CCFF66]registered. Please register in order to access services.", player);
 }
 FreeSQLQuery(q);
}

Anik

Try it.

function AccInfo(player)
{
 local q = QuerySQL(DB, "SELECT * FROM Accounts WHERE Name = '" + escapeSQLString(player.Name) + "'");
 if (q)
 {
  status[player.ID].Password = GetSQLColumnData(q, 2);
  status[player.ID].Level = GetSQLColumnData(q, 3);
  status[player.ID].UID = GetSQLColumnData(q, 5);
  status[player.ID].IP = GetSQLColumnData(q, 6);
  status[player.ID].AutoLogin = GetSQLColumnData(q, 7);
  status[player.ID].Registered = true;
  if ((player.UID == status[player.ID].UID) || (player.IP == status[player.ID].IP))
  {
   if (status[player.ID].AutoLogin == "true")
   {
    MessagePlayer("[#CCFF66]** Welcome back to the server.", player);
    MessagePlayer("[#CCFF66]** You've been auto logged in, to disable this, type /autologin [ Toggles automatically ]", player);
    status[player.ID].LoggedIn = true;
 local c = QuerySQL(DB, "SELECT Clan FROM Accounts WHERE Name = '"+player.Name+"' " ), Clan = GetSQLColumnData( c, 0 );

 local w = QuerySQL( Clans, "SELECT * FROM ClanMembersRequest WHERE Player LIKE '" + player.Name + "' COLLATE NOCASE" );
 if (w)
  {
  status[ player.ID ].ClanRequest = true;
  status[ player.ID ].ClaneTag = GetSQLColumnData( w, 1 );
  status[ player.ID ].Clane = GetSQLColumnData( w, 2 );
  status[ player.ID ].ClaneState = GetSQLColumnData( w, 3 );
  MessagePlayer( "[CLAN-Request] Clan [ " + status[ player.ID ].Clane + " ].Use /acceptclan or /rejectclan.",player);
  }
 FreeSQLQuery( w );
 
 if ( Clan != "None" )
  {
  local r = QuerySQL( Clans, "SELECT Tag FROM ClanStats WHERE Clan LIKE '"+Clan+"'" );
  if (r)
   {
   local
    Tag = GetSQLColumnData( r, 0 ),
    t = QuerySQL( Clans, "SELECT * FROM ClanMembers WHERE Clan LIKE '"+Clan+"'" ),
    Owner = GetSQLColumnData( t, 1 ),
    Leader1 = GetSQLColumnData( t, 2 ),
    Leader2 = GetSQLColumnData( t, 3 ),
    Leader3 = GetSQLColumnData( t, 4 ),
    Users = GetSQLColumnData( t, 5 );
   if ( Owner == player.Name )
    {
    status[ player.ID ].Clan = Clan;
    status[ player.ID ].ClanTag = Tag;
    status[ player.ID ].ClanState = "Owner";
    }
   if ( Leader1 == player.Name )
    {
    status[ player.ID ].Clan = Clan;
    status[ player.ID ].ClanTag = Tag;
    status[ player.ID ].ClanState = "Leader1";
    }
   if ( Leader2 == player.Name )
    {
    status[ player.ID ].Clan = Clan;
    status[ player.ID ].ClanTag = Tag;
    status[ player.ID ].ClanState = "Leader2";
    }
   if ( Leader3 == player.Name )
    {
    status[ player.ID ].Clan = Clan;
    status[ player.ID ].ClanTag = Tag;
    status[ player.ID ].ClanState = "Leader3";
    }
   if ( Users.find( player.Name ) )
    {
    status[ player.ID ].Clan = Clan;
    status[ player.ID ].ClanTag = Tag;
    status[ player.ID ].ClanState = "Users";
    }
   FreeSQLQuery(t);
   }
  FreeSQLQuery(r);
  }
 
 CheckPlayerClan( player );
FreeSQLQuery( c );
   }
   else
   {
    MessagePlayer("[#CCFF66]** Welcome back to the server.", player);
    MessagePlayer("[#CCFF66]** Your nick is registered. Please login in order to access services.", player);
   }
  }
  else
  {
   MessagePlayer("[#CCFF66]** Welcome back to the server.", player);
   MessagePlayer("[#CCFF66]** Your nick is registered. Please login in order to access services.", player);
  }
 }
 else
 {
  MessagePlayer("[#CCFF66]** Welcome to the server.", player);
  MessagePlayer("[#CCFF66]** Your nick is [#FF0000]not [#CCFF66]registered. Please register in order to access services.", player);
 }
 FreeSQLQuery(q);
}

Thijn

Read the error.

FreeSQL wants an instance of something ("userdata"), and you're giving it a string.

If you look at your locals, you can see the variable Clan (Which you're trying to free) contains "[vu]" at the time of the error.
Now look back to where you assign the Clan variable:
local Clan = GetSQLColumnData( QuerySQL(DB, "SELECT Clan FROM Accounts WHERE Name = '"+player.Name+"' " ), 0 );
As you can see, you assign the Clan variable to the column data, instead of the result of the actual query.
In order to fix your error, you have to assign the query to a variable, and then assign the clan variable.
Like so:
local QueryResult = QuerySQL(DB, "SELECT Clan FROM Accounts WHERE Name = '"+player.Name+"' " );
local Clan = GetSQLColumnData(QueryResult, 0 );

Then your QueryResult will hold the data for the query itself, and the Clan variable will contain the value.
Then, you can free the QueryResult and do what you want with the Clan variable:
FreeSQLQuery( QueryResult );