Raised This Month: $51 Target: $400
 12% 

Require module sqlite


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 11-24-2014 , 14:36   Require module sqlite
Reply With Quote #1

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.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 11-24-2014 , 14:47   Re: Require module sqlite
Reply With Quote #2

Try
#pragma reqclass sqlite
or
#pragma defclasslib sqlite
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 11-24-2014 , 16:08   Re: Require module sqlite
Reply With Quote #3

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.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness

Last edited by GuskiS; 11-24-2014 at 16:12.
GuskiS is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-25-2014 , 10:23   Re: Require module sqlite
Reply With Quote #4

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.
__________________

Last edited by Arkshine; 11-25-2014 at 10:45.
Arkshine is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-25-2014 , 12:09   Re: Require module sqlite
Reply With Quote #5

And to load only sqlite, you can do that:

#pragma defclasslib sqlx sqlite
#include <sqlx>
__________________

Last edited by Arkshine; 11-25-2014 at 12:09.
Arkshine is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 11-26-2014 , 15:26   Re: Require module sqlite
Reply With Quote #6

So it isn't possible to require both of them via plugin?
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-26-2014 , 16:38   Re: Require module sqlite
Reply With Quote #7

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".
__________________

Last edited by Arkshine; 11-26-2014 at 17:43.
Arkshine is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 11-27-2014 , 18:12   Re: Require module sqlite
Reply With Quote #8

Sweet, works nicely. I think this should be somewhere stated in include file so that other would see it, too if they use sqlite
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:59.


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