Squirrel/Server/Functions/Utils/IsNum

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
m
Line 15: Line 15:
  
 
<code lang="squirrel">
 
<code lang="squirrel">
function OnPlayerCommand( id, cmd, text )
+
function OnPlayerCommand( player, cmd, text )
 
{
 
{
 
     if ( cmd == "numbertest" )
 
     if ( cmd == "numbertest" )
 
     {
 
     {
           if ( IsNum( text ) ) MessagePlayer( text + " is a number!", id );
+
           if ( IsNum( text ) ) MessagePlayer( text + " is a number!", player );
           else MessagePlayer( text + " is NOT a number!", id );
+
           else MessagePlayer( text + " is NOT a number!", player );
 
     }
 
     }
 
}
 
}

Revision as of 20:36, 31 March 2009

This function returns whether the string is a number

Syntax

  1. bool IsNum( string text )

Arguments

  • text - This is the string to check

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. }
  10.  

Notes

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

Related Functions

Template:Squirrel/Functions/Misc

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox