Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Dynamic Dialogs BETA (Simple version)
- *
- * (c) Copyright 2013, GameMan aka Lemonadio aka MeowCola
- *
- */
- /* NATIVES for "Pawno"
- native ClearDialogListItems(playerid);
- native AddDialogListItem(playerid, itemid, itemtext[]);
- native ShowPlayerDialogList(playerid, dialogid, caption[], button1[], button2[]);
- */
- #if !defined _samp_included
- #error "Please include 'a_samp.inc' before 'dyndial.inc'"
- #endif
- #if defined _dynamic_dialogs_included
- #endinput
- #endif
- #define _dynamic_dialogs_included
- #define MAX_DIALOG_ITEMS (16)
- #define MAX_ITEM_LENGTH (64)
- #define MAX_DIALOG_LENGTH (1024)
- forward OnDialogListResponse(playerid, dialogid, response, itemid, itemtext[]);
- new DialogItemsID[MAX_PLAYERS][MAX_DIALOG_ITEMS];
- new DialogItemsText[MAX_PLAYERS][MAX_DIALOG_LENGTH];
- #if defined FILTERSCRIPT
- public OnFilterScriptInit() {
- foreach(new i : Player) {
- ClearDialogListItems(i);
- }
- if(funcidx("dd_OnFilterScriptInit") != -1) return CallLocalFunction("dd_OnFilterScriptInit", "");
- return 1;
- }
- #if defined _ALS_OnFilterScriptInit
- #undef OnFilterScriptInit
- #else
- #define _ALS_OnFilterScriptInit
- #endif
- #define OnFilterScriptInit dd_OnFilterScriptInit
- forward dd_OnFilterScriptInit();
- public OnFilterScriptExit() {
- foreach(new i : Player) {
- ClearDialogListItems(i);
- }
- if(funcidx("dd_OnFilterScriptExit") != -1) return CallLocalFunction("dd_OnFilterScriptExit", "");
- return 1;
- }
- #if defined _ALS_OnFilterScriptExit
- #undef OnFilterScriptExit
- #else
- #define _ALS_OnFilterScriptExit
- #endif
- #define OnFilterScriptExit dd_OnFilterScriptExit
- forward dd_OnFilterScriptExit();
- #else
- public OnGameModeInit() {
- foreach(new i : Player) {
- ClearDialogListItems(i);
- }
- if(funcidx("dd_OnGameModeInit") != -1) return CallLocalFunction("dd_OnGameModeInit", "");
- return 1;
- }
- #if defined _ALS_OnGameModeInit
- #undef OnGameModeInit
- #else
- #define _ALS_OnGameModeInit
- #endif
- #define OnGameModeInit dd_OnGameModeInit
- forward dd_OnGameModeInit();
- public OnGameModeExit() {
- foreach(new i : Player) {
- ClearDialogListItems(i);
- }
- if(funcidx("dd_OnGameModeExit") != -1) return CallLocalFunction("dd_OnGameModeExit", "");
- return 1;
- }
- #if defined _ALS_OnGameModeExit
- #undef OnGameModeExit
- #else
- #define _ALS_OnGameModeExit
- #endif
- #define OnGameModeExit dd_OnGameModeExit
- forward dd_OnGameModeExit();
- #endif
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
- listitem = DialogItemsID[playerid][listitem];
- ClearDialogListItems(playerid);
- if(funcidx("dd_OnDialogResponse") != -1) return CallLocalFunction("dd_OnDialogResponse", "dddds", playerid, dialogid, response, listitem, inputtext);
- return 0;
- }
- #if defined _ALS_OnDialogResponse
- #undef OnDialogResponse
- #else
- #define _ALS_OnDialogResponse
- #endif
- #define OnDialogResponse dd_OnDialogResponse
- forward dd_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]);
- public OnPlayerConnect(playerid)
- {
- ClearDialogListItems(playerid);
- if(funcidx("dd_OnPlayerConnect") != -1) return CallLocalFunction("dd_OnPlayerConnect", "d",playerid);
- return 1;
- }
- #if defined _ALS_OnPlayerConnect
- #undef OnPlayerConnect
- #else
- #define _ALS_OnPlayerConnect
- #endif
- #define OnPlayerConnect dd_OnPlayerConnect
- forward dd_OnPlayerConnect(playerid);
- stock ClearDialogListItems(playerid) {
- if(!IsPlayerConnected(playerid)) return 0;
- for(new di; di < MAX_DIALOG_ITEMS; di++) {
- DialogItemsID[playerid][di] = -1;
- }
- strdel(DialogItemsText[playerid], 0, sizeof(DialogItemsText[]));
- return 1;
- }
- stock AddDialogListItem(playerid, itemid, itemtext[]) {
- if(!IsPlayerConnected(playerid)) return 0;
- if(itemtext[0] == EOS || strlen(itemtext) > MAX_ITEM_LENGTH) return 0;
- for(new di; di < MAX_DIALOG_ITEMS; di++) {
- if(DialogItemsID[playerid][di] != -1) continue;
- DialogItemsID[playerid][di] = itemid;
- new tmp[MAX_ITEM_LENGTH+2];
- format(tmp, sizeof(tmp), "%s\n", itemtext);
- strcat(DialogItemsText[playerid], tmp, sizeof(DialogItemsText[]));
- return 1;
- }
- return 0;
- }
- stock ShowPlayerDialogList(playerid, dialogid, caption[], button1[], button2[]) {
- if(!IsPlayerConnected(playerid)) return 0;
- ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, caption, DialogItemsText[playerid], button1, button2);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement