Results 1 to 9 of 9

Thread: Count the numbers of symbols etc in a name

  1. #1
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts

    Count the numbers of symbols etc in a name

    Hi all,

    Im new here. Some ppl may know me from modsonline or just COD2.
    But how can you count the numbers of symbols, signs, numbers and letters on a name?
    For example, Ni3ls = 5, but Ni^23^7ls = 8.

    I need this, because when a name is longer then 10 characters for example, something will happen with that name.
    Thanks

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Yeah, i know you


    Didnt tested, but shall work:
    Code:
    letters = 0;
    numbers = 0;
    symbols = 0;
    
    for (i=0; i<str.size; i++)
    {
        switch (str[i]) // switch on current char
        {
            case "0":
            case "1":
            case "2":
            case "3":
            case "4":
            case "5":
            case "6":
            case "7":
            case "8":
            case "9":
                numbers++;
                break;
            case "^": // add all other symbols you want
                symbols++;
                break;
            default:
                letters++;
        }
    }
    timescale 0.01

  3. #3
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    I will test it later. But str.size is the size of the name right? Is it possible to get the stringsize then, since it's already implented in cod?

  4. #4
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Yep, correct, like "test".size == 4
    timescale 0.01

  5. #5
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Well it was just this what I was looking for.
    Code:
    self.name.size
    Thanks to Izno. And ty kung for the other script, I can use that aswell

  6. #6
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by Ni3ls View Post
    Hi all,

    Im new here. Some ppl may know me from modsonline or just COD2.
    But how can you count the numbers of symbols, signs, numbers and letters on a name?
    For example, Ni3ls = 5, but Ni^23^7ls = 8.

    I need this, because when a name is longer then 10 characters for example, something will happen with that name.
    Thanks
    Code:
    if( self.name.size > 10 )
    doStuff();

  7. #7
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Yes i already got it

    BTW: kung str.size is undefined in ur script
    Last edited by Ni3ls; 14th December 2012 at 14:01.

  8. #8
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    write before the script:

    Code:
    str = player.name;
    timescale 0.01

  9. #9
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Danke sehr!

Posting Permissions

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