10.10.2014, 18:08
(
Последний раз редактировалось AnnaSB; 12.10.2014 в 15:53.
Причина: Add Description
)
Hi all SAMP developers! I'm Anna SB, an amateur PAWN dev. I was looking for a text-to-go selection pane, like the one which Blacklite created. So I decided on creating one myself and publish it as an include to let other devs use too.
This solution is very very very customisable so it can be used for any theme. Some options are missing that will be added in future updates. Anyhow you can follow the development process on my GitHub.
For now, release v0.9.2 contains a variety of tools for creating global IndexDraws.
What is IndexDrawer?
IndexDrawer is a selection menu created using SAMP TextDraws. These menus don't need a mouse to be selected; only a key character, number or a small phrase that is unique for each menu option is used to select them, typing that phrase will cause the include to trigger a callback and let you react to the client's selection.
For example a menu like this:
Код:
My Menu 1. Give Me a Car 2. Give Me a Bus 3. Give Me Money K. Kill Me
* Which menu it was: ID of the IndexDraw that can be used for various commands...
* Which player it was: ID of the player who selected that.
* Selected option's index: Here 'K' has the fourth index.
* Selection phrase used: Player typed 'K'.
* Selected option's title: Option selected was named "Kill Me".
So we can let players choose an option from a menu just by typing a letter or two, and don't bother with mouse-based selection. Now let's use it!
Getting Started: Including
pawn Код:
#define MAX_SLOTS XXXX
#include <IndexDrawer>
// You sould define MAX_SLOTS before including the IndexDrawer,
// XXXX is the max players that can join your server, for example mine is 100.
pawn Код:
new idraw = IndexDrawCreate(Float:x, Float:y, title[], Float:xsize, Float:ysize, backcolor, align, font, outline, titlecolor[], enumcolor[], textcolor[])
// titlecolor, enumcolor and textcolor values are gametext colors like "~r~" with max length of 12.
// enumcolor is the color used for list bullet numbers.
IndexDrawLetterSize(idraw, Float:x, Float:y)
// Same as TextDrawLetterSize
IndexDrawCancelKey(idraw, keystate)
// Set a key which causes the selection to cancel, for example KEY_SPRINT.
// Default value is KEY_FIRE and if you want it you don't need to call this.
new index = IndexDrawAddOption(idraw, keytitle[], keystate[])
// Adds an option that can be selected by typing the keystate's value into the chatbox while selecting.
// Max. length of keytitle is 20 and for keystate is 2.
IndexDrawRemoveOption(idraw, index)
pawn Код:
IndexDrawShowForPlayer(playerid, idraw)
IndexDrawHideForPlayer(playerid, idraw)
IndexDrawDispose(idraw)
// Destroys the iDraw and releases all its related resources.
new ActiveDraw = GetPlayerActiveIndexDraw(playerid)
new bool:IsActive = IsPlayerIndexDrawActive(playerid, idraw)
pawn Код:
public OnIndexDrawCanceled(playerid, idraw)
// Triggers when an iDraw selection is cancelled for a user using the cancellation key.
public OnIndexDrawSelected(playerid, idraw, index, keystate[], keytitle[])
// Triggers when a player has selected an option by text-ing its index key.
Thanks and rep/star please! Don't forget to report any bug you seen on GitHub issues tab.
Kind kind regards - Anna SB