new time;
if( sscanf( params, "i", time ) ) return SendClientMessage( playerid, yellow, "Usage: /time <0-24>" );
if( time > 24 || time < 0 ) return SendClientMessage( playerid, red, ">> Available Hours: <0-24>" );
SetPlayerTime(playerid,time, 0);
// 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;
}
pawn Код:
|