Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-------------------------------Horsemeat------------------------------------//
- //-------------------------------Multipage-----------------------------------//
- //-----------------------------------V1-------------------------------------//
- //-------------------------------horsemeat---------------------------------//
- //-----------------------------built-on-0.3z------------------------------//
- //--------------------LastUpdate-for-0.3z-8,31,2014----------------------//
- //go here for the latest updates ---------------------------------------//
- #pragma dynamic 20000
- #include <a_samp>
- #include <ysi\y_dialog>
- #include <ysu\y_inline>
- #if defined _multipage_included
- #endinput
- #endif
- #define _multipage_included
- forward MenuPageString(playerid,index,dialogid,string[],size);
- forward MenuPageReturn(playerid,index,dialogid);
- MenuPage(playerid,did, data[], size, string:label[],string:button1[],string:button2[])
- {
- new page;
- new bool:nextpage = false;
- inline MenuPageD(pid, dialogid, response, listitem, string:inputtext[])
- {
- #pragma unused dialogid, pid, inputtext
- if(response)
- {
- if(listitem == 10)
- {
- if(nextpage)
- {
- page = page + 10;
- Dialog_ShowCallback(playerid,using inline MenuPageD, DIALOG_STYLE_LIST,label ,MenuPageText(playerid,page,did,nextpage,data,size), button1,button2);
- }
- else
- {
- Dialog_ShowCallback(playerid,using inline MenuPageD, DIALOG_STYLE_LIST, label,MenuPageText(playerid,page,did,nextpage,data,size), button1,button2);
- }
- }
- else if(listitem == 11)
- {
- if(page >= 10)
- {
- page = page - 10;
- Dialog_ShowCallback(playerid,using inline MenuPageD, DIALOG_STYLE_LIST, label,MenuPageText(playerid,page,did,nextpage,data,size), button1,button2);
- }
- else
- {
- Dialog_ShowCallback(playerid,using inline MenuPageD, DIALOG_STYLE_LIST, label,MenuPageText(playerid,page,did,nextpage,data,size), button1,button2);
- }
- }
- else
- {
- new selected = MenuPageSelected(page,listitem,data,size);
- CallRemoteFunction("MenuPageReturn","iii",playerid,selected,did);
- }
- }
- }
- Dialog_ShowCallback(playerid,using inline MenuPageD, DIALOG_STYLE_LIST, label, MenuPageText(playerid,page,did,nextpage,data,size), button1,button2);
- }
- stock MenuPageSelected(page,selected,data[],size)
- {
- new limitcount,actualcount;
- for(new count;count < size;count++)
- {
- if((data[count])==1)
- {
- if((limitcount) >= page)
- {
- if((actualcount) == selected)
- {
- return count;
- }
- else
- {
- actualcount++;
- }
- }
- else
- {
- limitcount++;
- }
- }
- }
- return -1;
- }
- stock MenuPageText(playerid,page,dialogid,&bool:nextpage,data[],size)
- {
- new string[1024],stradd[1024],limitcount,actualcount;
- for(new count;count < size;count++)
- {
- if((data[count])==1)
- {
- if((limitcount) >= page)
- {
- if((actualcount) < 10)
- {
- actualcount++;
- new str[256];
- format(str,sizeof(str),"%s",GetStringForPage(playerid,count,dialogid));
- if(isnull(string))
- {
- format(string,sizeof(string),"%s",str);
- }
- else
- {
- format(stradd,sizeof(stradd),"%s\n%s",string,str);
- format(string,sizeof(string),"%s",stradd);
- }
- }
- else
- {
- break;
- }
- }
- else
- {
- limitcount++;
- }
- }
- }
- if((actualcount)==10)
- {
- if(CheckNextPage(page,data,size))
- {
- nextpage = true;
- format(stradd,sizeof(stradd),"%s\nNextpage",string);
- format(string,sizeof(string),"%s",stradd);
- }
- }
- else
- {
- nextpage = false;
- while(actualcount != 10)
- {
- actualcount++;
- if(isnull(string))
- {
- format(string,sizeof(string),"empty");
- }
- else
- {
- format(stradd,sizeof(stradd),"%s\nempty",string);
- format(string,sizeof(string),"%s",stradd);
- }
- }
- format(stradd,sizeof(stradd),"%s\nNo Next Page",string);
- format(string,sizeof(string),"%s",stradd);
- }
- if((page) >= 10)
- {
- format(stradd,sizeof(stradd),"%s\nLast Page",string);
- format(string,sizeof(string),"%s",stradd);
- }
- return string;
- }
- stock CheckNextPage(page,data[],size)
- {
- new limitcount = 0;
- new npage = page + 10;
- for(new count;count < size;count++)
- {
- if((data[count])==1)
- {
- if((limitcount) >= npage)
- {
- return true;
- }
- else
- {
- limitcount++;
- }
- }
- }
- return false;
- }
- stock GetStringForPage(playerid,index,dialogid)
- {
- new text[256];
- format(text,sizeof(text),"Test\n");
- CallLocalFunction2("MenuPageString","iiisi",playerid,index,dialogid,text,sizeof(text));
- return text;
- }
- //Thanks Slice/Y_Less for this script
- //http://forum.sa-mp.com/showpost.php?p=1642880&postcount=2950
- stock CallLocalFunction2(const szFunction[], const szFormat[], {Float, _}:...)
- {
- new
- iFunc,
- iIndex,
- iTemp,
- iNumArgs = strlen(szFormat),
- iArg = iNumArgs,
- bool:bPackedFormat = ispacked(szFormat)
- ;
- // Get the function's address
- if (-1 != (iIndex = funcidx(szFunction))) {
- // Load the offset to DAT from the prefix
- #emit LCTRL 1
- // Invert it so we have the offset to the prefix from DAT
- #emit NEG
- // Copy it to alt for use later
- #emit MOVE.alt
- // Add 32 to jump to the offset containing the public function's table
- #emit ADD.C 32
- // Read the value there; must be done using LREF because
- // it's outside of the DAT section
- #emit STOR.S.pri iTemp
- #emit LREF.S.pri iTemp
- // Add the value we just loaded to the prefix (that we stored in alt)
- #emit ADD
- // Add index * 8 (each entry contains 2 cells - a pointer to the function's name
- // and a pointer to the function itself, relative to COD).
- #emit LOAD.S.alt iIndex
- #emit SHL.C.alt 3
- // Add that to the offset
- #emit ADD
- // Now get the address it's pointing to. This seems to only work
- // using LREF (as opposed to LOAD.I, for example).
- #emit STOR.S.pri iTemp
- #emit LREF.S.pri iTemp
- // Now store it
- #emit STOR.S.pri iFunc
- } else {
- return 0;
- }
- while (--iArg >= 0) {
- switch (bPackedFormat ? szFormat{iArg} : szFormat[iArg]) {
- // String, array, and variables passed by reference
- case 's', 'a', 'v': {
- // Load the frame pointer
- #emit LCTRL 5
- // Add 12 + (2 + iArg) * 4 to get the argument we want
- #emit LOAD.S.alt iArg
- #emit SHL.C.alt 2
- #emit ADD
- #emit ADD.C 20
- // Load the address there
- #emit LOAD.I
- // Push that address
- #emit PUSH.pri
- }
- // Single-cell arguments passed by value; I used "default"
- // here because it seems that's what CallLocalFunction does.
- default: {
- // Load the frame pointer
- #emit LCTRL 5
- // Add 12 + (2 + iArg) * 4 to get the argument we want
- #emit LOAD.S.alt iArg
- #emit SHL.C.alt 2
- #emit ADD
- #emit ADD.C 20
- // Load the address there
- #emit LOAD.I
- // Load the value that address points to
- #emit LOAD.I
- // Push that value
- #emit PUSH.pri
- }
- }
- }
- // Push iNumArgs * 4
- #emit LOAD.S.pri iNumArgs
- #emit SHL.C.pri 2
- #emit PUSH.pri
- // Push the return address
- #emit LCTRL 6
- #emit ADD.C 28
- #emit PUSH.pri
- // Call the function
- #emit LOAD.S.pri iFunc
- #emit SCTRL 6
- // Restore the stack
- #emit STACK 24
- // Return (pri is the return value, which comes from iFunc)
- #emit RETN
- // Never actually happens
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement