You can use OnPlayerText and then make an array of words that you'll replace them with, for example, if player types 'ungag me', you replace it with 'ungahg meh', and you can add as many as words you like if you use array and strcmp and str replace function.
|
// Replacement rules (these can have any number of characters) static LetterA[3] = { 'g', 'h', 'd' }; static LetterE[3] = { 'g', 'h', 'd' }; static LetterI[3] = { 'g', 'h', 'd' }; static LetterO[3] = { 'g', 'h', 'd' }; // Only has one static LetterU = 'g'; BabbleText(string[]) { new output[144], len, currpos; len = strlen(string); // Loop through string for(new i = 0; i < len; i++) { // Check for letter rules switch(string[i]) { // Found a letter that has an addition case 'a', 'e', 'i', 'o', 'u': { // Letter needs to be added no matter what output[currpos] = string[i]; // Chance of letter actually being added if(random(2) == 1) { // Only need to increment position if we actually need to replace currpos++; switch(string[i]) { case 'a': { output[currpos] = LetterA[random(strlen(LetterA))]; } case 'e': { output[currpos] = LetterE[random(strlen(LetterE))]; } case 'i': { output[currpos] = LetterI[random(strlen(LetterI))]; } case 'o': { output[currpos] = LetterO[random(strlen(LetterO))]; } // Only has one no need for random case 'u': { output[currpos] = LetterU; } } } } // No rule on letter default: { output[currpos] = string[i]; } } // Always increment current position currpos++; } return output; }
Consider this I have not tested it but pretty sure I got it right the rest is up to you to test and make sure it works right.
Код:
// Replacement rules (these can have any number of characters) static LetterA[3] = { 'g', 'h', 'd' }; static LetterE[3] = { 'g', 'h', 'd' }; static LetterI[3] = { 'g', 'h', 'd' }; static LetterO[3] = { 'g', 'h', 'd' }; // Only has one static LetterU = 'g'; BabbleText(string[]) { new output[144], len, currpos; len = strlen(string); // Loop through string for(new i = 0; i < len; i++) { // Check for letter rules switch(string[i]) { // Found a letter that has an addition case 'a', 'e', 'i', 'o', 'u': { // Letter needs to be added no matter what output[currpos] = string[i]; // Chance of letter actually being added if(random(2) == 1) { // Only need to increment position if we actually need to replace currpos++; switch(string[i]) { case 'a': { output[currpos] = LetterA[random(strlen(LetterA))]; } case 'e': { output[currpos] = LetterE[random(strlen(LetterE))]; } case 'i': { output[currpos] = LetterI[random(strlen(LetterI))]; } case 'o': { output[currpos] = LetterO[random(strlen(LetterO))]; } // Only has one no need for random case 'u': { output[currpos] = LetterU; } } } } // No rule on letter default: { output[currpos] = string[i]; } } // Always increment current position currpos++; } return output; } |
It's just a function.......... do your checks before calling this function.
|