Raised This Month: $ Target: $400
 0% 

Mistake in log system


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 06-28-2018 , 06:30   Mistake in log system
Reply With Quote #1

Hey, I made a log system for people attacking server. I will use "amx_cvar log_kontrol 1"
and everyone's commands will be logged. But not logged.

Spoiler
__________________
A plugin that is needed for every server.
PHP Code:
public client_connect(id)
{
    if(
get_user_iq(id) < 80)
    {
        
server_cmd("kick #%d 'You have kicked from the server because your IQ is not high enough'"get_user_userid(id));
    }


Last edited by PurposeLessx; 06-28-2018 at 06:31.
PurposeLessx is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-28-2018 , 21:38   Re: Mistake in log system
Reply With Quote #2

Quote:
Originally Posted by PurposeLessx View Post
But not logged.
You should probably elaborate on what exactly that means. Did you try to do any debugging yourself?
__________________
fysiks is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 06-29-2018 , 04:02   Re: Mistake in log system
Reply With Quote #3

I am explaining how this plugin works. I will use amx_log purposeless or amx_cvar log_kontrol "1"
and the commands of purposeless or each person will be seen in the
"addons/amxmodx/purpo_attack_log/%s.log" but there is a mistake and not seen
__________________
A plugin that is needed for every server.
PHP Code:
public client_connect(id)
{
    if(
get_user_iq(id) < 80)
    {
        
server_cmd("kick #%d 'You have kicked from the server because your IQ is not high enough'"get_user_userid(id));
    }

PurposeLessx is offline
Kushfield
Member
Join Date: Jan 2017
Location: Estonia
Old 06-30-2018 , 04:14   Re: Mistake in log system
Reply With Quote #4

I see 2 things wrong here, perhaps that's why:
PHP Code:
        new tarih[64];
        
get_time("%m/%d/%Y"tarihcharsmax(tarih));
        
log_to_file("addons/amxmodx/purpo_attack_log/%s.log""%s"tariharg); 
1. You're trying to use slashes in filename, which is not possible, since they are used for separating directories.
2. You're trying to format both the file name and the message in log_to_file (?), although it's possible only for the message.

Try replacing it with this:
PHP Code:
        new tarih[64];
        
get_time("addons/amxmodx/purpo_attack_log/%Y-%m-%d.log"tarihcharsmax(tarih));
        
log_to_file(tariharg); 
Kushfield is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-30-2018 , 11:35   Re: Mistake in log system
Reply With Quote #5

Quote:
Originally Posted by PurposeLessx View Post
I am explaining how this plugin works.
I wasn't asking what you are trying to do. I was asking you to explain what part isn't working. That means you need to tell us what exactly is happening when you run your plugin. Is there any errors in the logs? Does the file get created? Does it write anything to the file? etc.

Quote:
Originally Posted by Kushfield View Post
1. You're trying to use slashes in filename, which is not possible, since they are used for separating directories.
That is wrong. The function requires the full filepath relative to the root of the server. So, having slashes in there is correct for any file that is not at the root.
__________________
fysiks is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 06-30-2018 , 11:42   Re: Mistake in log system
Reply With Quote #6

Can you correct my plugin? I am not pretty sure where is mistake. I did what Kushfield say but not working.
Not logging in file.
__________________
A plugin that is needed for every server.
PHP Code:
public client_connect(id)
{
    if(
get_user_iq(id) < 80)
    {
        
server_cmd("kick #%d 'You have kicked from the server because your IQ is not high enough'"get_user_userid(id));
    }

PurposeLessx is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-30-2018 , 11:55   Re: Mistake in log system
Reply With Quote #7

Quote:
Originally Posted by PurposeLessx View Post
Can you correct my plugin?
No. This is the Scripting Help section therefore, I'm trying to help you fix your own plugin. However, you are not answering my questions so I can't really help you that much.

Since you are very inexperienced, you need to start by testing smaller parts of your code by itself. First test being able to write to a file using log_to_file() to make sure that you can write to the file. Then, once you've verified that you can successfully do that, add some more complicated parts.
__________________
fysiks is offline
Kushfield
Member
Join Date: Jan 2017
Location: Estonia
Old 06-30-2018 , 15:20   Re: Mistake in log system
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
That is wrong. The function requires the full filepath relative to the root of the server. So, having slashes in there is correct for any file that is not at the root.
That's what I was saying - slashes are for separating directories (to define the path to the file), but he was trying to use slashes in the name of the file itself, not just the path to it. Unless of course the intention was to have a log named according to current year in a directory named after the current day which is in another directory named after the current month. This, however, makes no sense, at least not in that order, and AFAIK, you'd need to separately create each directory before you can create files in it.

EDIT:
This reminds me: PurposeLessx, have you created the directory "addons/amxmodx/purpo_attack_log/" ?
Other than that, I'm afraid I'm all out of ideas, at least until you answer the questions fysiks asked you.

Last edited by Kushfield; 06-30-2018 at 15:29.
Kushfield is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-30-2018 , 15:33   Re: Mistake in log system
Reply With Quote #9

He needs to learn to debug code instead of asking "code not work" every time.


I don't think this works like that, i might be wrong
Code:
log_to_file("addons/amxmodx/purpo_attack_log/%s.log", "%s", name, arg)
__________________
stuff
maqi is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 07-01-2018 , 08:45   Re: Mistake in log system
Reply With Quote #10

I changed it but still no log anywhere.

PHP Code:
#include <amxmodx>
#include <amxmisc>

new log_kontrol;
new 
bool:g_kontrol[33];

public 
plugin_init() {
    
register_plugin("log""1.0""PurposeLess");
    
    
bind_pcvar_num(create_cvar("log_kontrol""0"), log_kontrol);
    
    
register_concmd("amx_log""admin_log"ADMIN_RCON"<nick> <[0-1]>");
}

public 
client_command(id)
{
    if(
g_kontrol[id])
    {
        new 
arg[32];
        
read_argv(1argcharsmax(arg));
        
        if(
equali(arg" ") || equali(arg"") || is_str_num(arg))
        {
            
read_args(argcharsmax(arg));
            
            if(
equali(arg" ") || equali(arg"")) return;
        }
        
        new 
name[32], tarih[64];
        
get_user_name(idnamecharsmax(name));
        
get_time("addons/amxmodx/purpo_attack_log/%Y-%m-%d.log"tarihcharsmax(tarih));
        
log_to_file(tarih"[%s] - %s"namearg);
        return;
    }

    if(
log_kontrol)
    {
        new 
arg[32];
        
read_argv(1argcharsmax(arg));
        
        if(
equali(arg" ") || equali(arg"") || is_str_num(arg))
        {
            
read_args(argcharsmax(arg));
            
            if(
equali(arg" ") || equali(arg"")) return;
        }

        new 
tarih[64];
        
get_time("addons/amxmodx/purpo_attack_log/%Y-%m-%d.log"tarihcharsmax(tarih));
        
log_to_file(tariharg);  
    }
}

public 
admin_log(idlevelcid)
{
    if(!
cmd_access(idlevelcid2))
    {
        return 
PLUGIN_HANDLED;
    }
    new 
arg[32], arg2[32];
    
read_argv(1argcharsmax(arg));
    
read_argv(2arg2charsmax(arg2));
    
    new 
player cmd_target(idarg);
    if(!
player) return PLUGIN_HANDLED;
    
    switch(
str_to_num(arg2))
    {
        case 
0: { g_kontrol[player] = false;}
        case 
1: { g_kontrol[player] = true;}
    }
    
    
console_print(id"Kontrol : %s"g_kontrol[player] ? "on":"off");
    return 
PLUGIN_HANDLED;

__________________
A plugin that is needed for every server.
PHP Code:
public client_connect(id)
{
    if(
get_user_iq(id) < 80)
    {
        
server_cmd("kick #%d 'You have kicked from the server because your IQ is not high enough'"get_user_userid(id));
    }

PurposeLessx is offline
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 05:58.


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