Results 1 to 5 of 5

Thread: String to float?

  1. #1
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts

    String to float?

    Any way I can convert a string to float?

    One of my floating points gets too long so I need to resize it.

    Best I can come up with is to convert to string, resize, then back to float.

    However I'm having trouble finding a way to convert from string back to float.

    Does anyone have a method for this?
    Last edited by filthy_freak_; 6th May 2014 at 12:02.

  2. #2
    Private First Class RobsoN's Avatar
    Join Date
    Jan 2013
    Location
    /home/cod2/
    Posts
    230
    Thanks
    119
    Thanked 95 Times in 64 Posts
    If you haven't got libcod, you may try this:

    PHP Code:
    strToFloat(str)
    {
      
    setCvar("temp",str);
      return 
    GetCvarFloat("temp");

    "Don't worry if your code doesn't work correctly - if everything worked, you would not work" ~Mosher's right

  3. The Following User Says Thank You to RobsoN For This Useful Post:

    filthy_freak_ (6th May 2014)

  4. #3
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Quote Originally Posted by RobsoN View Post
    If you haven't got libcod, you may try this:

    PHP Code:
    strToFloat(str)
    {
      
    setCvar("temp",str);
      return 
    GetCvarFloat("temp");

    Thanks, working perfectly. Such an odd way to do it yet so simple.

    BTW Yes i'm using libcod.

  5. #4
    Private First Class RobsoN's Avatar
    Join Date
    Jan 2013
    Location
    /home/cod2/
    Posts
    230
    Thanks
    119
    Thanked 95 Times in 64 Posts
    So you simply can do it by calling an function stringToFloat(str)

    more info at: http://znation.nl/cod4script/
    "Don't worry if your code doesn't work correctly - if everything worked, you would not work" ~Mosher's right

  6. The Following 2 Users Say Thank You to RobsoN For This Useful Post:

    filthy_freak_ (6th May 2014),kung foo man (6th May 2014)

  7. #5
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Quote Originally Posted by RobsoN View Post
    So you simply can do it by calling an function stringToFloat(str)

    more info at: http://znation.nl/cod4script/
    O.O no idea how I missed that.

Posting Permissions

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