Signup Now
Results 1 to 5 of 5
  1. #1
    Banned
    Join Date
    Dec 2013
    Location
    Porto Alegre - RS
    Posts
    524
    Reputation
    61
    Rep Power
    0

    Convert string to variable number

    Hello guys, i figured it, idk if anybody needs this too, but when makes some configs, like lua varations of comparation like:

    Code:
    mincap = getuseroption("MinCap")
    if $cap < MinCap then
    say("test")
    end
    It will result in error that not compare Number with String or String with Number

    So the easy FIX is to add +0 in after the variable string, to convert it to a number like:

    Code:
    mincap = getuseroption("MinCap")
    if $cap < mincap+0 then
    say("test")
    end
    No string code error

    [SIZE=10px]Tnx to, Invalid Name to his discovery![/SIZE]

    This image is hosted on a possibly dangerous website (http://puu.sh/5IqH5.png). Please consider reuploading it on Imgur.com.


  2. #2
    Moderator RoxZin xD's Avatar
    Join Date
    Dec 2013
    Location
    Rio de Janeiro
    Posts
    4,914
    Reputation
    109
    Rep Power
    31
    Isn't there something like tosec() or tostring() in-built? o.o

  3. #3
    Banned
    Join Date
    Dec 2013
    Location
    Porto Alegre - RS
    Posts
    524
    Reputation
    61
    Rep Power
    0
    Idk, but this way is simple i think .-.

  4. #4
    Moderator Raphael's Avatar
    Join Date
    Dec 2013
    Location
    raphseller.com
    Posts
    2,441
    Reputation
    309
    Rep Power
    28
    Please, don't do that. Use tonumber().

  5. #5
    Banned
    Join Date
    Dec 2013
    Location
    Porto Alegre - RS
    Posts
    524
    Reputation
    61
    Rep Power
    0
    Quote Originally Posted by Raphael;n965
    Please, don't do that. Use tonumber().
    Nice, this one!

    Will release this in my next scripts!

    Thanks!

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •