Vice City: Multiplayer

Community Projects => SLC's Squirrel Plugin => Bug Reports => Topic started by: EK.IceFlake on Mar 02, 2017, 06:59 PM

Title: the index 'BindPreLoad' does not exists
Post by: EK.IceFlake on Mar 02, 2017, 06:59 PM
I was trying to make a barebones script, and I got this error when trying to create a database connection on preload
[DBG] Signaling outside plug-ins to register their API
[SQMOD] Registered: Squirrel SQLite Module
[SQMOD] Registered: Squirrel MySQL Module
[DBG] Attempting to compile the specified scripts
[DBG] Compiled script: Q:\etsx\main.nut
[ERR] the index 'BindPreLoad' does not exist
[
=>Location: sqli.nut
=>Line: 1
=>Function: main
]
[INF] Traceback:
[
=> [1] sqli.nut (1) [main]
=> [2] NATIVE (-1) [dofile]
=> [3] Q:\etsx\main.nut (1) [main]
]
[INF] Locals:
[
=> [1] ARRAY [vargv] : ...
=> [1] TABLE [this] : ...
=> [3] ARRAY [vargv] : ...
=> [3] TABLE [this] : ...
]
[ERR] the index 'BindPreLoad' does not exist
[
=>Location: Q:\etsx\main.nut
=>Line: 1
=>Function: main
]
[INF] Traceback:
[
=> [1] Q:\etsx\main.nut (1) [main]
]
[INF] Locals:
[
=> [1] ARRAY [vargv] : ...
=> [1] TABLE [this] : ...
]
[FTL] Unable to execute: Q:\etsx\main.nut
[SQMOD] Unable to load the plug-in resources properly
One or more plugins failed to initialise, quitting.

[DBG] Signaling outside plug-ins to release their resources
[SQMOD] Terminating: Squirrel SQLite Module
[SQMOD] Terminating: Squirrel MySQL Module
[DBG] Clearing the entity containers
[DBG] Terminating routines an commands
[DBG] Releasing any final resources and all loaded scripts
[DBG] Signaling outside plug-ins the virtual machine is closing
[DBG] Signaling outside plug-ins to release the virtual machine
[SQMOD] Squirrel plug-in was successfully terminated

Here's the code:
SqCore.BindPreLoad(this, function(payload)
{
    print("Creating SQLite connection...");
    SQLd <- SQLite.Connection("sqli.db");
    print("OK");
});
Title: Re: the index 'BindPreLoad' does not exists
Post by: EK.IceFlake on Mar 02, 2017, 07:07 PM
Update: I'm also getting the same error on SqCore.Bind when trying to move it to ScriptLoaded
SqCore.Bind(SqEvent.ScriptLoaded, this, function()
{
    print("Creating SQLite connection...");
    SQLd <- SQLite.Connection("sqli.db");
    print("OK");
    print("Creating SQLite tables...");
    SQLd.Exec("create table if not exists [players] ([name] text not null, [salt] varchar(24) not null, [password] varchar(24) not null);");
    SQLd.Exec("create table if not exists [players_vars] ([name] text not null, [var] varchar(24) not null, [value] not null);");
    print("OK");
});

Here's my full code:
main.nut:
dofile("sqli.nut");sqli.nut:
SqCore.Bind(SqEvent.ScriptLoaded, this, function()
{
    print("Creating SQLite connection...");
    SQLd <- SQLite.Connection("sqli.db");
    print("OK");
    print("Creating SQLite tables...");
    SQLd.Exec("create table if not exists [players] ([name] text not null, [salt] varchar(24) not null, [password] varchar(24) not null);");
    SQLd.Exec("create table if not exists [players_vars] ([name] text not null, [var] varchar(24) not null, [value] not null);");
    print("OK");
});
Title: Re: the index 'BindPreLoad' does not exists
Post by: . on Mar 02, 2017, 08:07 PM
The event system was changed (http://forum.vc-mp.org/?topic=3607.msg31793#msg31793) to a more modern signals and slots design in the last update. Because I wanted to allow scripters to add their own events that can be used seamlessly with the ones provided by the plugin.

Including the load stages. I just forgot to update the main topics.

This:
SqCore.BindPreLoad(this, function(payload)
{
  // doing stuff...
});

Becomes:
SqCore.OnPreLoad().Connect(this, function() {
  // doing stuff....
});

And you can even omit the `this` parameter and it'll default to the root table automatically.

And then this:
SqCore.Bind(SqEvent.ScriptLoaded, this, function()
{
  // doing stuff...
});

Becomes:
SqCore.On().ScriptLoaded.Connect(this, function()
{
  // doing stuff...
});