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

How to organize this?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 11-13-2009 , 01:03   How to organize this?
Reply With Quote #1

Alright, well originally this thread was about arrays, fixed it I was being lame.

Now, for those advanced scripters, need your help.

I am creating a multi-forum supported "vip mod". The purpose of this mod is to cache data from your forum such as Posts, Username, Password, Group_Id.

Now, I will create a small API to manage all this. The main plugin will allow you to login using amx_login, save your info in a set_user_info. The password will be randomly encoded with an RC4 hash. You will be required to change it before even using this plugin or it will stop working..

The API will include functions such as IsUserLogedIn, GetUserPostCount, GetUserGroupId and GetUserUsername, GetPluginStatus. Now, you wont be able to grab a users password since there's complications with that.

Seeing as every board has a different way to salt and hash each password, it will require some changes per forum board so this plugin must be durable.

What features does this include? Well right now, this is mostly on the list of things to include in this plugin for safety measures and such.
  • Maximum amount of attempts per timed period (ie: 5 tries per 3 mins for your account).
  • Auto Cache per map the latest data from the forum and store it in a Trie
  • Non-Persistant connection. If there is an error in the main plugin, return that so other plugins will need to check for the main plugin's status when starting up.
  • Dynamic table prefix (ie: vbulletin_users not users table)

If you have any suggestions or concerns, please address them here. I will be happy to come up with a solution. If this is going to be done for the public, I want it done right. Currently I will be supported phpBB 3.x, latest vBulletin and Invision Power Board. I need somebody to help me come up with a way to make this as dynamic as possible so other forum boards can easily be added ect.. I want a better way to manage other plugins that are utilizing this API too, so if something fails the other plugins don't sit there failing for ever.. I'm not completely sure how to go about this. I took a look at ARP but I think that's a little too advanced for something like this.

I hope that I can eventually have my own board for this were people can take already public plugins (Hopefully the author) and post them in the VIP Mod section. After proving they work of course. This way people that aren't too savy with plugins can easily integrate this into their server and have a ton of options for their users such as

Code:
CanUseHats(id) {     if(GetUserPosts(id) < 100)     {         client_vipprint(id, "You are not currently allowed to use hats. Please gain 100 posts on the forum.");     }         return true; } GrantUserAdmin(id) {     if(GetUserGroup(id) == 5) // Asumming this is VIP Rank     {         set_user_flags(id, ADMIN_BAN);         client_vipprint(id, "Your admin is currently active.");     } }

ect.. the ides are endless for the possibilities.. Thus creating a more unified server and automating the act of purchasing admin.

Currently I have something along the lines of...
Code:
#pragma semicolon 1 #include <amxmodx> #include <amxmisc> #include <sqlx> enum _:e_PlayerData {     password[64],     salt[64],     post_count[64] }; new Trie:g_CachedUsers; new Handle:g_SqlTuple, g_Error[512]; static g_Tag[64]; new g_PTablePrefix, g_PForumType; public plugin_init() {     register_plugin("VIP Mod", "0.0.1", "Styles");         // Register all the protected cvars for the forum connection        g_PTablePrefix = register_cvar("vipmod_table_prefix", "vb_");     g_PForumType = register_cvar("vipmod_forum_type", "vb");         // Grab the sql data     new szHost[64], szUser[64], szPass[64], szDb[64];     get_cvar_string("amx_sql_host", szHost, 63);     get_cvar_string("amx_sql_user", szUser, 63);     get_cvar_string("amx_sql_pass", szPass, 63);     get_cvar_string("amx_sql_db", szDb, 63);         // Rest of the cvars, mostly random now     new szTag = register_cvar("vipmod_tag", "[VIP Mod]");     get_pcvar_string(szTag, g_Tag, charsmax(g_Tag));         // Initilize SQLx     g_SqlTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDb);     new ErrorCode, Handle:SqlConnection = SQL_Connect(g_SqlTuple, ErrorCode, g_Error, 511);         // Check for a valid connection     if(SqlConnection == Empty_Handle)     {         // Chonnection error         log_amx("%s Connection failed to %s. Error: %s occured.", g_Tag, szHost, g_Error);         set_fail_state(g_Error);     }     else     {         // Initilize Trie Array         g_CachedUsers = TrieCreate();                 // Start cacheing of user database         set_task(5.0, "BeginCahce");     } } public BeginCache() {     // Grab forum type and table prefix information     new szQuery[512], szForumType[6], szTablePrefix[12];     get_pcvar_string(g_PForumType, szForumType, 5);     get_pcvar_string(g_PTablePrefix, szTablePrefix, 11);         if(equali(szForumType, "vb"))     {         // vBulletin forum            formatex(szQuery, 511, "SELECT `%suser`.`username`, `%suser`.`password`, `%suser`.`salt`, count(*) AS `posts` FROM `%suser` LEFT JOIN `post` ON `%spost`.`userid`=`%suser`.`userid` GROUP BY `%suser`.`userid`", szTablePrefix, szTablePrefix, szTablePrefix, szTablePrefix, szTablePrefix, szTablePrefix, szTablePrefix); // 7 times     }     else if(equali(szForumType, "ipb"))     {         // Invision Power Board forum     }     else if(equali(szForumType, "phpbb"))     {         // phpBB 3.x forum type     }     else     {         // Not a valid forum type         new szError[512];         formatex(szError, charsmax(szError), "%s You did not select a valid forum type.", g_Tag);         set_fail_state(szError);     }         // Let's run the query     SQL_ThreadQuery(g_SqlTuple,"HandleCacheData",szQuery, _, _); }

Thank you

Last edited by Styles; 11-13-2009 at 02:04. Reason: Redirecting this thread..
Styles is offline
Send a message via AIM to Styles
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 11-13-2009 , 06:04   Re: How to organize this?
Reply With Quote #2

To make it look nicer and easier to change in the future if one of the board types get incompatible with your code and promote 3rd party board implementation development, you should have a main plugin and implement the functionality for each board in a separated one. Each plugin would have a BeginCache function and all those necessary and would register itself in the main plugin with a function like registerBoard("ipb","beginCache").
__________________
joaquimandrade is offline
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 11-13-2009 , 20:16   Re: How to organize this?
Reply With Quote #3

ahh great idea. I'll do that ;). Thank you
Styles is offline
Send a message via AIM to Styles
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 08:13.


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