Hide some numbers. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Hide some numbers. (
/showthread.php?tid=498115)
Hide some numbers. -
audriuxxx - 02.03.2014
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*
Re: Hide some numbers. -
Threshold - 02.03.2014
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.