[G]KeyPad (Textdraw) -
Gasman - 22.08.2015
[G]KeyPad
Hi guys,
Today i made include called [G]KeyPad
Function
BUTTONS
0-9 to add number
Ok to response
Del to remove numer
X to close [G]Keypad
SHOW
pawn Code:
native ShowGKeyPad(playerid,keypadid,match,selectcolor = -1);
Description:
Display [G]KeyPad for player
Parameters:
pawn Code:
(playerid,keypadid,match,selectcolor)
playerid - The ID of the player to display the [G]KeyPad
keypadid - An ID to assign this [G]KeyPad to, so responses can be processed.
match - An value of keypad. ( check if player input value success)
selectcolor - Color Select textdraw ( default White)
HIDE
pawn Code:
native HideGKeyPad(playerid);
Description:
Hide [G]KeyPad for player.
Parameters:
pawn Code:
(playerid)
playerid - The ID of the player to display the [G]KeyPad
Callback
pawn Code:
public OnPlayerEnterGKeyPad(playerid,success,keypadid,value,match)
Description:
This callback is called when a player click button 'Ok' on [G]KeyPad
Parameters:
pawn Code:
(playerid,success,keypadid,value,match)
playerid - The ID of the player that enter to the [G]KeyPad
success - 0 is wrong and 1 is correct
keypadid - The ID of the [G]Keypad the player enter to, assigned in ShowGKeyPad
value - Is Value of player input
match - Is Value of Keypadid
IMAGES
EXAMPLE
Code:
#define FILTERSCRIPT
#include <a_samp>
#include <gkeypad>
#include <zcmd>
CMD:gkeypad(playerid,params[])
{
ShowGKeyPad(playerid,1,123456,-1);
return 1;
}
CMD:cursor(playerid,params[])
{
if(IsGKeyPadOpened(playerid) == 1) SelectTextDraw(playerid,-1);
else SendClientMessage(playerid,-1,"GKeypad no opened");
return 1;
}
public OnPlayerEnterGKeyPad(playerid,success,keypadid,value,match)
{
new str[128];
format(str,sizeof(str),"%d , id : %d,value %d match %d",success,keypadid,value,match);
SendClientMessage(playerid,-1,str);
return 1;
}
DOWNLOAD
https://github.com/gasmanvnn/SA-MP/b...ts/gkeypad.inc
CREDITS
Specical thank Southclaw's for Example Functions.
Gasman for script.
ZeeX for Zcmd (Example)
Re: [G]KeyPad (Textdraw) -
Variable™ - 22.08.2015
COOOOOOL +REP I will use it
Re: [G]KeyPad (Textdraw) -
Michael B - 22.08.2015
Nice include Gasman! Just a question, why did you call it GKeyPad instead of KeyPad? Does G come from your name?
Re: [G]KeyPad (Textdraw) -
Crayder - 22.08.2015
You should have it like this:
[7][8][9]
[4][5][6]
[1][2][3]
[0]
That's how most keypads are. You have it like a cell phone.
Re: [G]KeyPad (Textdraw) -
Gasman - 22.08.2015
@1Deagle1 Thank
@Michael B
Yes G from my name .

haha.
@Crayder Thank you for this comment. I will do it tomorrow.
Re: [G]KeyPad (Textdraw) -
kristo - 22.08.2015
Remove the X button as it doesn't really fit in the box. I think the user will be smart enough to press escape on their keyboard.
Re: [G]KeyPad (Textdraw) -
Crayder - 22.08.2015
pawn Code:
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
if(GKeyPadOpened[playerid])
{
if(clickedid == GKeyPad[33] || clickedid == Text:INVALID_TEXT_DRAW)
HideGKeyPad(playerid);
if(clickedid == GKeyPad[31])
GKeyPadEnter(playerid);
if(clickedid == GKeyPad[32])
GKeypadRemoveNumber(playerid);
if(clickedid == GKeyPad[21])
GKeypadAddNumber(playerid,1);
if(clickedid == GKeyPad[22])
GKeypadAddNumber(playerid,2);
if(clickedid == GKeyPad[23])
GKeypadAddNumber(playerid,3);
if(clickedid == GKeyPad[24])
GKeypadAddNumber(playerid,4);
if(clickedid == GKeyPad[25])
GKeypadAddNumber(playerid,5);
if(clickedid == GKeyPad[26])
GKeypadAddNumber(playerid,6);
if(clickedid == GKeyPad[27])
GKeypadAddNumber(playerid,7);
if(clickedid == GKeyPad[28])
GKeypadAddNumber(playerid,8);
if(clickedid == GKeyPad[29])
GKeypadAddNumber(playerid,9);
if(clickedid == GKeyPad[30])
GKeypadAddNumber(playerid,0);
}
#if defined gkp_OnPlayerClickTextDraw
return gkp_OnPlayerClickTextDraw(playerid, _:clickedid)
#else
return 1;
#endif
}
That'll prevent collision with other scripts and add 'esc' detection to hide.
Re: [G]KeyPad (Textdraw) -
Pottus - 22.08.2015
Don't want to get too involved in SA-MP but a quick tip make sure you always clean up after in OnFilterScriptExit() /OnGameModeExit() this include will result in losing your textdraw references so eventually the limit could potentially be reached.