unintelligible muttering whilst gagged
#1

So I've made a command to /gag players which currently completely mutes them, but I'd rather have it so that they speak in a very low range ( using proxdetector ) and that they still mutter their sentence but with some stuff in it, ex:

Player types: Ungag me.

In chat this appears: Ungahg meh..

Is this possible, and if so, how?

I've been trying with OnPlayerText but I don't think I'm using the right function.
Reply
#2

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.
Reply
#3

Quote:
Originally Posted by Logic_
Посмотреть сообщение
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.
I'd prefer if it worked for anything and it wasn't limited to a couple of sentences though.
Reply
#4

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;
}
Reply
#5

Quote:
Originally Posted by Pottus
Посмотреть сообщение
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;
}
Where would I put this code? I also can't find where it checks for if a player is gagged or not.. To be honest, I don't understand the code at all Please assist me some more, thanks so far.
Reply
#6

It's just a function.......... do your checks before calling this function.
Reply
#7

Quote:
Originally Posted by Pottus
Посмотреть сообщение
It's just a function.......... do your checks before calling this function.
It seems like the random part of your function isn't working properly. It causes the script to sometimes take the vanilla samp message, and sometimes take the custom message with %s says: %s. ( example screenshot below: )

Chatting works perfectly fine when you aren't gagged.

I've tried to fix it but haven't managed yet... So I'm still stuck with the original code you provided.
Reply
#8

That just gives a chance that it will actually do something. You can remove that random or change the chances of it actually happening.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)