oblinez Posted May 27, 2020 Share Posted May 27, 2020 while(input(.name$) == "" && (isdigit(.name$))){ input .name$; } I want the player to type only letters/words, if it contains any number he will have to type it again without numbers how can I do that? Quote Link to comment Share on other sites More sharing options...
0 Patskie Posted May 27, 2020 Share Posted May 27, 2020 prontera,150,150,6 script Sample 112,{ do { input [email protected]$; } while (callfunc("ValidateInput", [email protected]$)); mes "You pick " + [email protected]$; close; } function script ValidateInput { [email protected]$ = getarg(0, ""); [email protected] = getstrlen([email protected]$); for ([email protected] = 0; [email protected] < [email protected]; [email protected]++) { if (charat([email protected]$, [email protected]) != " ") { if (!charisalpha([email protected]$, [email protected])) return 1; } } return 0; } Quote Link to comment Share on other sites More sharing options...
0 oblinez Posted May 27, 2020 Author Share Posted May 27, 2020 9 hours ago, Patskie said: prontera,150,150,6 script Sample 112,{ do { input [email protected]$; } while (callfunc("ValidateInput", [email protected]$)); mes "You pick " + [email protected]$; close; } function script ValidateInput { [email protected]$ = getarg(0, ""); [email protected] = getstrlen([email protected]$); for ([email protected] = 0; [email protected] < [email protected]; [email protected]++) { if (charat([email protected]$, [email protected]) != " ") { if (!charisalpha([email protected]$, [email protected])) return 1; } } return 0; } you are my savior! can you explain your code for me? so that i can learn how does the first part undestand that returning 1 or 0 must repeat the input or not is this boolean? callfunc returns 1 or 0, while true it pass, false it fall into condition, that's right? Quote Link to comment Share on other sites More sharing options...
0 Patskie Posted May 27, 2020 Share Posted May 27, 2020 The function i created will loop over each character of the string and check if that character is a letter or a number. If there is a number then always return 1 else 0. You can return anything from a function you can leave it empty as well for any reason. I just use 0 and 1 because any !var means 0 and var means something else. Quote Link to comment Share on other sites More sharing options...
0 oblinez Posted May 27, 2020 Author Share Posted May 27, 2020 10 hours ago, Patskie said: prontera,150,150,6 script Sample 112,{ do { input [email protected]$; } while (callfunc("ValidateInput", [email protected]$)); mes "You pick " + [email protected]$; close; } function script ValidateInput { [email protected]$ = getarg(0, ""); [email protected] = getstrlen([email protected]$); for ([email protected] = 0; [email protected] < [email protected]; [email protected]++) { if (charat([email protected]$, [email protected]) != " ") { if (!charisalpha([email protected]$, [email protected])) return 1; } } return 0; } how to prevent the player type only space? Quote Link to comment Share on other sites More sharing options...
0 Patskie Posted May 28, 2020 Share Posted May 28, 2020 Comment //if (charat([email protected]$, [email protected]) != " ") { if (!charisalpha([email protected]$, [email protected])) return 1;//} Quote Link to comment Share on other sites More sharing options...
I want the player to type only letters/words, if it contains any number he will have to type it again without numbers
how can I do that?
Link to comment
Share on other sites