SA-MP Forums Archive
dialog input - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: dialog input (/showthread.php?tid=471816)



dialog input - gotwarzone - 25.10.2013

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?


Re: dialog input - Konstantinos - 25.10.2013

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;
}



Re: dialog input - gotwarzone - 25.10.2013

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