good morning
I created a GUI, a simple phone keypad. I would like to set a number (if you type for example 0012345)
proceed with an action
thanks
Please add some details. How are you processing keypad clicks? Etc.
hi Khris how are you?
for now I have created a gui with 12 keys.
123
456
789
* 0 #
click event and in globalscript
Button6_OnClick function (GUIControl * control, MouseButton button) {
// USE INV
OptionGui.OnClick (control, button); {
player.Say ("1");
}
}
Button7_OnClick function (GUIControl * control, MouseButton button) {
// USE INV
OptionGui.OnClick (control, button); {
player.Say ("2");
}
}
etc .. I wish that if the player typed the right number, the animation starts
Righty, so you can do this for instance:
String keypadKeys;
function Type(String number) {
if (keypadKeys == null) keypadKeys = "";
keypadKeys = keypadKeys.Append(number);
// display typed number in a label?
// lblDisplay.Text = keypadKeys;
if (keypadKeys == "0012345") {
// stuff happens
}
}
function button6_OnClick(GUIControl* control, MouseButton button) {
Type("1");
}
function button7_OnClick(GUIControl* control, MouseButton button) {
Type("2");
}
Note that if you created the keys in order, the digit on the key is control.ID + 5, which means you can use a single function for all your 0-9 buttons.
ok, it seems clear but I get this error
GlobalScript.asc(335): Error (line 335): cannot assign initial value to global pointer
Which line is 335?
Never mind, code fixed.
Quote from: Khris on Thu 03/03/2022 09:09:12
Which line is 335?
(https://i.ibb.co/2qp3f87/Immagine-2022-03-03-101011.jpg) (https://imgbb.com/)
(https://i.ibb.co/2qp3f87/Immagine-2022-03-03-101011.jpg)
Quote from: Khris on Wed 02/03/2022 22:37:27
// display typed number in a label?
// lblDisplay.Text = keypadKeys;
lbl.Text = keypadKeys;
this works
Yeah, it was an example that needed a label called lblDisplay, which is why I put it as comment.
yes then I understood .. thanks