Squirrel/Server/Functions/Utils/IsNum

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
m (updated title/example)
 
Line 1: Line 1:
__NOTOC__
+
{{Squirrel/Title|IsNum}}
 
This function returns whether a string is a number.
 
This function returns whether a string is a number.
  
Line 12: Line 12:
 
== Example ==
 
== Example ==
  
This example tells the player if their input is a number when they type '/numbertest 123'
+
This example tells the player if their input is a number when they type '/numbertest 123'.
  
 
<code lang="squirrel">
 
<code lang="squirrel">
Line 22: Line 22:
 
           else MessagePlayer( text + " is NOT a number!", player );
 
           else MessagePlayer( text + " is NOT a number!", player );
 
     }
 
     }
 +
   
 +
    return 1;
 
}
 
}
 
</code>
 
</code>

Latest revision as of 13:48, 13 July 2010

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

This function returns whether a string is a number.

[edit] Syntax

  1. bool IsNum( string text )

[edit] Arguments

  • text - This is the string to check

[edit] Example

This example tells the player if their input is a number when they type '/numbertest 123'.

  1.  
  2. function onPlayerCommand( player, cmd, text )
  3. {
  4. if ( cmd == "numbertest" )
  5. {
  6. if ( IsNum( text ) ) MessagePlayer( text + " is a number!", player );
  7. else MessagePlayer( text + " is NOT a number!", player );
  8. }
  9. return 1;
  10. }
  11.  

[edit] Notes

The function MessagePlayer and call onPlayerCommand were used in in this example. More info about them in corresponding pages.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox