dialog input
#1

PHP код:
new time;
if( 
sscanfparams"i"time ) ) return SendClientMessageplayeridyellow"Usage: /time <0-24>" );
if( 
time 24 || time ) return SendClientMessageplayeridred">> Available Hours: <0-24>" );
SetPlayerTime(playerid,time0); 
I want to make it like a dialog input where you put the Digit or Time in the input dialog box. how?
Reply
#2

pawn Код:
// command:
ShowPlayerDialog( playerid, 463, DIALOG_STYLE_INPUT, "Time", "Enter the time below:", "Change!", "Cancel" );

// OnDialogResponse, check if the dialogid is 463 by using if statement or swictch (recommended for more cases - it's faster!)
if( response )
{
    if( !IsNumeric( inputtext ) ) return ShowPlayerDialog( playerid, 463, DIALOG_STYLE_INPUT, "Time", "You must input a number. Re-enter the time below:", "Change!", "Cancel" );
    new
        time = strval( inputtext )
    ;
    if( time > 24 || time < 0 ) return SendClientMessage( playerid, red, ">> Available Hours: <0-24>" );
    SetPlayerTime( playerid, time, 0 );
}

// IsNumeric (to prevent false values from strval if the text contains letters or other chars excluding 0-9)
stock IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
// command:
ShowPlayerDialog( playerid, 463, DIALOG_STYLE_INPUT, "Time", "Enter the time below:", "Change!", "Cancel" );

// OnDialogResponse, check if the dialogid is 463 by using if statement or swictch (recommended for more cases - it's faster!)
if( response )
{
    if( !IsNumeric( inputtext ) ) return ShowPlayerDialog( playerid, 463, DIALOG_STYLE_INPUT, "Time", "You must input a number. Re-enter the time below:", "Change!", "Cancel" );
    new
        time = strval( inputtext )
    ;
    if( time > 24 || time < 0 ) return SendClientMessage( playerid, red, ">> Available Hours: <0-24>" );
    SetPlayerTime( playerid, time, 0 );
}

// IsNumeric (to prevent false values from strval if the text contains letters or other chars excluding 0-9)
stock IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}
Omg! Save me time. Thank you very much brother! +repppp
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)