add /feedback in its own module

This commit is contained in:
Lorenc Pekaj 2019-01-01 18:05:12 +11:00
parent 2610dd9c19
commit 99f6370bd1
3 changed files with 39 additions and 28 deletions

View File

@ -12,4 +12,5 @@
#include "irresistible\cnr\commands\cmd_changes.pwn" #include "irresistible\cnr\commands\cmd_changes.pwn"
#include "irresistible\cnr\commands\cmd_twitter.pwn" #include "irresistible\cnr\commands\cmd_twitter.pwn"
#include "irresistible\cnr\commands\cmd_highscores.pwn" #include "irresistible\cnr\commands\cmd_highscores.pwn"
#include "irresistible\cnr\commands\cmd_nametags.pwn" #include "irresistible\cnr\commands\cmd_nametags.pwn"
#include "irresistible\cnr\commands\cmd_feedback.pwn"

View File

@ -0,0 +1,37 @@
/*
* Irresistible Gaming (c) 2018
* Developed by Lorenc
* Module: cnr\commands\cmd_feedback.pwn
* Purpose: create /feedback (or /suggest) about the server
*/
/* ** Includes ** */
#include < YSI\y_hooks >
/* ** Commands ** */
CMD:suggest( playerid, params[ ] ) return cmd_feedback( playerid, params );
CMD:feedback( playerid, params[ ] )
{
return ShowPlayerDialog( playerid, DIALOG_FEEDBACK, DIALOG_STYLE_INPUT, ""COL_GOLD"Server Feedback", ""COL_WHITE"Let us know how you think we can make the server better to play! Impactful feedback is rewarded.\n\n Be as serious and straight forward as you wish. You can rant if you need to. Be impactful.", "Submit", "Close" );
}
/* ** Hooks ** */
hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
{
if ( ( dialogid == DIALOG_FEEDBACK ) && response )
{
if ( ! ( 10 < strlen( inputtext ) <= 512 ) )
{
SendError( playerid, "Your feedback must be between 10 and 512 characters long." );
return ShowPlayerDialog( playerid, DIALOG_FEEDBACK, DIALOG_STYLE_INPUT, ""COL_GOLD"Server Feedback", ""COL_WHITE"Let us know how you think we can make the server better to play! Impactful feedback is rewarded.\n\n Be as serious and straight forward as you wish. You can rant if you need to. Be impactful.\n\n"COL_RED"Your feedback must be between 10 and 512 characters long.", "Submit", "Close" );
}
// insert into database
mysql_format( dbHandle, szLargeString, sizeof( szLargeString ), "INSERT INTO `FEEDBACK` (`USER_ID`, `FEEDBACK`) VALUES (%d, '%e')", p_AccountID[ playerid ], inputtext );
mysql_single_query( szLargeString );
format( szLargeString, sizeof( szLargeString ), ""COL_GOLD"Thank you for your feedback!"COL_WHITE" If it can make a positive impact on the server then you will be rewarded.\n\nYou can speak as freely as you want. Be vulgar, serious if you need to. It's okay as long as it's constructive.\n\nHere is what you have submitted!\n\n"COL_GREY"%s", szFeedback );
return ShowPlayerDialog( playerid, DIALOG_NULL, DIALOG_STYLE_MSGBOX, ""COL_GOLD"Server Feedback", szLargeString, "Close", "" );
}
return 1;
}

View File

@ -2194,12 +2194,6 @@ CMD:changename( playerid, params[ ] ) {
return 1; return 1;
} }
CMD:suggest( playerid, params[ ] ) return cmd_feedback( playerid, params );
CMD:feedback( playerid, params[ ] )
{
return ShowPlayerDialog( playerid, DIALOG_FEEDBACK, DIALOG_STYLE_INPUT, ""COL_GOLD"Server Feedback", ""COL_WHITE"Let us know how you think we can make the server better to play! Impactful feedback is rewarded.\n\n Be as serious and straight forward as you wish. You can rant if you need to. Be impactful.", "Submit", "Close" );
}
CMD:request( playerid, params[ ] ) CMD:request( playerid, params[ ] )
{ {
/* ** Anti Spammy Commands ** */ /* ** Anti Spammy Commands ** */
@ -7095,27 +7089,6 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
} }
} }
} }
if ( ( dialogid == DIALOG_FEEDBACK ) && response )
{
if ( ! ( 10 < strlen( inputtext ) <= 512 ) )
{
SendError( playerid, "Your feedback must be between 10 and 512 characters long." );
return ShowPlayerDialog( playerid, DIALOG_FEEDBACK, DIALOG_STYLE_INPUT, ""COL_GOLD"Server Feedback", ""COL_WHITE"Let us know how you think we can make the server better to play! Impactful feedback is rewarded.\n\n Be as serious and straight forward as you wish. You can rant if you need to. Be impactful.\n\n"COL_RED"Your feedback must be between 10 and 512 characters long.", "Submit", "Close" );
}
new
szFeedback[ 512 ];
// escape feedback
mysql_real_escape_string( inputtext, szFeedback );
// insert into database
format( szLargeString, sizeof( szLargeString ), "INSERT INTO `FEEDBACK` (`USER_ID`, `FEEDBACK`) VALUES (%d, '%s')", p_AccountID[ playerid ], szFeedback );
mysql_single_query( szLargeString );
format( szLargeString, sizeof( szLargeString ), ""COL_GOLD"Thank you for your feedback!"COL_WHITE" If it can make a positive impact on the server then you will be rewarded.\n\nYou can speak as freely as you want. Be vulgar, serious if you need to. It's okay as long as it's constructive.\n\nHere is what you have submitted!\n\n"COL_GREY"%s", szFeedback );
return ShowPlayerDialog( playerid, DIALOG_NULL, DIALOG_STYLE_MSGBOX, ""COL_GOLD"Server Feedback", szLargeString, "Close", "" );
}
if ( dialogid == DIALOG_AIRPORT && response ) if ( dialogid == DIALOG_AIRPORT && response )
{ {
static const static const