Problem with OnDialogResponse and (%)
#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;
    }
but I already have that in public OnDialogResponse, should I put that code before all OnDialogResponse that i hooked??

EDIT: hook OnDialogResponse is below the public OnDialogResponse...
Reply
#2

bump
Reply
#3

You probably need to post your code to get any help
Reply
#4

Quote:
Originally Posted by v1k1nG
Посмотреть сообщение
You probably need to post your code to get any help
Here is the code:

pawn Код:
// 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;
}
Reply
#5

TIP: If you don't wanna use hooks, in your main gamemode do in this way:

pawn Код:
#include "/Custom/system.pwn"
Place your callbacks in your system.pwn, then use them normally in your gamemode.

DON'T compile the system.pwn, just save it in your /gamemodes/Custom folder (or the name you choose).

Also be sure to not include normal callbacks already existent in your main script. (Such as OnPlayerDeath, OnPlayerSpawn etc. etc.)

I use this system to insert custom maps. I do like:

pawn Код:
CreateCustomMap()
{
//Code
}
then in my gm i only add: CreateCustomMap();

Useful if you have a lot of stocks and general publics/functions made by you.
Reply
#6

Yes put that
Код:
if(strfind(inputtext, "%", true) != -1)  {
        SCM(playerid, -1, "Don't use %%!");
        return 1;
    }
At first lines under OnDialogRes. Also try returning 0 instead of 1, not sure if that'll work tho. Anyways if you have crashdetect plugin you can check its log too.
Reply
#7

Or take a look at the easyDialog include and see its transform the % into a #
Reply
#8

Quote:
Originally Posted by RedGun2015
Посмотреть сообщение
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;
    }
but I already have that in public OnDialogResponse, should I put that code before all OnDialogResponse that i hooked??

EDIT: hook OnDialogResponse is below the public OnDialogResponse...
PHP код:
    for(new 0strlen(inputtext); l++)
    {
        if(
inputtext[i] == '%') { the rest of the code here }
    } 
EDIT:
Or you can just replace it instead of sending a client message.
PHP код:
    for(new 0strlen(inputtext); l++)
    {
        if(
inputtext[i] == '%')  inputtext[i] = '#';
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)