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

Simple admin system SQL


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 06-14-2012 , 12:17   Simple admin system SQL
Reply With Quote #1

Hi all, I need a simple SQL system, example:

The plugin create the table administrator and the row steamid.

And, create the bool is_admin(id)

I need this in include.

Sorry for my badly badly english.
kramesa is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-14-2012 , 12:21   Re: Simple admin system SQL
Reply With Quote #2

Use the SQL method of the current existing admin.amxx, then for is_admin() just check is_user_admin().
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 06-14-2012 , 12:31   Re: Simple admin system SQL
Reply With Quote #3

Quote:
Originally Posted by Exolent[jNr] View Post
Use the SQL method of the current existing admin.amxx, then for is_admin() just check is_user_admin().
Ok, I will try. Thanks
kramesa is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 06-14-2012 , 13:03   Re: Simple admin system SQL
Reply With Quote #4

I view the admin.sma and I try this:

Code:
#if defined _admin_included #endinput #endif #define _admin_included #include <amxmodx> #include <sqlx> new Query[512]; new Handle:gSqlTuple; plugin_cfg() {     static szHost[] = "";     static szUser[] = "";     static szPass[] = "";     static szDB[]   = "";         gSqlTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB);         set_task(2.1, "PrepareDatabase"); } PrepareDatabase() {     new Query[512];     formatex(Query, charsmax(Query), "CREATE TABLE IF NOT EXISTS admins (steamid VARCHAR(32)");         SQL_ThreadQuery(gSqlTuple, "QueryDefaultHandle", Query); } public QueryDefaultHandle(FailState, Handle:Query, Error[], ErrorCode, Data[], DataSize, Float:QueueTime) {     switch(FailState) {         case TQUERY_CONNECT_FAILED: {             set_fail_state("SQL: Connection failed.");         }         case TQUERY_QUERY_FAILED: {             log_amx("SQL: Query failed. Error: %s (%i)", Error, ErrorCode);         }     } } stock bool:is_admin(id) {     new SteamID[32];     get_user_authid(id, SteamID, charsmax(SteamID));         new Data[2];     Data[0] = id;     Data[1] = get_user_userid(id);         formatex(Query, charsmax(Query), "SELECT * FROM admins WHERE steamid = '%s'", SteamID);     SQL_ThreadQuery(gSqlTuple, "AutSteam", Query, Data, sizeof(Data)); } public AutSteam(FailState, Handle:Query, Error[], Errcode, Data[], DataSize) {     new id = Data[0], userid = Data[1];         if(!is_user_connected(id) || get_user_userid(id) != userid) return PLUGIN_HANDLED;         if(FailState == TQUERY_CONNECT_FAILED)     {         return false;     }     else if(FailState == TQUERY_QUERY_FAILED || Errcode)     {         return false;     }     else if(!SQL_MoreResults(Query))     {         return false;     }     else     {          return true;     } }

But have some errors on compile

Last edited by kramesa; 06-14-2012 at 13:03.
kramesa is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-14-2012 , 13:04   Re: Simple admin system SQL
Reply With Quote #5

You can't do it like that. Why don't you just use what already exists instead of writing a new one?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 12:46.


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