OnPlayerText
#1

Код:
if(strfind(text, "(", true) != -1)
	{
    new length = strlen(text);
	  while ((idx < length) && (text[idx] <= ' '))
    {
				idx++;
	  }
	  new offset = idx;
	  new result[64];
	  while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
	  {
				result[idx - offset] = text[idx];
				idx++;
	  }
	  result[idx - offset] = EOS;
    GetPlayerName(playerid, sendername, sizeof(sendername));
	  format(string, sizeof(string), "%s : (( %s ))", sendername, result);
	  ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
	  printf("%s", string);
		return 0;
	}
i got result like this:
name_surname : (( (text ))
Reply
#2

Cool?

So what's the problem?
Reply
#3

Listen.I use it for ooc.I am sick of /b. simple

input:
(whats up

outpit:
Michael_Corleone : (((whats up))

there is a "(" bracket that is unussed.I cant get rid off it.
anyone has idea how to solve ?
Reply
#4

Why don't you just take out one of the other brackets?

pawn Код:
format(string, sizeof(string), "%s : ( %s ))", sendername, result);
Like that...
Reply
#5

you simple , use this form

pawn Код:
if(text[0] == '(' ) { /* .... */ }
don't use strfind , because if you use it , text can 'blow'

if you type : He is gay ( joking ) the computer will find the bracket (
Reply
#6

I think it will not work but try xD

pawn Код:
public OnPlayerText(playerid,text[])
{
    for(new i;i < strlen(text) < i++;)
    {
        if(i == 1 && !strcmp(text[i],"(",false))
        {
            text[i] = ' ';
            // Your code for sending message here
        }
    }
}
Reply
#7

omg,i am so stupid guys
ahhaha works great now xD
Reply
#8

Quote:
Originally Posted by Naruto4
omg,i am so stupid guys
ahhaha works great now xD
My code works, or you write your own? :P
Reply
#9

Quote:
Originally Posted by Luka™
I think it will not work but try xD

pawn Код:
public OnPlayerText(playerid,text[])
{
    for(new i;i < strlen(text) < i++;)
    {
        if(i == 1 && !strcmp(text[i],"(",false))
        {
            text[i] = ' ';
            // Your code for sending message here
        }
    }
}
Man you got the chance to win the "the most ineffective code ever award"

here would be another solution instead of changing an array element

pawn Код:
if(text[0] == '(')
{
    new string[(136 + MAX_PLAYER_NAME)];
    GetPlayerName(playerid, string, MAX_PLAYER_NAME);
    format(string, sizeof string, "%s : (( %s ))", string, text[1]);
    ProxDetector(20.0, playerid, string, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
    return print(string);
}
Reply
#10

Quote:
Originally Posted by ♣ ⓐⓢⓢ
Quote:
Originally Posted by Luka™
I think it will not work but try xD

pawn Код:
public OnPlayerText(playerid,text[])
{
    for(new i;i < strlen(text) < i++;)
    {
        if(i == 1 && !strcmp(text[i],"(",false))
        {
            text[i] = ' ';
            // Your code for sending message here
        }
    }
}
Man you got the chance to win the "the most ineffective code ever award"

here would be another solution instead of changing an array element

pawn Код:
if(text[0] == '(')
{
    new string[(136 + MAX_PLAYER_NAME)];
    GetPlayerName(playerid, string, MAX_PLAYER_NAME);
    format(string, sizeof string, "%s : (( %s ))", string, text[1]);
    ProxDetector(20.0, playerid, string, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
    return print(string);
}
Thank you, but I have few "The Most Ineffective Code" awards already !
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)