AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] My remake overlays the default plugin :( (https://forums.alliedmods.net/showthread.php?t=54436)

Day 04-25-2007 15:29

[SOLVED] My remake overlays the default plugin :(
 
I needed plugin to check the player if he exists in current file. And ih he doesn't - he got kicked from the server. I need it to separated from default admin.amxx plugin.

I tried to remake admin.amxx, but my new plugin overlays the default one and my admins don't get authorized by default plugin. So they are accepted to enter the server, but don't get admin rights from users.ini :(

Can somebody help me in this issue?

I need plugin which reads line from file (XnameX XpasswordX) and if player have "setinfo _test XpasswordX" and XnameX he's got in, else - kicked. This plugin also have to check if player changed his nickname - and if XnameX and XpasswordX doesn't meets condition of file - he's got kicked.

This is my recreation:
Code:
/* AMX Mod X script. *   Admin Base Plugin * * by the AMX Mod X Development Team *  originally developed by OLO * * This file is part of AMX Mod X. * * *  This program is free software; you can redistribute it and/or modify it *  under the terms of the GNU General Public License as published by the *  Free Software Foundation; either version 2 of the License, or (at *  your option) any later version. * *  This program is distributed in the hope that it will be useful, but *  WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *  General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software Foundation, *  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *  In addition, as a special exception, the author gives permission to *  link the code of this program with the Half-Life Game Engine ("HL *  Engine") and Modified Game Libraries ("MODs") developed by Valve, *  L.L.C ("Valve"). You must obey the GNU General Public License in all *  respects for all of the code used other than the HL Engine and MODs *  from Valve. If you modify this file, you may extend this exception *  to your version of the file, but you are not obligated to do so. If *  you do not wish to do so, delete this exception statement from your *  version. */ #include <amxmodx> #include <amxmisc> #define MAX_ADMINS 64 #define ADMIN_LOOKUP    (1<<0) #define ADMIN_NORMAL    (1<<1) #define ADMIN_STEAM (1<<2) #define ADMIN_IPADDR    (1<<3) #define ADMIN_NAME      (1<<4) new g_aPassword[MAX_ADMINS][32] new g_aName[MAX_ADMINS][32] new g_aFlags[MAX_ADMINS] new g_aAccess[MAX_ADMINS] new g_aNum = 0 new g_cmdLoopback[16] public plugin_init() {     register_plugin("Test", "1.0", "Day")     register_cvar("test_mode", "2")     register_cvar("test_password_field", "_test")     register_cvar("test_default_access", "z")     format(g_cmdLoopback, 15, "amxauth%c%c%c%c", random_num('A', 'Z'), random_num('A', 'Z'), random_num('A', 'Z'), random_num('A', 'Z'))     register_clcmd(g_cmdLoopback, "ackSignal")     remove_user_flags(0, read_flags("z"))       // Remove 'user' flag from server rights     new configsDir[64]     get_configsdir(configsDir, 63)         format(configsDir, 63, "%s/test.ini", configsDir)     loadSettings(configsDir)                    // Load admins accounts } public plugin_cfg() {     new configsDir2[64]     get_configsdir(configsDir2, 63)         new len = format(configsDir2, 63, "%s/test.ini", configsDir2)     set_task(1.0, "loadSettings", 0, configsDir2, len + 1, "b") } public loadSettings(szFilename[]) {     g_aNum = 0     if (!file_exists(szFilename))         return 0     new szText[256], szFlags[32], szAccess[32]     new a, pos = 0     while (g_aNum < MAX_ADMINS && read_file(szFilename, pos++, szText, 255, a))     {         if (szText[0] == ';')             continue         if (parse(szText, g_aName[g_aNum], 31, g_aPassword[g_aNum], 31, szAccess, 31, szFlags, 31) < 2)             continue         g_aAccess[g_aNum] = read_flags(szAccess)         g_aFlags[g_aNum] = read_flags(szFlags)         ++g_aNum     }     return 1 } getAccess(id, name[], authid[], ip[], password[]) {     new index = -1     new result = 0         for (new i = 0; i < g_aNum; ++i)     {         if (g_aFlags[i] & FLAG_AUTHID)         {             if (equal(authid, g_aName[i]))             {                 index = i                 break             }         }         else if (g_aFlags[i] & FLAG_IP)         {             new c = strlen(g_aName[i])                         if (g_aName[i][c - 1] == '.')       /* check if this is not a xxx.xxx. format */             {                 if (equal(g_aName[i], ip, c))                 {                     index = i                     break                 }             }                                   /* in other case an IP must just match */             else if (equal(ip, g_aName[i]))             {                 index = i                 break             }         } else {             if (g_aFlags[i] & FLAG_TAG)             {                 if (contain(name, g_aName[i]) != -1)                 {                     index = i                     break                 }             }             else if (equal(name, g_aName[i]))             {                 index = i                 break             }         }     }     if (index != -1)     {         if (g_aFlags[index] & FLAG_NOPASS)         {             result |= 8             new sflags[32]                         get_flags(g_aAccess[index], sflags, 31)             set_user_flags(id, g_aAccess[index])         }         else if (equal(password, g_aPassword[index]))         {             result |= 12             set_user_flags(id, g_aAccess[index])                         new sflags[32]             get_flags(g_aAccess[index], sflags, 31)         } else {             result |= 1                         if (g_aFlags[index] & FLAG_KICK)             {                 result |= 2             }         }     }     else if (get_cvar_float("test_mode") == 2.0)     {         result |= 2     } else {         new defaccess[32]                 get_cvar_string("test_default_access", defaccess, 31)                 if (!strlen(defaccess))             copy(defaccess, 32, "z")                 new idefaccess = read_flags(defaccess)                 if (idefaccess)         {             result |= 8             set_user_flags(id, idefaccess)         }     }         return result } accessUser(id, name[] = "") {     remove_user_flags(id)         new userip[32], userauthid[32], password[32], passfield[32], username[32]         get_user_ip(id, userip, 31, 1)     get_user_authid(id, userauthid, 31)         if (name[0])         copy(username, 31, name)     else         get_user_name(id, username, 31)         get_cvar_string("test_password_field", passfield, 31)     get_user_info(id, passfield, password, 31)         new result = getAccess(id, username, userauthid, userip, password)         if (result & 2)     {         client_cmd(id, "%s", g_cmdLoopback)         return PLUGIN_HANDLED     }         return PLUGIN_CONTINUE } public client_infochanged(id) {     if (!is_user_connected(id) || !get_cvar_num("test_mode"))         return PLUGIN_CONTINUE     new newname[32], oldname[32]         get_user_name(id, oldname, 31)     get_user_info(id, "name", newname, 31)     if (!equal(newname, oldname))         accessUser(id, newname)     return PLUGIN_CONTINUE } public ackSignal(id) {     server_cmd("kick #%d ^"%s^"", get_user_userid(id), "You don't have an access!") } public client_authorized(id)     return get_cvar_num("test_mode") ? accessUser(id) : PLUGIN_CONTINUE public client_putinserver(id) {     if (!is_dedicated_server() && id == 1)         return get_cvar_num("test_mode") ? accessUser(id) : PLUGIN_CONTINUE         return PLUGIN_CONTINUE }

This is more request, then help... but I think this message should be here... If no, plz move it to Requests thread...

Day 04-26-2007 02:08

Re: My remake overlays the default plugin :(
 
Any help? any?

Day 04-26-2007 03:35

Re: My remake overlays the default plugin :(
 
1 Attachment(s)
Trying to make changes myself, but stuck with simple problem, which I don't understand:

Code:

//// csdo.sma
// C:\Games\HLDS\cstrike\addons\amxmodx\scripting\csdo.sma(105) : error 033: arr
ay must be indexed (variable "g_aName")
//
// 1 Error.
// Could not locate output file compiled\csdo.amx (compile failed).
//
// Compilation Time: 0,11 sec
// ----------------------------------------

That's my current code:
Code:
/* AMX Mod X script. *   Admin Base Plugin * * by the AMX Mod X Development Team *  originally developed by OLO * * This file is part of AMX Mod X. * * *  This program is free software; you can redistribute it and/or modify it *  under the terms of the GNU General Public License as published by the *  Free Software Foundation; either version 2 of the License, or (at *  your option) any later version. * *  This program is distributed in the hope that it will be useful, but *  WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *  General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software Foundation, *  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *  In addition, as a special exception, the author gives permission to *  link the code of this program with the Half-Life Game Engine ("HL *  Engine") and Modified Game Libraries ("MODs") developed by Valve, *  L.L.C ("Valve"). You must obey the GNU General Public License in all *  respects for all of the code used other than the HL Engine and MODs *  from Valve. If you modify this file, you may extend this exception *  to your version of the file, but you are not obligated to do so. If *  you do not wish to do so, delete this exception statement from your *  version. */ #include <amxmodx> #include <amxmisc> #define MAX_ADMINS 64 new g_aPassword[MAX_ADMINS][32] new g_aName[MAX_ADMINS][32] new g_aNum = 0 public plugin_init() {     register_plugin("test", "1.0", "Day")     register_cvar("test_password_field", "_test")     new configsDir[64]     get_configsdir(configsDir, 63)         format(configsDir, 63, "%s/test.ini", configsDir)     loadSettings(configsDir)                    // Load admins accounts } public plugin_cfg() {     new configsDir2[64]     get_configsdir(configsDir2, 63)         new len = format(configsDir2, 63, "%s/test.ini", configsDir2)     set_task(1.0, "loadSettings", 0, configsDir2, len + 1, "b") } public loadSettings(szFilename[]) {     g_aNum = 0     if (!file_exists(szFilename))         return 0     new szText[256]     new a, pos = 0     while (g_aNum < MAX_ADMINS && read_file(szFilename, pos++, szText, 255, a))     {         if (szText[0] == ';')             continue         if (parse(szText, g_aName[g_aNum], 31, g_aPassword[g_aNum], 31) < 2)             continue         ++g_aNum     }     return 1 } accessUser(id, name[] = "") {     new password[32], passfield[32], username[32]         if (name[0])         copy(username, 31, name)     else         get_user_name(id, username, 31)         get_cvar_string("test_password_field", passfield, 31)     get_user_info(id, passfield, password, 31)         new result = 0     g_aNum = 0     while (g_aNum < MAX_ADMINS)     {         if (g_aName[g_aNum] == username && g_aPassword[g_aNum] == password)             result = 1         ++g_aNum     }         if (result == 0)     server_cmd("kick #%d ^"%s^"", get_user_userid(id), "You don't have an access!")             return PLUGIN_CONTINUE } public client_infochanged(id) {     if (!is_user_connected(id))         return PLUGIN_CONTINUE     new newname[32], oldname[32]         get_user_name(id, oldname, 31)     get_user_info(id, "name", newname, 31)     if (!equal(newname, oldname))         accessUser(id, newname)     return PLUGIN_CONTINUE } public client_authorized(id) {     accessUser(id)     return PLUGIN_CONTINUE } public client_putinserver(id) {     if (!is_dedicated_server() && id == 1)         accessUser(id)     return PLUGIN_CONTINUE }

pRED* 04-26-2007 03:59

Re: My remake overlays the default plugin :(
 
You are trying to compare two strings using ==. you need to use the equal(string1,string2) function.

http://www.amxmodx.org/funcwiki.php?go=func&id=53

Day 04-26-2007 04:00

Re: My remake overlays the default plugin :(
 
ouch... thanks

Day 04-26-2007 04:16

Re: My remake overlays the default plugin :(
 
allright... thanks again... works very good...

One more question. How to make check by char in string? I have equal name compare now, but I want to check if part of name is in file.

Something like:
Code:
if (If_In_String(username, g_aName[g_aNum]) && equali(password, g_aPassword[g_aNum]))

Day 04-26-2007 04:26

Re: My remake overlays the default plugin :(
 
I made this myself:
Code:
if ((containi(username,g_aName[g_aNum]) != -1) && equali(password, g_aPassword[g_aNum]))

Thanks everyone... Topic solved


All times are GMT -4. The time now is 06:33.

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