Raised This Month: $32 Target: $400
 8% 

Help with strbreak


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LondoN
Senior Member
Join Date: Dec 2015
Location: Roman, Romania.
Old 12-28-2018 , 04:19   Help with strbreak
Reply With Quote #1

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?
__________________
LondoN is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-28-2018 , 05:19   Re: Help with strbreak
Reply With Quote #2

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

Last edited by HamletEagle; 12-28-2018 at 05:19.
HamletEagle is offline
LondoN
Senior Member
Join Date: Dec 2015
Location: Roman, Romania.
Old 12-28-2018 , 05:34   Re: Help with strbreak
Reply With Quote #3

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
__________________
LondoN is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-28-2018 , 05:55   Re: Help with strbreak
Reply With Quote #4

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.
__________________
fysiks is offline
LondoN
Senior Member
Join Date: Dec 2015
Location: Roman, Romania.
Old 12-28-2018 , 06:02   Re: Help with strbreak
Reply With Quote #5

Thanks a lot guys, since i replaced strbreak with parse it's works fine. The problem was strbreak.
__________________
LondoN is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-28-2018 , 06:18   Re: Help with strbreak
Reply With Quote #6

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.
__________________

Last edited by fysiks; 12-28-2018 at 06:18.
fysiks 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 11:36.


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