Load ITC does not exists along with other errors.

Started by Pr0Ankit, May 22, 2015, 12:48 AM

Previous topic - Next topic

Pr0Ankit

Hello Everyone,

I am new to Squirrel Scripting and currently I'm putting skins,team and messages in my server.
But I am stuck at a point. Please help me.
I don't know which portion of code I should put here for more details so I'm putting a screenshot of my error.

http://pasteboard.co/DI8vdNA.png

Thanks,
Pr0Ankit

Honey

it looks like an index error, You're probably trying to use a function which doesn't exist.

Pr0Ankit

#2
Hello Honey,

Thanks for helping me.
Actually I'm using Country Detector by Matheus . I don't know where I am making mistake but the country detector seems to be working fine. When I connect to server it says Connexao Local. My code is here
function
onScriptLoad()
{
dofile( "IPtoCountry/IPtoCountry.nut" );
secondarydb <- ConnectSQL( "IpToCountry.db" );
Load_ITC( "IPtoCountry/" ); // Loading the detector
}

Thanks,
Pr0Ankit

EK.IceFlake

Quote from: Pr0Ankit on May 22, 2015, 02:48 AMHello Honey,

Thanks for helping me.
Actually I'm using Country Detector by Matheus . I don't know where I am making mistake but the country detector seems to be working fine. When I connect to server it says Connexao Local. My code is here
function
onScriptLoad()
{
dofile( "IPtoCountry/IPtoCountry.nut" );
secondarydb <- ConnectSQL( "IpToCountry.db" );
Load_ITC( "IPtoCountry/" ); // Loading the detector
}

Thanks,
Pr0Ankit
Is there any "function Load_ITC"? Search for it if not thenyou have to put it there by looking at the detector again.

Pr0Ankit

#4
Quote from: NE.CrystalBlue on May 22, 2015, 03:45 AM
Quote from: Pr0Ankit on May 22, 2015, 02:48 AMHello Honey,

Thanks for helping me.
Actually I'm using Country Detector by Matheus . I don't know where I am making mistake but the country detector seems to be working fine. When I connect to server it says Connexao Local. My code is here
function
onScriptLoad()
{
dofile( "IPtoCountry/IPtoCountry.nut" );
secondarydb <- ConnectSQL( "IpToCountry.db" );
Load_ITC( "IPtoCountry/" ); // Loading the detector
}

Thanks,
Pr0Ankit
Is there any "function Load_ITC"? Search for it if not thenyou have to put it there by looking at the detector again.
Hi,
I solved this issue by deleting the loaditc line as i did not had any such function in my script. And what are all those warnings in my script ?
Thx ,
Pr0Ankit

Honey

Removing won't help you fix the problem. You need these functions for the system to work correctly.

function Load_ITC( path )
{
secondarydb <- ConnectSQL( path + "IpToCountry.db" );
}

function Unload_ITC()
{
    DisconnectSQL( secondarydb );
}

function IpToCountry(IP)
{
local result, query, IPsplit = split( IP, "." );
if ( !secondarydb ) return "Error on db connection";
if ( IP == "127.0.0.1" ) return "Localhost";
if ( IPsplit.len() != 4 ) return "Invalid IP";
result = QuerySQL(secondarydb, "SELECT Country FROM countrydetected WHERE ((" + IPsplit[0].tointeger() + " * 16777216) + (" + IPsplit[1].tointeger() + " * 65536) + (" + IPsplit[2].tointeger() + " * 256) + " + IPsplit[3].tointeger() + ") BETWEEN Ip_From AND Ip_to LIMIT 1");
query = GetSQLColumnData( result, 0 );
if ( !query ) query = "Unknown";
FreeSQLQuery( result );
return query;
}

Pr0Ankit

Quote from: Honey on May 22, 2015, 10:24 AMRemoving won't help you fix the problem. You need these functions for the system to work correctly.

function Load_ITC( path )
{
secondarydb <- ConnectSQL( path + "IpToCountry.db" );
}

function Unload_ITC()
{
    DisconnectSQL( secondarydb );
}

function IpToCountry(IP)
{
local result, query, IPsplit = split( IP, "." );
if ( !secondarydb ) return "Error on db connection";
if ( IP == "127.0.0.1" ) return "Localhost";
if ( IPsplit.len() != 4 ) return "Invalid IP";
result = QuerySQL(secondarydb, "SELECT Country FROM countrydetected WHERE ((" + IPsplit[0].tointeger() + " * 16777216) + (" + IPsplit[1].tointeger() + " * 65536) + (" + IPsplit[2].tointeger() + " * 256) + " + IPsplit[3].tointeger() + ") BETWEEN Ip_From AND Ip_to LIMIT 1");
query = GetSQLColumnData( result, 0 );
if ( !query ) query = "Unknown";
FreeSQLQuery( result );
return query;
}

