AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Require module sqlite (https://forums.alliedmods.net/showthread.php?t=252056)

GuskiS 11-24-2014 14:36

Require module sqlite
 
How do you require module sqlite? I know there that if you include something it automatically loads module, but why isn't working for sqlite? It gives me error(when Sqlite isn't enabled in modules) that I can't connect to DB. When I enable it in modules.ini it works fine.

YamiKaitou 11-24-2014 14:47

Re: Require module sqlite
 
Try
#pragma reqclass sqlite
or
#pragma defclasslib sqlite

GuskiS 11-24-2014 16:08

Re: Require module sqlite
 
With #pragma reqclass sqlite I get this:
Quote:

[AMXX] Plugin "ttt_antiretry_system.amxx" failed to load: Module/Library Class "sqlite" required for plugin. Check modules.ini.
Which means I have to include it either way.

With #pragma defclasslib sqlite I can't compile:
Quote:

error 045: too many function arguments
EDIT: After using #pragma reqclass sqlite and enabling sqlite module, it still gives that error.

Arkshine 11-25-2014 10:23

Re: Require module sqlite
 
sqlite is a special case. Both mysql and sqlite uses "dbi" as library name, to keep compatibility with old natives as well.
They share also the same natives names and basically the same base.

Because of you can choose dynamically the driver with SQL_SetAffinity(), if you plan to use both (you have "mysql" and "sqlite" available, it's possible to create another driver), you need to manually enable them in modules.ini. So with both loaded, you can switch affinity anytime.

If you need just mysql, you have nothing to do because it will load automatically mysql module by default when you include sqlx.inc.

Arkshine 11-25-2014 12:09

Re: Require module sqlite
 
And to load only sqlite, you can do that:

#pragma defclasslib sqlx sqlite
#include <sqlx>

GuskiS 11-26-2014 15:26

Re: Require module sqlite
 
So it isn't possible to require both of them via plugin?

Arkshine 11-26-2014 16:38

Re: Require module sqlite
 
This looks like this works for me this:

Code:

#include "sqlx"
#pragma defclasslib sqlite sqlite

What it matters is to use a different class name for the first param. You could use anything except "sqlx".
When you use "defclasslib", it's basically saved in a list and amxx will try to load module named with second param, here "sqlite".

GuskiS 11-27-2014 18:12

Re: Require module sqlite
 
Sweet, works nicely. I think this should be somewhere stated in include file so that other would see it, too if they use sqlite :)


All times are GMT -4. The time now is 17:41.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.