Hide some numbers.
#1

Hi,

For ex:

i have that code from 11 symbols:


57895214678


Ofcourse it will be random, but what i want is i want to get 5 first numbers and one less from the end like ex:

57895****7*
Reply
#2

This appears to work:
pawn Код:
public OnGameModeInit()
{

    new value = random(5555555555) + 1111111111; //Can be any value.
    printf("%s", HideNumbers(value));
    return 1;
}

stock HideNumbers(numbertohide)
{
    new length = floatround(floatlog(numbertohide) + 1);
    new string[20];
    format(string, sizeof(string), "%d", numbertohide);
    if(length < 8) return string;
    for(new i = 0; i < length; i++)
    {
        if(i < (length / 2) || i == (length - 2)) continue;
        else string[i] = '*';
    }
    return string;
}
:P

This works for all values less than 99999999999999999999, and all values greater than 0 I guess.
NOTE: The outcome is a STRING not an INTEGER.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)