AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Easiest way..? (https://forums.alliedmods.net/showthread.php?t=28679)

Feren6 05-20-2006 09:01

Easiest way..?
 
What is the easiest way to search a file for steamID on connect and kick them if they arent on the list?

Hawk552 05-20-2006 09:37

Untested, and I've never used the new file natives before.

Code:
#include <amxmodx> #include <amxmisc> #define MAX_USERS 50 new g_szFileLocation[128] new g_szFileName[] = "allowed_users.ini" new g_szUsers[MAX_USERS][36] public plugin_init() {     register_plugin("File Search","1.0","Hawk552")         fnLoadFile     fnLoadUsers } public client_authorized(id) {     new szAuthid[36]     get_user_authid(id,szAuthid,35)         for(new iCount = 0;iCount < MAX_USERS;iCount++)         if(equali(szAuthid,g_szUsers[iCount]))             return PLUGIN_CONTINUE         server_cmd("kick #%d",get_user_userid(id))         return PLUGIN_CONTINUE } fnLoadFile() {     new szConfigsdir[64]     get_configsdir(szConfigsdir,63)         format(g_szFileLocation,127,"%s/%s",szConfigsdir,g_szFileName) } fnLoadUsers() {     new iFile = fopen(g_szFileLocation,"rt"), iNum     while(!feof(iFile))     {         if(iNum > MAX_USERS - 1)             break                     fgets(iFile,g_szUsers[iNum],35)         replace(g_szUsers[iNum++],35,"^n","")     } }

Feren6 05-20-2006 10:53

TY, but where does it call client_authorized? How does it know to execute it? (i'm new to this)


All times are GMT -4. The time now is 16:21.

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