daily pastebin goal
31%
SHARE
TWEET

Untitled

a guest Aug 13th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * Anti Dialog-Hider hack
  3.  *
  4.  * Copyright 2017 Tango
  5.  * Distributed under the terms of the GNU General Public License version 3.
  6.  *
  7.  * Dialog hack/Dialog hider hack allows the player to hide or show any dialog at any time.
  8.  *
  9.  * Simply include this file into every script that uses dialogs.
  10.  * Make sure this is the SECOND file included (right below #include <a_samp>) in every file.
  11.  * If you are redefining MAX_PLAYERS, you have to do so BEFORE including this file.
  12.  * Also, do NOT use DIALOGID = -1 in your script.
  13.  *
  14.  * When a player gets detected to be cheating, the PUBLIC function OnDialogHackDetected(playerid) will be called.
  15.  * Make sure you have that function defined somewhere in your script.
  16.  *
  17.  * WARNING: Because of how SAMP dialogs work - if a dialog is shown, and the server restarts and the player
  18.  * responds to the dialog AFTER the restart, he will be "DETECTED" and OnDialogHackDetected will be called.
  19.  */
  20.  
  21. #include <a_samp>
  22.  
  23. static lastDialogID[MAX_PLAYERS] = { -1, ... };  
  24.  
  25.  
  26. stock ADH_ShowPlayerDialog(playerid, dialogid, style, caption[], info[], button1[], button2[]) {
  27.   lastDialogID[playerid] = dialogid;
  28.   ShowPlayerDialog(playerid, dialogid, style, caption, info, button1, button2);
  29. }
  30.  
  31. public OnPlayerConnect(playerid) {
  32.   lastDialogID[playerid] = -1;
  33.   #if defined ADH_OnPlayerConnect // a classic "hooking construct"
  34.     return CallRemoteFunction("ADH_OnPlayerConnect", "i", playerid);
  35.   #else
  36.     return 1;
  37.   #endif  
  38. }
  39.  
  40. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  41.   if (lastDialogID[playerid] != dialogid) { // hacker detected
  42.     lastDialogID[playerid] = -1;
  43.     #if defined OnDialogHackDetected
  44.       CallRemoteFunction("OnDialogHackDetected", "i", playerid);
  45.     #endif
  46.     return 1;
  47.   } else { // no hacker detected... Continue normally...
  48.     lastDialogID[playerid] = -1;
  49.     #if defined ADH_OnDialogResponse
  50.       if (inputtext[0])
  51.         return CallRemoteFunction("ADH_OnDialogResponse", "iiiis", playerid, dialogid, response, listitem, inputtext);
  52.       else
  53.         return CallRemoteFunction("ADH_OnDialogResponse", "iiiis", playerid, dialogid, response, listitem, "\1");
  54.     #else
  55.       return 0;
  56.     #endif
  57.   }  
  58. }
  59.  
  60. // safety measures to allow compatibility with other hooks
  61. #if defined _ALS_ShowPlayerDialog // function hook
  62.   #undef ShowPlayerDialog
  63. #else
  64.   #define _ALS_ShowPlayerDialog
  65. #endif
  66.  
  67. #if defined _ALS_OnDialogResponse // callback hook
  68.   #undef OnDialogResponse
  69. #else
  70.   #define _ALS_OnDialogResponse
  71. #endif
  72.  
  73. #if defined _ALS_OnPlayerConnect // callback hook
  74.   #undef OnPlayerConnect
  75. #else
  76.   #define _ALS_OnPlayerConnect
  77. #endif
  78.  
  79. #define ShowPlayerDialog ADH_ShowPlayerDialog // function hook
  80. #define OnDialogResponse ADH_OnDialogResponse // callback hook
  81. #define OnPlayerConnect  ADH_OnPlayerConnect  // callback hook
  82.  
  83. // The following will be "forwarded" only if those functions are used somewhere in code
  84. #if defined OnDialogHackDetected
  85.   forward OnDialogHackDetected(playerid);
  86. #endif
  87. #if defined ADH_OnDialogResponse
  88.   forward ADH_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]);
  89. #endif
  90. #if defined ADH_OnPlayerConnect
  91.   forward ADH_OnPlayerConnect(playerid);
  92. #endif
RAW Paste Data
Top