Quote from: Honey on May 22, 2015, 10:24 AM

Hi,
Thanks again for helping. I have solved out this error by removing the line and the system is working normal. I'm sorry but I could not understand what your code meant as I am a beginner and I am choosing simple and easy snippets to start with.
And what about the warnings which i get ? Why are they causing and another warning which says no custom weapons to load though I have added M6 as weapon4 it does not works. Idk what is the problem.

Thanks and Best Regards,
Pr0Ankit

Honey

alright then,

Basically removing that line didn't fix your problem. Let's suppose your master / sensei asks you to find a box named Load_ITC. You can't find it anywhere so you return to your master and say "I was not able to find this", This happened with your server and when it says index not found so it's something mistyped or missing,  So then Your Master said " Ok nevermind" and there you go, earned nothing. That happens when you remove the lines, Put those function in your functions.nut or wherever you want to and then try this so It can successfully load it. As for the warnings I can't understand what you mean, elaborate

MatheuS

if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

Thijn

That load line did just connect to the SQLite database, something he already did in his onScriptLoad. That line is perfectly fine to remove in this case.

Pr0Ankit

Quote from: Thijn on May 22, 2015, 05:05 PMThat load line did just connect to the SQLite database, something he already did in his onScriptLoad. That line is perfectly fine to remove in this case.

Yea i think you are correct Thijn.
function onScriptLoad()
{
dofile( "IPtoCountry/IPtoCountry.nut" );
secondarydb <- ConnectSQL( "IpToCountry.db" ); <------------- SQL Connected here in this line so extra line is not needed.
}

function onPlayerJoin( player )
{
Message("[#DF0101]"+player.Name+" joined the server.");
local country = IpToCountry( player.IP );
Message( "[#F5FFFA]"+player.Name+" Country: [#06FA16]"+country+"[#F5FFFA]." ); <----- How do i change this line to say Pr0Ankit joined from Connexao Local. And why it says Connexao ? Whenver i try to add extra words inside quotation It gives error.
}

Thanks,
Pr0Ankit

Mashreq

Can you provide us your IpToCountry function? Probably "Connexao Local" stands for "local" in english since "Connexao Local" is a word in brazilian language.

Pr0Ankit

Quote from: Steam on May 23, 2015, 10:01 AMCan you provide us your IpToCountry function? Probably "Connexao Local" stands for "local" in english since "Connexao Local" is a word in brazilian language.

function onPlayerJoin( player )
{
pstats[ player.ID ] = PlayerClass( player.Name, sqliteDB );
pstats[ player.ID ].Join( player );
Message("[#DF0101]"+player.Name+" joined the server.");
local country = IpToCountry( player.IP );
Message( "[#F5FFFA]"+player.Name+" Country: [#06FA16]"+country+"[#F5FFFA]." );
if(timer_status == false)
                {
                        timer_status = true;
                        meter.Paused = false;
                        print("Timer Resumed");
                }
}

and

this one below is the file iptocountry.nut
function IpToCountry(IP)
{
local result, query, IPsplit = split( IP, "." );
if ( !secondarydb ) return "Error on db connection";
if ( IP == "127.0.0.1" ) return "Conexao Local";
if ( IPsplit.len() != 4 ) return "Invalid IP";
result = QuerySQL(secondarydb, "SELECT Country FROM countrydetected WHERE ((" + IPsplit[0].tointeger() + " * 16777216) + (" + IPsplit[1].tointeger() + " * 65536) + (" + IPsplit[2].tointeger() + " * 256) + " + IPsplit[3].tointeger() + ") BETWEEN Ip_From AND Ip_to LIMIT 1");
query = GetSQLColumnData( result, 0 );
if ( !query ) query = "Nao encontrado";
FreeSQLQuery( result );
return query;
}

I tried checking the database with a sqlite browser and i found that ip 0 was said reserved but I did not find Connexao Local or Local in any of the tables.

Thanks and Best Regards,
Pr0Ankit

Mashreq

Ankit, because you didn't checked it clearly :P
Have a look here in your IpToCountry function:

if ( IP == "127.0.0.1" ) return "Conexao Local";
Change it to
if ( IP == "127.0.0.1" ) return "Local host";

MatheuS

if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.