if(strfind(inputtext, "%", true) != -1) {
SCM(playerid, -1, "Don't use %%!");
return 1;
}
// in main gamemode
// gamemode.pwn
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(strfind(inputtext, "%", true) != -1) {
SCM(playerid, -1, "Don't use %%!");
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, "Invalid characthers", "Write without restricted characthers", "Continue", "Exit");
return 1;
}
return 1;
}
// in reports include:
// reports.inc
YCMD:reports(playerid, params[], help)
{
ShowPlayerDialog(playerid, DIALOG_REPORT_ID, DIALOG_STYLE_LIST, "Choose", "Report with message\nOther", "Select", "Exit");
return 1;
}
hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_REPORT_ID) {
ShowPlayerDialog(playerid, DIALOG_REPORT_ID2, DIALOG_STYLE_INPUT, "Write", "Report message:", "Send", "Cancel");
}
if(dialogid == DIALOG_REPORT_ID2)
{
format(Report[playerid][reportText], 200, "%s", inputtext);
SCM(playerid, -1, "Report subbmited!");
format(gString, sizeof gString, "%s [%d] sended a report with message: %s", GetName(playerid), playerid, inputtext);
foreach(new i : Admins) SendClientMessage(i, COLOR_RED, gString);
}
return 1;
}
#include "/Custom/system.pwn"
CreateCustomMap()
{
//Code
}
if(strfind(inputtext, "%", true) != -1) {
SCM(playerid, -1, "Don't use %%!");
return 1;
}
|
So, all my gamemode (75%) is modular, every system (almost every system) has his include.
The problem is with hook. I have a report system (/report - > then I show a dialog and then he need to select 'Report with message') Then when he write '%s' in the dialog, the server crash (I know i can do that: Код:
if(strfind(inputtext, "%", true) != -1) {
SCM(playerid, -1, "Don't use %%!");
return 1;
}
EDIT: hook OnDialogResponse is below the public OnDialogResponse... |
for(new i = 0, l = strlen(inputtext); i < l; i ++)
{
if(inputtext[i] == '%') { the rest of the code here }
}
for(new i = 0, l = strlen(inputtext); i < l; i ++)
{
if(inputtext[i] == '%') inputtext[i] = '#';
}