Raised This Month: $ Target: $400
 0% 

Help Please


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Anthraxnz
Senior Member
Join Date: May 2005
Location: New Zealand
Old 03-07-2006 , 00:31   Help Please
Reply With Quote #1

can someone tell me why this doesnt work properly?

when i test it with just one person( my self ) it works because im slot #1 but when someone else is in slot #1 it doesnt work.

its suposed to connect to a SQL DB then loop through all players STEAMIDs on the server and compare then with ones located in the admins table.

if it one matches it shud print Alias Name then STEAMID followed by Real Name

ie
Player??? STEAM123 Dave

Code:
public checkAdmin(id){     if (!(get_user_flags(id)&ADMIN_KICK)){         console_print(id,"You have no access to that command")         return PLUGIN_HANDLED }             new players[32],inum, auth[32],name[32],playerid[32], playername[32]         if(!get_playersnum()){         console_print(id,"No Players Found")         return PLUGIN_HANDLED     }     get_players(players,inum)     result = dbi_query(dbc,"SELECT * FROM admins")         console_print(id,"Admins On Server")         for (new i=0;i<=dbi_num_rows(result);i++) {                     dbi_nextrow(result)         dbi_result(result,"auth",auth,31)         get_user_authid(players[i],playerid,31)         get_user_name(players[i],playername,31)         if ( equal(auth,playerid)){             dbi_result(result,"name",name,31)             console_print(id,"%s %s = %s",playername,playerid,name)         }     }     dbi_free_result(result)     return PLUGIN_HANDLED }

think its to do with the loop
__________________
Dont know how to add admins?

use my program
http://www.amxmodx.org/forums/viewto...=129092#129092

it does the work for you ... sort of
Anthraxnz is offline
Charr
Senior Member
Join Date: Jul 2005
Location: Long Island, New York, U
Old 03-07-2006 , 14:05  
Reply With Quote #2

Do the people that are trying to use it not have Kick access?
Is there an open connection to the SQL?
__________________
Charr is offline
Send a message via AIM to Charr Send a message via MSN to Charr
Anthraxnz
Senior Member
Join Date: May 2005
Location: New Zealand
Old 03-07-2006 , 15:50  
Reply With Quote #3

requried level is kick and there is a connection to sql
__________________
Dont know how to add admins?

use my program
http://www.amxmodx.org/forums/viewto...=129092#129092

it does the work for you ... sort of
Anthraxnz is offline
Kraugh
Senior Member
Join Date: Jan 2006
Location: barrington, ri
Old 03-07-2006 , 16:16  
Reply With Quote #4

right now you are mixing a player check loop and an admin check loop. you need two different loops: one that loops through all of the players, and one inside that searches all steam ids in the database and attempts to match it with the current player.

i would recommend querying the server only once and saving the admin steam ids into a variable so you don't have to use mysql over and over. it would look something like this:

Code:
#define MAX_ADMINS 32 new adminlist[MAX_ADMINS][32]; public get_adminlist() {    new admincount = 0;    // query here    while(/* this would be your result loop */) {       format(adminlist[admincount++],31,"%s",/* authid retrieved from database */);    }    return admincount; } public check_admins() {    new admincount = get_adminlist();    new players[32], num, i, j;    get_players(players, num);    for(i=0;i<num;i++) {       new authid[32];       get_user_authid(players[i],authid,31);       for(j=0;j<admincount;j++) {          if(equali(authid,adminlist[j])) {             // console print here             continue;          }       }    } }

i don't know exactly how amxx's mysql works so you'll have to work to adapt it.
__________________
"You can not restrain a fool from speaking, but nothing obliges you to listen."
Kraugh is offline
Send a message via AIM to Kraugh
Anthraxnz
Senior Member
Join Date: May 2005
Location: New Zealand
Old 03-07-2006 , 18:49  
Reply With Quote #5

ok thanks will give it a try
__________________
Dont know how to add admins?

use my program
http://www.amxmodx.org/forums/viewto...=129092#129092

it does the work for you ... sort of
Anthraxnz is offline
Anthraxnz
Senior Member
Join Date: May 2005
Location: New Zealand
Old 03-08-2006 , 19:25  
Reply With Quote #6

cant seem to figure it out can someone help?
heres the complete code

Code:
#include <amxmodx> #include <amxmisc> #include <dbi> new Sql:dbc new Result:result #define MAX_ADMINS 32 new adminlist[MAX_ADMINS][32] public plugin_init() {     register_plugin("AdminCheck","1.0","Anthrax")     register_concmd("amx_admins","checkAdmin",ADMIN_KICK," - Checks For Admins Real Name")     set_task(Float:10.0,"sql_init") } public sql_init(id){     new host[64], username[32], password[32], dbname[32], error[32]     get_cvar_string("amx_sql_host",host,64)     get_cvar_string("amx_sql_user",username,32)     get_cvar_string("amx_sql_pass",password,32)     get_cvar_string("amx_sql_db",dbname,32)     dbc = dbi_connect(host,username,password,dbname,error,32)     if (dbc == SQL_FAILED)         log_amx("[AMXX] SQL Connection Failed") } //----------------------------------------------------------------------------------------- public get_adminlist(){     new admincount = 0;     new sqlAuth[32]     new i = 1     result = dbi_query(dbc,"SELECT auth FROM admins")     while( i <= dbi_num_rows(result)) {         format(adminlist[admincount++],31,"%s",sqlAuth);         i++     }     return admincount; } //----------------------------------------------------------------------------------------- public checkAdmin(id){     if (!(get_user_flags(id)&ADMIN_KICK)){         console_print(id,"You have no access to that command")         return PLUGIN_HANDLED     }     if (!get_playersnum()){         console_print(id,"No Players Found")         return PLUGIN_HANDLED     }     new admincount = get_adminlist()     new players[32], num, i, j     new name[32]     get_players(players, num)         for(i=0;i<num;i++) {         new authid[32]         get_user_authid(players[i],authid,31)                       for(j=0;j<admincount;j++) {             if(equali(authid,adminlist[j])) {                 dbi_result(result,"name",name,32)                 console_print(id,"%s",name)                 continue;             }         }     }         dbi_free_result(result)     return PLUGIN_HANDLED }
__________________
Dont know how to add admins?

use my program
http://www.amxmodx.org/forums/viewto...=129092#129092

it does the work for you ... sort of
Anthraxnz is offline
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 03-08-2006 , 19:34  
Reply With Quote #7

Code:
dbc = dbi_connect(host,username,password,dbname,error,32)
to
Code:
dbc = dbi_connect(host,username,password,dbname,error,31)

just something that I noticed off the back. Another thing I noticed is the thread title is "Help Please". Next time please name is something related to what you need help with. In example: "SQL Query Help"
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
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 20:16.


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