Squirrel/Server/Functions/Utils/IsNum
From Liberty Unleashed Wiki
(Difference between revisions)
m |
(Updated) |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | This function returns whether | + | This function returns whether a string is a number. |
== Syntax == | == Syntax == | ||
Line 15: | Line 15: | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | function | + | function onPlayerCommand( player, cmd, text ) |
{ | { | ||
if ( cmd == "numbertest" ) | if ( cmd == "numbertest" ) | ||
Line 27: | Line 27: | ||
=== Notes === | === Notes === | ||
− | The function [[Squirrel/Functions/ | + | The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and call [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in in this example. More info about them in corresponding pages. |
== Related Functions == | == Related Functions == | ||
− | {{Squirrel/Functions/ | + | {{Squirrel/Server/Functions/Utils}} |
Revision as of 04:38, 13 November 2009
This function returns whether a string is a number.
Syntax
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'
function onPlayerCommand( player, cmd, text ) { if ( cmd == "numbertest" ) { if ( IsNum( text ) ) MessagePlayer( text + " is a number!", player ); else MessagePlayer( text + " is NOT a number!", player ); } }
Notes
The function MessagePlayer and call onPlayerCommand were used in in this example. More info about them in corresponding pages.