AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with strbreak (https://forums.alliedmods.net/showthread.php?t=313095)

LondoN 12-28-2018 04:19

Help with strbreak
 
Code:

#include < amxmodx >
#include < amxmisc >

#define PLUGIN        "Report System"
#define VERSION        "1.0"
#define AUTHOR        "LondoN eXtream"

public plugin_init ( )
{
        register_plugin ( PLUGIN, VERSION, AUTHOR );

        register_clcmd ( "say", "Func_ChatCMD" );
        register_clcmd ( "say_team", "Func_ChatCMD" );

        set_task ( random_float ( 47.5, 126.5 ), "ShowInfo", .flags="b" );
}

public ShowInfo ( )        Print ( 0, "^x04[Zombie OutStanding]^x01 Scrie^x03 /report <nume> <motiv>^x01 pentru a raporta un jucator care profita de server!" );

public Func_ChatCMD ( Player )
{
        new ChatSays [ 256 ], User [ 32 ], Reason [ 32 ];
        read_args ( ChatSays, charsmax ( ChatSays ) );
        remove_quotes ( ChatSays );

        strbreak ( ChatSays, User, charsmax ( User ), Reason, charsmax ( Reason ) );

        if ( equal ( ChatSays, "/report" ) )
        {
                new Configs [ 128 ], Date [ 16 ];
                get_configsdir ( Configs, charsmax ( Configs ) );
                get_time ( "%d-%m", Date, charsmax ( Date ) );
                formatex ( Configs, charsmax ( Configs ), "%s/reports/reported-%s", Configs, Date );

                new Target = cmd_target ( Player, User, 8 );

                if  ( !Target )
                        return;

                new Name [ 32 ], IP [ 32 ], szLine [ 258 ];
                get_user_name ( Target, Name, charsmax ( Name ) );
                get_user_ip ( Target, IP, charsmax ( IP ), 1 );
       
                formatex ( szLine, charsmax ( szLine ), "Jucatorul %s [IP: %s] a fost raportat pentru %s", Name, IP, Reason );
                write_file ( Configs, szLine );

                Print ( Player, "^x04[Zombie OutStanding]^x01 Iti multumim pentru raportul facut. Acesta va fi analizat in cel mai scurt timp" );
        }
}

stock Print(const id, const input[], any:...) {
        new count = 1, players[32];
        static msg[191];
        vformat(msg, 190, input, 3);
       
        if(id) players[0] = id;
        else get_players(players, count, "ch"); {
                for(new i = 0; i < count; i++) {
                        if(is_user_connected(players[i])) {
                                message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
                                write_byte(players[i]);
                                write_string(msg);
                                message_end();
                        }
                }
        }
}

i've maked a simple report sistem.
command must be /report <user> <reason> then write the file from reports folder.
but doesn't work, i don't know why...if i strbreak with 3 args can't compile.
any ideas?

HamletEagle 12-28-2018 05:19

Re: Help with strbreak
 
Debug your code, add messages to see where the logic breaks(for example before/inside if checks, in loops, etc).

LondoN 12-28-2018 05:34

Re: Help with strbreak
 
i've debugged the code, but no information provided

Code:

Connection to Steam servers successful.
  VAC secure mode is activated.
LondoN eXtream : /report london test


fysiks 12-28-2018 05:55

Re: Help with strbreak
 
It does not appear that you have attempted to debug the code as Hamlet has suggested. If you have access to the server console, you can add server_print() functions to print out various values/strings to see what the variable actually contain. This will allow you to see why conditions are not being met.

More specifically, you are not using strbreak() properly. I'd actually suggest using parse() in this context instead.

LondoN 12-28-2018 06:02

Re: Help with strbreak
 
Thanks a lot guys, since i replaced strbreak with parse it's works fine. The problem was strbreak.

fysiks 12-28-2018 06:18

Re: Help with strbreak
 
But, do you understand why? Also do you understand what we are saying about debugging your code? Because originally it was apparent you didn't understand what Hamlet was saying. If you learn how to do some basic debugging as described by myself and Hamlet, you'll be able to solve more of your problems on your own.


All times are GMT -4. The time now is 07:30.

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