Settime

Started by Knight, Jul 12, 2015, 05:35 AM

Previous topic - Next topic

Knight

Can someone  fix this and help me understand that code ...
http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/SetTime
I had changed it to


   if ( cmd == "settime" ){
      if ( !text ) MessagePlayer( "Correct syntax : /settime <hr> <min>", player );
      else if ( split(text, " ").len() < 2) return MessagePlayer("Correct syntax : /settime <hr> <min>", player )
      local a = split(text, " ");
      if ( !IsNum( a[0] )) MessagePlayer( "Format: /settime <hr> <min>", player );
      else if ( !IsNum( a[1] )) MessagePlayer( "Format: /settime <hr> <min>", player );
      else SetTime( a[0], a[1] ) ; 
              }but it still doesn't work :(



Mashreq

You can use this one
if ( cmd == "settime" )
{
      if ( !text ) MessagePlayer( "Correct syntax : /settime <hr> <min>", player );
      else if ( split(text, " ").len() < 2) return MessagePlayer("Correct syntax : /settime <hr> <min>", player )
      else
  {
  local a = split(text, " ");
      if ( !IsNum( a[0] )) MessagePlayer( "Format: /settime <hr> <min>", player );
      else if ( !IsNum( a[1] )) MessagePlayer( "Format: /settime <hr> <min>", player );
      else SetTime( a[0].tointeger(), a[1].tointeger() ) ; 
      }
  }

Knight


Thijn

You can combine the two if's like so:
      if ( !IsNum( a[0] ) || !IsNum( a[1] )) MessagePlayer( "Format: /settime <hr> <min>", player );