AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Does not load the vips are connected (https://forums.alliedmods.net/showthread.php?t=321767)

Fuck For Fun 02-28-2020 09:32

Does not load the vips are connected
 
I'm trying to test that as soon as PLAYER connects to the server it will get/set FLAGS and then print/show up on LOG AMX but for some reason it doesn't work properly

Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

// Flags
#define FLAG_A (1<<0)
#define FLAG_B (1<<1)
#define FLAG_C (1<<2)
#define FLAG_D (1<<3)
#define FLAG_E (1<<4)
#define FLAG_K (1<<10)

enum _:DATA_PREM {
        auth[50],
        password[50],
        accessflags,
        flags
};

new amx_password_field_string[32];
new g_iUserFlags[MAX_PLAYERS + 1];
new g_aPremium[DATA_PREM];
new Array:g_aDataPremiums;

public plugin_init() {
        register_plugin(PLUGIN, VERSION, AUTHOR)
       
        get_cvar_string("amx_password_field", amx_password_field_string, charsmax(amx_password_field_string));
}

public client_putinserver(id) {
        set_flags(id);
}

public plugin_cfg() {
        reload_vips();
}
       
public set_flags(id) {
        static szAuthId[31], szIp[31], szName[32], szPassword[30];
        get_user_authid(id, szAuthId, charsmax(szAuthId));
        get_user_ip(id, szIp, charsmax(szIp), 1);
        get_user_name(id, szName, charsmax(szName));
        get_user_info(id, amx_password_field_string, szPassword, charsmax(szPassword));
       
        g_iUserFlags[id] = 0
        for(new i; i < ArraySize(g_aDataPremiums); i++) {
                ArrayGetArray(g_aDataPremiums, i, g_aPremium);
               
                if(g_aPremium[flags] & FLAG_D)
                {
                        if(equal(szIp, g_aPremium[auth]))
                        {
                                if(~g_aPremium[flags] & FLAG_E)
                                {
                                        if(equal(szPassword, g_aPremium[password]))
                                                g_iUserFlags[id] = g_aPremium[accessflags];
                                        else if(g_aPremium[flags] & FLAG_A) {
                                                server_cmd("kick #%d ^"Ivalid password!^"", get_user_userid(id));
                                                break;
                                        }
                                }
                                else
                                        g_iUserFlags[id] = g_aPremium[accessflags];
                               
                                log_amx("%s become Premium. (SteamID: ^"%s^") (IP: ^"%s^") (Flags: ^"%s^")", szName, szAuthId, szIp, get_flags_string(g_aPremium[accessflags]));
                                break;
                        }
                }
                else if(g_aPremium[flags] & FLAG_C)
                {
                        if(equal(szAuthId, g_aPremium[auth]))
                        {
                                if(~g_aPremium[flags] & FLAG_E)
                                {
                                        if(equal(szPassword, g_aPremium[password]))
                                                g_iUserFlags[id] = g_aPremium[accessflags];
                                        else if(g_aPremium[flags] & FLAG_A) {
                                                server_cmd("kick #%d ^"Ivalid password!^"", get_user_userid(id));
                                                break;
                                        }
                                }
                                else
                                        g_iUserFlags[id] = g_aPremium[accessflags];
                               
                                log_amx("%s become Premium. (SteamID: ^"%s^") (IP: ^"%s^") (Flags: ^"%s^")", szName, szAuthId, szIp, get_flags_string(g_aPremium[accessflags]));
                                break;
                        }
                }
                else
                {
                        if(g_aPremium[flags] & FLAG_K) {
                                if((g_aPremium[flags] & FLAG_B && contain(szName, g_aPremium[auth]) != -1) || equal(szName, g_aPremium[auth]))
                                {
                                        if(~g_aPremium[flags] & FLAG_E)
                                        {
                                                if(equal(szPassword, g_aPremium[password]))
                                                        g_iUserFlags[id] = g_aPremium[accessflags];
                                                else if(g_aPremium[flags] & FLAG_A)
                                                {
                                                        server_cmd("kick #%d ^"Ivalid password!^"", get_user_userid(id));
                                                        break;
                                                }
                                        }
                                        else
                                                g_iUserFlags[id] = g_aPremium[accessflags];
                                       
                                        log_amx("%s become Premium. (SteamID: ^"%s^") (IP: ^"%s^") (Flags: ^"%s^")", szName, szAuthId, szIp, get_flags_string(g_aPremium[accessflags]));
                                        break;
                                }
                        }
                        else
                        {
                                if((g_aPremium[flags] & FLAG_B && containi(szName, g_aPremium[auth]) != -1) || equali(szName, g_aPremium[auth]))
                                {
                                        if(~g_aPremium[flags] & FLAG_E)
                                        {
                                                if(equal(szPassword, g_aPremium[password]))
                                                        g_iUserFlags[id] = g_aPremium[accessflags];
                                                else if(g_aPremium[flags] & FLAG_A) {
                                                        server_cmd("kick #%d ^"Ivalid password!^"", get_user_userid(id));
                                                        break;
                                                }
                                        }
                                        else
                                                g_iUserFlags[id] = g_aPremium[accessflags];
                                       
                                        log_amx("%s become Premium. (SteamID: ^"%s^") (IP: ^"%s^") (Flags: ^"%s^")", szName, szAuthId, szIp, get_flags_string(g_aPremium[accessflags]));
                                        break;
                                }
                        }
                }
        }
        return 1;
}

public reload_vips() {
        new szBuffer[256], szArg[2][8], iFile = fopen("addons/amxmodx/configs/premium.ini", "a+");
        if(!iFile)
                return set_fail_state("File ^"addons/amxmodx/configs/premium.ini^" not found");
       
        if(g_aDataPremiums)
                ArrayDestroy(g_aDataPremiums);
        g_aDataPremiums = ArrayCreate(DATA_PREM);
       
        while(!feof(iFile)) {
                fgets(iFile, szBuffer, charsmax(szBuffer));
                trim(szBuffer);
                if(!szBuffer[0] || szBuffer[0] == ';')
                        continue;
               
                if(parse(szBuffer,
                        g_aPremium[auth], charsmax(g_aPremium[auth]),
                        g_aPremium[password], charsmax(g_aPremium[password]),
                        szArg[0], charsmax(szArg[]),
                        szArg[1], charsmax(szArg[])
                ))
                        continue;
                       
                g_aPremium[accessflags] = read_flags(szArg[0]);
                g_aPremium[flags] = read_flags(szArg[1]);
        }
        return 1;
}

stock get_flags_string(iFlags) {
        new szBuffer[16];
        get_flags(iFlags, szBuffer, charsmax(szBuffer));
        return szBuffer;
}

Quote:

after someone here explains to me the problem I would love to explain to me how I can define that I can give by command and not by anyone who comes in server flags

Bugsy 02-28-2020 12:08

Re: Does not load the vips are connected
 
Before I look further, your g_aDataPremiums array is empty and you attempt to pull data from it
Code:
new Array:g_aDataPremiums;
public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         get_cvar_string("amx_password_field", amx_password_field_string, charsmax(amx_password_field_string)); } public client_putinserver(id) {     set_flags(id); }     public set_flags(id) {     static szAuthId[31], szIp[31], szName[32], szPassword[30];     get_user_authid(id, szAuthId, charsmax(szAuthId));     get_user_ip(id, szIp, charsmax(szIp), 1);     get_user_name(id, szName, charsmax(szName));     get_user_info(id, amx_password_field_string, szPassword, charsmax(szPassword));         g_iUserFlags[id] = 0
    for(new i; i < ArraySize(g_aDataPremiums); i++) {
        ArrayGetArray(g_aDataPremiums, i, g_aPremium);

Fuck For Fun 02-28-2020 12:31

Re: Does not load the vips are connected
 
Quote:

Originally Posted by Bugsy (Post 2685303)
Before I look further, your g_aDataPremiums array is empty and you attempt to pull data from it
Code:
new Array:g_aDataPremiums;
public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         get_cvar_string("amx_password_field", amx_password_field_string, charsmax(amx_password_field_string)); } public client_putinserver(id) {     set_flags(id); }     public set_flags(id) {     static szAuthId[31], szIp[31], szName[32], szPassword[30];     get_user_authid(id, szAuthId, charsmax(szAuthId));     get_user_ip(id, szIp, charsmax(szIp), 1);     get_user_name(id, szName, charsmax(szName));     get_user_info(id, amx_password_field_string, szPassword, charsmax(szPassword));         g_iUserFlags[id] = 0
    for(new i; i < ArraySize(g_aDataPremiums); i++) {
        ArrayGetArray(g_aDataPremiums, i, g_aPremium);

PHP Code:

public reload_vips() {
    new 
szBuffer[256], szArg[2][8], iFile fopen("addons/amxmodx/configs/premium.ini""a+");
    if(!
iFile
        return 
set_fail_state("File ^"addons/amxmodx/configs/premium.ini^" not found");
    
    if(
g_aDataPremiums
        
ArrayDestroy(g_aDataPremiums);
    
g_aDataPremiums ArrayCreate(DATA_PREM);
    
    while(!
feof(iFile)) {
        
fgets(iFileszBuffercharsmax(szBuffer));
        
trim(szBuffer);
        if(!
szBuffer[0] || szBuffer[0] == ';')
            continue;
        
        if(
parse(szBuffer,
            
g_aPremium[auth], charsmax(g_aPremium[auth]),
            
g_aPremium[password], charsmax(g_aPremium[password]),
            
szArg[0], charsmax(szArg[]),
            
szArg[1], charsmax(szArg[])
        ))
            continue;
            
        
g_aPremium[accessflags] = read_flags(szArg[0]);
        
g_aPremium[flags] = read_flags(szArg[1]);
    }
    return 
1;


Yes i was working on it at the time and did not know if i did it right so now i have edited and added to CODE

Bugsy 02-28-2020 12:35

Re: Does not load the vips are connected
 
ReloadVIP's is never called.

Fuck For Fun 02-28-2020 12:50

Re: Does not load the vips are connected
 
Quote:

Originally Posted by Bugsy (Post 2685307)
ReloadVIP's is never called.

Ok so here I am trying to create a command that I can give access by command, and I did that someone coming in would bring it SETFLAGS and load CFG

fysiks 02-28-2020 20:01

Re: Does not load the vips are connected
 
Quote:

Originally Posted by Fuck For Fun (Post 2685309)
Ok so here I am trying to create a command that I can give access by command, and I did that someone coming in would bring it SETFLAGS and load CFG

What?? Do you still have an issue or did you figure it out?

Fuck For Fun 02-29-2020 10:54

Re: Does not load the vips are connected
 
Quote:

Originally Posted by fysiks (Post 2685336)
What?? Do you still have an issue or did you figure it out?

I got it, just trying to figure something out for myself


All times are GMT -4. The time now is 18:05.

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