View Single Post
Old 08/02/2017, 05:17 PM   #17
Lordzy
High-roller
 
Lordzy's Avatar
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,698
Reputation: 1177
Default Re: safeDialogs - Complete protection against spoofed dialog data!

safeDialogs - v1.0.3 (optional/minor update) released!

- Added a static-global array to handle huge strings, thereby freeing more heap space. If you were facing any heap space related warning after including safeDialogs earlier, it should be fixed now.
- Improved list-item filtering. There used to be a confusion for non-hex codes between curly braces in list-item string, no more now though!
- Added new function : GetPlayerDialogItem - It stores the list-item string/data into destination. Using this function, you don't have to rely on inputtext for list-type dialogs to get their string data. In cases of DIALOG_STYLE_TABLIST or DIALOG_STYLE_TABLIST_HEADERS - it stores the complete list-item data.
pawn Code:
GetPlayerDialogItem(playerid, listitem, dest[], bool:filter = false, size = sizeof(dest));

playerid - The player to obtain data from.
listitem - The listitem of which data/string has to be obtained.
dest[] - Array to store string/data.
filter = false - Whether to filter the contents in a list-item. If filter is set to true,
                   it will automatically remove color embedding and make it look like
                   how it's shown to clients / players.
                   If filter is set to false (by default it'
s false), it will show the raw data
                   which may or may not include color embedding, depending on how the
                   code is.
size = sizeof(dest) - The size of destination array.
- Fixed functions : Functions from safeDialogs can now be used under OnDialogResponse and OnDialogSpoof.
- Include initialization won't call OnPlayerConnect completely anymore, instead it only resets necessary variables. This also means that "_ALS_" hook errors upon including certain libraries along with safeDialogs, are fixed.

This is an optional update, but I'd recommend anyone using this include to update to the latest version.

-----


Output of how the whole text can be retrieved for tabbed dialogs. (The same applies for header type dialogs)

pawn Code:
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_TABLIST,
"DIALOG_STYLE_TABLIST",
"Item\t1\n\
{FF0000}Stuff\t2\n\
{FFFaf9}Other\t3"
, "Select", "Close");

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {

    if(dialogid == 1) {
   
        new
            tmpString[256];
           
        GetPlayerDialogItem(playerid, listitem, tmpString, false, sizeof(tmpString));
        //filter is false - This output can include color embedding if the script has done so.
        printf("%s", tmpString);
       
        tmpString[0] = EOS;
        GetPlayerDialogItem(playerid, listitem, tmpString, true, sizeof(tmpString));
        //filter is true - It will print the text exactly like how clients view in game.
        printf("%s", tmpString);
       
        return 1;
    }
    return 0;
}

Output: (I selected each and every list-items)
Code:
Item	1
Item	1
{FF0000}Stuff	2
Stuff	2
{FFFaf9}Other	3
Other	3
__________________
Currently inactive - I don't play at any SA-MP servers nor work on anything in PAWN for now. The projects that I've done so far in PAWN, which requires updates will be taking some time.

Last edited by Lordzy; 09/02/2017 at 01:15 AM.
Lordzy is offline   Reply With Quote