Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if defined EXTENSION_DIALOG_INCLUDED
- #endinput
- #endif
- #define EXTENSION_DIALOG_INCLUDED
- #define DIALOG: Dialog
- // -----------------------------------------------------------------------------
- // Global to store current open dialog id
- // -----------------------------------------------------------------------------
- static
- gCurrentlyOpenDialog[MAX_PLAYERS] = {cellmin, ...};
- // -----------------------------------------------------------------------------
- // OnPlayerConnect
- // -----------------------------------------------------------------------------
- public OnPlayerConnect(playerid)
- {
- gCurrentlyOpenDialog[playerid] = cellmin;
- #if defined ex_OnPlayerConnect
- ex_OnPlayerConnect(playerid);
- #endif
- return 1;
- }
- #if defined _ALS_OnPlayerConnect
- #undef OnPlayerConnect
- #else
- #define _ALS_OnPlayerConnect
- #endif
- #define OnPlayerConnect ex_OnPlayerConnect
- #if defined ex_OnPlayerConnect
- forward ex_OnPlayerConnect(playerid);
- #endif
- // -----------------------------------------------------------------------------
- // OnPlayerDisconnect
- // -----------------------------------------------------------------------------
- public OnPlayerDisconnect(playerid, reason)
- {
- gCurrentlyOpenDialog[playerid] = cellmin;
- #if defined ex_OnPlayerDisconnect
- ex_OnPlayerDisconnect(playerid, reason);
- #endif
- return 1;
- }
- #if defined _ALS_OnPlayerDisconnect
- #undef OnPlayerDisconnect
- #else
- #define _ALS_OnPlayerDisconnect
- #endif
- #define OnPlayerDisconnect ex_OnPlayerDisconnect
- #if defined ex_OnPlayerDisconnect
- forward ex_OnPlayerDisconnect(playerid, reason);
- #endif
- // -----------------------------------------------------------------------------
- // OnDialogResponse
- // -----------------------------------------------------------------------------
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- // spoof check
- if(dialogid != gCurrentlyOpenDialog[playerid] && !IsPlayerAdmin(playerid))
- return Kick(playerid);
- gCurrentlyOpenDialog[playerid] = cellmin;
- #if defined ex_OnDialogResponse
- ex_OnDialogResponse(playerid, dialogid, response, listitem, inputtext);
- #endif
- return 0;
- }
- #if defined _ALS_OnDialogResponse
- #undef OnDialogResponse
- #else
- #define _ALS_OnDialogResponse
- #endif
- #define OnDialogResponse ex_OnDialogResponse
- #if defined ex_OnDialogResponse
- forward ex_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]);
- #endif
- // -----------------------------------------------------------------------------
- // ShowPlayerDialog Hook
- // -----------------------------------------------------------------------------
- stock ex_ShowPlayerDialog(playerid, dialogid, style, caption[], info[], button1[], button2[])
- {
- gCurrentlyOpenDialog[playerid] = dialogid;
- ShowPlayerDialog(playerid, dialogid, style, caption, info, button1, button2);
- return 1;
- }
- #if defined _ALS_ShowPlayerDialog
- #undef ShowPlayerDialog
- #else
- #define _ALS_ShowPlayerDialog
- #endif
- #define ShowPlayerDialog ex_ShowPlayerDialog
- // -----------------------------------------------------------------------------
- // API Functions
- // -----------------------------------------------------------------------------
- stock IsPlayerDialogOpen(playerid, dialogid)
- return gCurrentlyOpenDialog[playerid] == dialogid;
- stock bool:IsAnyPlayerDialogOpen(playerid)
- return gCurrentlyOpenDialog[playerid] >= 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement