Raised This Month: $51 Target: $400
 12% 

Bug Reporting Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 08-29-2012 , 20:45   Bug Reporting Plugin
Reply With Quote #1

Being under 50 lines i didn't see this fit as a "release" plugin. But i thought some might find it useful on public test servers. If not....its a good example of how to pull apart say and say_team messages and text and then print them to a log.

DESCRIPTION: This plugin gives users of a server the ability to report any sort of bugs they see to a developer with a simple command "/bugreport [bug]"

The bug then gets logged to a defined log file with the reporter's name so you can look at it later. It also helps when you're testing, you don't have to write all that stuff down, and you can keep it permanently.

Happy developing!

Here is the code all commented out as the tutorial. If you have any questions or i'm unclear, please don't be afraid to comment.
PHP Code:
/* 
    This gives users of a server the ability
    to report a bug via chat commands.
    Also includes an advertisement (toggleable)
    
    */

#include <amxmodx>

#define PLUGIN "Bug Report"
#define VERSION "1.0"
#define AUTHOR "Liverwiz"

    // This is a string that determines the file in which to log bugs
new const LogFile[] = "BugLog.log"
    
// This can be commented out to disable advertising
    // the value determines how often (in seconds) the message is displayed
#define ADVERTISE 30.0

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
        
/* these register commands with the core to catch
         when users "say" with 'y' or "team say" with 'u'  */
    
register_clcmd("say""handleSay")
    
register_clcmd("say_team""handleSay")
    
        
/* This is a preprocessor if-statement it allows
        lines to be executed while the condition is true
        In this case i checked to make sure ADVERTISE is defined
        otherwise ADVERTISE won't be found and will then have an
        error on compilation. Every #if statement must be closed
        with an #endif (much like the brackets)    
        
        The set_task sets a task to run the function "advertise"
        every ADVERTISE seconds. 0 is the id (irrelevant in this
        example, but important in many other situations. You can 
        skip paramaters in a stock function (like set_task) 
        if they have a default value. Then define
        what parameters you wish with a period (.) then the 
        parameter name = value i.e. (.flags="a") You may also
        skip parameters with underscores ( _ ) This is also quite
        common and is easier for some people to see. I prefer this
        method because you can see exactly what variables you're 
        working with. It is important to know if you go this rout
        EVERY paramater after will require this sort of definition */
#if defined ADVERTISE 
    
set_task(ADVERTISE"advertise"0, .flags="a")
#endif
}

public 
handleSay(id)
{
        
// This defines all variables we will be using later
        // sz is a Hungarian Notation prefix for "string"
        // szInput is set at 192. that is the maxlen of a chat string
    
new szInput[192], szCommand[32], szBug[192], szName[32]
    
        
/* This takes all arguemtns passed to the function and outputs
         them as a string    */
    
read_args(szInputcharsmax(szInput) )
        
// Remove quotes so there is no confusions in handling
    
remove_quotes(szInput)
    
        
/* This seperates the input into two strings a right and left
        left is szCommand and right is szBug. The string is seperated
        at the first space unless contained in quotes    */
    
strbreak(szInputszCommandcharsmax(szCommand), szBugcharsmax(szBug) )
    
        
// This checks to make sure they are using the right command
    
if(!equali(szCommand"/reportbug") && !equali(szCommand"/bugreport") )
        return 
PLUGIN_CONTINUE 
        
        
// Gets user name and stores it into szName
        /* I see a lot of peole using a hardcoded number instead
        of charsmax(szName). This is bad practice. And you will
        also find this to be an inconvenience later if you change
        the length of the string. Remember to use charsmax(string) */
    
get_user_name(idszNamecharsmax(szName) )
    
        
// Logs  it to the indentified Log File
    
log_to_file(LogFile"%s: %s"szNameszBug)
    
        
// Shows our appreciation for bug reports. 
    
client_print(idprint_chat"[AMXX] Thanks for the report! I appreciate your support!")
    
    return 
PLUGIN_HANDLED
}
    
// This prints an advertisement from the task. 0 as the id means "all clients" 
public advertise(id)
    
client_print(0print_chat"[AMXX] Notice a bug with a plugin? Type '/bugreport' with a short description and we'll get it taken care of!"
Attached Files
File Type: sma Get Plugin or Get Source (bug_report.sma - 767 views - 1.2 KB)
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 09-01-2012 at 10:56.
Liverwiz is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 08-31-2012 , 21:56   Re: Bug Reporting Plugin
Reply With Quote #2

Where's the Snippet/Tutorial?
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 09-01-2012 , 10:15   Re: Bug Reporting Plugin
Reply With Quote #3

Quote:
Originally Posted by meTaLiCroSS View Post
Where's the Snippet/Tutorial?
I'm working on it. Been trying for the past couple days, but then always my time runs out. I -hope- i'll get it up today.

EDIT: finally posted the code with all comments and descriptions. I hope this helps everyone.
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 09-01-2012 at 10:57.
Liverwiz is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 09-01-2012 , 13:10   Re: Bug Reporting Plugin
Reply With Quote #4

This isn't an utility for something, this is a plugin that should be posted on New Plugin Submissions instead here lol
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 09-01-2012 , 13:49   Re: Bug Reporting Plugin
Reply With Quote #5

Quote:
Originally Posted by Liverwiz View Post
Being under 50 lines i didn't see this fit as a "release" plugin. But i thought some might find it useful on public test servers. If not....its a good example of how to pull apart say and say_team messages and text and then print them to a log.
I've found myself answering the question "how do i get a say message and check for a command" way too many times. I wrote this as a simpler example than telling them to go look at other plugins. And because i needed a bug reporting system. If people want this to be posted in new plugin submisions i'll be happy to do that. But i just felt it a better example than plugin.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 09-13-2012 , 22:49   Re: Bug Reporting Plugin
Reply With Quote #6

Nice, my server is still in development and many players help me out reporting all the bugs.
this will prove very handy for me.
gj!
__________________

Working on:
[CSGO/CSS] Mmorpg - an extensive XP/level modulair platform
Progress: [♣♣♣♣♣♣♣|♣♣♣]
striker07 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 06:04.


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