![]() |
[Library] Advanced Model Selection Menu (eSelection) - Printable Version + open.mp forum (https://forum.open.mp) -- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) --- Forum: Releases (https://forum.open.mp/forumdisplay.php?fid=13) ---- Forum: Libraries (https://forum.open.mp/forumdisplay.php?fid=31) ---- Thread: [Library] Advanced Model Selection Menu (eSelection) (/showthread.php?tid=1403) |
Advanced Model Selection Menu (eSelection) - TommyB - 2020-12-02 eSelection This library adds the ability to create dynamic model selection menus in your SA-MP gamemodes. It's an edit of the original eSelection include created by the developers of the Interactive Roleplay SA-MP server back in 2013. I've been using it in my own server for many years and made countless adjustments, fixes, optimizations and feature changes to it. After a bit of consideration, I decided to open source the changes I've made. This edit (well, it's closer to a rewrite) makes use of dynamic PawnPlus containers, adds in an improved API, descriptive text per model preview and also adds the ability to call task-based menu responses, which will be demonstrated below. ![]() ![]() Installation Simply install to your project: Code: sampctl package install TommyB123/eSelection Include in your code and begin using the library: PHP Code: #include <eSelection> Functions Adds a new model to a model selection list. Descriptive text and preview rotations are supported as optional arguments. PHP Code: AddModelMenuItem(List:menulist, modelid, const text[] = "", bool:usingrotation = false, Float:rotx = 0.0, Float:roty = 0.0, Float:rotz = 0.0, Float:zoom = 1.0) Shows a model selection menu to a player. OnModelSelectionResponse will be called when using this function. PHP Code: ShowModelSelectionMenu(playerid, const header[], extraid, List:items) Shows a model selection menu to a player. Requires waiting for a PawnPlus task to receive the response results. PHP Code: Task:ShowAsyncModelSelectionMenu(playerid, const header[], List:items) Non-task-based model selection menu responses are handled via the callback below. PHP Code: public OnModelSelectionResponse(playerid, extraid, index, modelid, response) extraid is the ID of the model menu provided in ShowModelSelectionMenu. This functionality is similar to the dialog ID argument in ShowPlayerDialog. index is the list index of the model that was clicked. If the first model in a menu is clicked, index will 0. If the second model is clicked, index will be 1. You get the point, I hope. modelid is the model ID that was clicked. If a player clicks on skin ID 5 in a model menu, this variable would also be 5. Relevant constants MODEL_RESPONSE_CANCEL - Response value when a player cancels a model menu. MODEL_RESPONSE_SELECT - Response value when a player clicks on a model inside of a model menu. The following constants are used in the array response when handling a task-based model menu response. E_MODEL_SELECTION_RESPONSE - The response value to be compared with the constants described above. Equiavelent to the response argument in OnModelSelectionResponse E_MODEL_SELECTION_INDEX - The index of the model selection menu response. Equivalent to the index argument in OnModelSelectionResponse E_MODEL_SELECTION_MODELID - The model ID of the model selection menu response. Equivalent to the modelid argument in OnModelSelectionResponse Usage Example of a traditional model selection response when using ShowModelSelectionMenu PHP Code: // define an ID for the model selection menu below Example of waiting for a task-based model selection menu response with ShowAsyncModelSelectionMenu PHP Code: // enable the "await" syntax from PawnPlus before including it Credits Interactive Roleplay Developer(s) - Original authors of this library Me - Numerous feature updates, housekeeping, etc RE: Advanced Model Selection Menu (eSelection) - Pinch - 2020-12-02 Big PawnPlus energy indeed. Design could be a bit better but it's still 10/10 RE: Advanced Model Selection Menu (eSelection) - Toxic - 2020-12-04 Didn't try it myself but looks pretty useful RE: Advanced Model Selection Menu (eSelection) - Radical - 2021-06-05 This library stopped/crashed the compiler for me. https://pasteboard.co/K5cVApH.png Why? |