AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   it does not work? (https://forums.alliedmods.net/showthread.php?t=163675)

EclipseCP 08-02-2011 05:37

it does not work?
 
hi all.

I have a problem with this:

In this plugin, check that, when the time XX / XX / XX 00:00 of the day is equal to a variable

But to put hours and minutes, Buge, is not he takes the admin (as this will use it to automatically remove the admins)

PHP Code:

#include <amxmodx>
#include <amxmisc> 
#include <chatcolor> 

new szAdmin[63][40], szVencimiento[63][11], linea

public plugin_init()
{
    
register_plugin("Admin Vencimiento""1.0""ILUSION")
    
    
register_clcmd("say /vencimiento""cmdVencimiento")
    
    
check_date()
}

public 
cmdVencimiento(id)
{
    if (!(
get_user_flags(id) & ADMIN_RESERVATION))
        return 
PLUGIN_CONTINUE;
    
    new 
name[32];
    
get_user_name(idnamecharsmax(name));
    
    for (new 
0lineai++)
    {
        if (
containi(nameszAdmin[i]) != -1)
        {
            if (
szVencimiento[i][0])
                
client_print_color(idBlue"Tu administrador vence el dia: ^4%s"szVencimiento[i]);
            
            break;    
        }    
    }
    
    return 
PLUGIN_HANDLED;
}

check_date()
{
    new 
szFile[255], szLine[255];

    
get_localinfo("amxx_configsdir"szFilecharsmax(szFile));
    
formatex(szFilecharsmax(szFile), "%s/users.ini"szFile);
    
    new 
file fopen(szFile"rt");
    
linea 0;
    
    while (!
feof(file))
    {
        
szLine[0] = '^0';
        
fgets(fileszLinecharsmax(szLine));
        
trim(szLine);
        
        if (!
szLine[0] || szLine[0] == ';')
            continue;
        
        
parse(szLineszAdmin[linea], sizeof szAdminszLinecharsmax(szLine), szLinecharsmax(szLine), szLinecharsmax(szLine), szVencimiento[linea], charsmax(szVencimiento));
        
        
linea++;
    }

    
fclose(file);
    
    new 
fecha[64]
    
get_time("%d/%m/%Y %H:%M"fechacharsmax(fecha))
    
    for (new 
0lineai++)
    {
        if (
equal(fechaszVencimiento[i]))
        {
            new 
FilePossszName[32];
            
            
file fopen(szFile"rt");
            
            while (!
feof(file))
            {
                
szLine[0] = '^0';
                
fgets(fileszLinecharsmax(szLine));
                
                
FilePoss++;
                
                if (
szLine[0] == ';')
                    continue;
                
                
parse(szLineszNamecharsmax(szName));
                
                if (
equal(szNameszAdmin[i]))
                {
                    
/* Bugsy */
                    
format(szLinecharsmax(szLine), ";%s"szAdmin[i]);
                    
write_file(szFileszLineFilePoss 1);
                    break;
                    
/* Bugsy */
                
}
            }

            
fclose(file);
            
            
server_cmd("amx_reloadadmins");
            
log_amx("El admin %s fue deshabilitado ya que vencio el dia %s"szAdmin[i], szVencimiento[i]);
        }
    }



fysiks 08-02-2011 08:28

Re: it does not work?
 
The probability of equal(fecha, szVencimiento[i]) being true is nearly 0 (therefore it's a poor method to check if their admin has expired).


All times are GMT -4. The time now is 03:31.

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