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

Authorization plugin instead of native amxx


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PlayingTalking
Junior Member
Join Date: Apr 2007
Old 04-07-2007 , 07:56   Authorization plugin instead of native amxx
Reply With Quote #1

Hi everybody!

I write a plugin to replace amxx native user authorization engine. It requests the database for user info and sets flags according to user's group.
4 now I’ve done the following:

Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <dbi>
 
 
#define PLUGIN "Auth Plugin"
#define VERSION "1.0"
#define AUTHOR "PlayingTalking"
#define dbhost "127.0.0.1"
#define dbname "xxx"
#define dbuser "xxx"
#define dbpass "xxx"
 
public plugin_init() {
     register_plugin(PLUGIN, VERSION, AUTHOR);
     register_event("ResetHUD", "hook_join_auth","be")
}
 
 
public hook_join_auth(id) {
 
          new playername[35]
          new playerpass[35]
          new playergroup 
          get_user_name(id, playername, 50) 
 
          new error[35]
 
          new Sql:dbh = dbi_connect(dbhost, dbuser, dbpass, dbname, error, 255);
 
          if (dbh == SQL_FAILED) {
                      log_amx("[PT Auth] SQL Connection Failed = %s", error)
                      return PLUGIN_HANDLED;
          }
 
          new Result:result
 
          result = dbi_query(dbh, "SELECT username, password, groupid FROM tblusers WHERE username = '%s'",  playername)            
          if (result > RESULT_NONE) {      
             if (dbi_num_rows(result)>0) {             
 
 
                      dbi_nextrow(result)
 
                      dbi_field(result, 1, playername, 31) 
                      dbi_field(result, 2, playerpass, 31)
                      playergroup=dbi_field(result, 3)
 
                      new setinfopass[32]                  
                      get_user_info(id, "_password", setinfopass, 31)               
 
                      new md5sum[34]                      
                      md5(setinfopass,md5sum)                     
 
                      if (md5sum[31] == playerpass[31]) {                             
                                  //new flags
                                  remove_user_flags(id, ADMIN_USER)
                                  switch(playergroup){
                                              case 5:         // Site Admin – Server Top Admin                                                                                                 
                                               {         
                                                          set_user_flags(id, read_flags("abcdefghijklmnopqrstu"))                                                              
                                               }
                                              case 3:         // Site Moderator – Server Admin
                                               {
                                                          set_user_flags(id, read_flags("bcdefju"))
 
                                               }
                                              case 2:         // VIP
                                               {
                                                          set_user_flags(id, read_flags("bj"))
 
 
                                               }
                                              case 1:         // User
                                               {
                                                          set_user_flags(id, read_flags("j"))                                              
                                               }
                                  }                                  
                      } else {                         
                                  server_cmd("kick #%d Wrong password for player %s. ",uid, playername)                                                                                                           
                      }                      
             }
             dbi_free_result(result)
          }                                  
          dbi_close(dbh)   
 
          return PLUGIN_HANDLED
}
Everything works fine but the plugin has 2 disadvantages:
1. The procedure of checking is called every round which is 2 often. And it starts only when a player is alive and has joined a team
2. This method disallows the slot reservation mechanism.
I’ve tried to add the following:

Code:
 
public client_connect(id)
{ 
hook_join_auth(id)
}
It work but as I funded out (imho) my function is called before amxx native auth procedures. Thus my plugin firstly sets proper flags to player and after that amxx changes them, back to "z"

This is my first plugin and everything I’ve done I've done by reading this forum. But now I couldn't fide answer for the question here:
Q1: How to call my function after amxx calls its own. Or if it s possible even disable amxx native authorization mechanism?

Maybe smb suggests an other salvation. To my mind:

1. At player connects server plugin should check his info and set flags according to group (top admin, common admin, vip, user) and flag "z" to other not registered users.
2. The same when client_infochanged
3. In future I want to disable slot reservation in my server. And therefore when an admin or vip connects full server the plugin should kick one of not registered players with worst kills/deaths coefficient. So my second question is:
Q2: how can I get players list with their kill/deaths information?
PlayingTalking is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 04-07-2007 , 17:40   Re: Authorization plugin instead of native amxx
Reply With Quote #2

try with client_putinserver(id). if that doesn't work, just disable the amxx auth. (find where amxx does it, rescript it or strip it) or just add your function to the amxx way.

get_user_kills
get_user_deaths
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
PlayingTalking
Junior Member
Join Date: Apr 2007
Old 04-08-2007 , 22:17   Re: Authorization plugin instead of native amxx
Reply With Quote #3

Thanks a lot.
  • client_putinserver(id) works fine.
  • I replaced get_user_kills to get_user_frags (I didn’t find get_user_kills in functions list)
I’ll post here my new plugin soon. If smb needs it.
PlayingTalking is offline
Old 09-17-2017, 17:41
BaD CopY
This message has been deleted by BaD CopY.
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 09-17-2017 , 18:46   Re: Authorization plugin instead of native amxx
Reply With Quote #4

Don't use userinfo for password storing. It can be stolen on other server.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
BaD CopY
Senior Member
Join Date: Oct 2014
Location: Home
Old 09-18-2017 , 15:11   Re: Authorization plugin instead of native amxx
Reply With Quote #5

Ok, I can change it whenever I want. Why server print '2345' if password is '12345' ?
BaD CopY is offline
Send a message via Yahoo to BaD CopY Send a message via Skype™ to BaD CopY
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-18-2017 , 21:13   Re: Authorization plugin instead of native amxx
Reply With Quote #6

What are you talking about? Please make a new thread for your question since your question doesn't appear to be about the original post.
__________________
fysiks 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 08:24.


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