SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 22/08/2015, 03:28 PM   #1
Gasman
Little Clucker
 
Gasman's Avatar
 
Join Date: May 2015
Location: VietNam
Posts: 33
Reputation: 73
Default [G]KeyPad (Textdraw)

[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)
Gasman is offline   Reply With Quote
Old 22/08/2015, 03:31 PM   #2
Variable™
Gangsta
 
Variable™'s Avatar
 
Join Date: Jul 2015
Posts: 828
Reputation: 200
Default Re: [G]KeyPad (Textdraw)

COOOOOOL +REP I will use it
Variable™ is offline   Reply With Quote
Old 22/08/2015, 03:32 PM   #3
Michael B
High-roller
 
Michael B's Avatar
 
Join Date: Oct 2014
Location: Romania
Posts: 1,004
Reputation: 127
Default Re: [G]KeyPad (Textdraw)

Nice include Gasman! Just a question, why did you call it GKeyPad instead of KeyPad? Does G come from your name?
__________________
Michael B is offline   Reply With Quote
Old 22/08/2015, 03:33 PM   #4
Crayder
Banned
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,324
Reputation: 652
Default Re: [G]KeyPad (Textdraw)

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.
Crayder is offline   Reply With Quote
Old 22/08/2015, 04:05 PM   #5
Gasman
Little Clucker
 
Gasman's Avatar
 
Join Date: May 2015
Location: VietNam
Posts: 33
Reputation: 73
Default Re: [G]KeyPad (Textdraw)

@1Deagle1 Thank
@Michael B
Yes G from my name . haha.
@Crayder Thank you for this comment. I will do it tomorrow.
Gasman is offline   Reply With Quote
Old 22/08/2015, 07:01 PM   #6
kristo
Banned
 
Join Date: Jun 2012
Location: Estonia
Posts: 352
Reputation: 179
Default Re: [G]KeyPad (Textdraw)

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.
kristo is offline   Reply With Quote
Old 22/08/2015, 07:14 PM   #7
Crayder
Banned
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,324
Reputation: 652
Default Re: [G]KeyPad (Textdraw)

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.
Crayder is offline   Reply With Quote
Old 22/08/2015, 07:41 PM   #8
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,885
Reputation: 1337
Default Re: [G]KeyPad (Textdraw)

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.
Pottus is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] Interactive clickable textdraw keypad system (Easy to use) MP2 Includes 101 12/06/2019 10:23 AM
keypad 0.3e help Tarik_Tare Scripting Help 2 14/05/2012 07:55 PM
[HELP] Keypad.inc don't open clickable textdraw Abravanel Scripting Help 4 09/04/2012 09:25 PM
[Include] Textdraw inputs - easy input using keypad & player list [0.3e] Hiddos Includes 52 30/03/2012 06:22 PM


All times are GMT. The time now is 07:34 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.