16.11.2016, 00:08
Alright so I've stumbled upon a problem while creating this, I am simply trying to make something that will replace certain parts (random parts) of a string.
Example
Normal String:
Output should have 10 random characters:
Now currently my system is kinda glitchy.
1. It will replace few characters with exactly the same letter. For example it will replace 5 characters with a character S
2. Sometimes it will cut down the string. So for example you write "Hello world" and you will get the output "P"
Example
Normal String:
Quote:
Hello World |
Quote:
Aqer Zxcas |
1. It will replace few characters with exactly the same letter. For example it will replace 5 characters with a character S
2. Sometimes it will cut down the string. So for example you write "Hello world" and you will get the output "P"
pawn Код:
new LetterList[26][] =
{
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
};
stock strReplaceChar(string[128]) {
new text_lenght = strlen(string),
rr = random(text_lenght);
for(new i=0; i < text_lenght; i++) {
if(!strcmp(string, " ")) continue; //just to avoid cutting down the spaces
strreplace(string, string[rr], LetterList[random(sizeof(LetterList))], true, .maxlength = 128);
}
return string;
}