SA-MP Forums Archive
OnPlayerText - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: OnPlayerText (/showthread.php?tid=220079)



OnPlayerText - Unknown123 - 03.02.2011

When i use the code like this, then the "Try to short down your text, Please" work (but not the code under)
pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128];
    if(text[72] > 72)
    {
        SendClientMessage(playerid, 0xFF0000FF, "Try to short down your text, Please");
        return 0;
    }
   
    //(code under)
    format(string, sizeof(string), "(%d) %s", playerid, text);
    SendPlayerMessageToAll(playerid, string);
    return 0;
}
If i use the colde like this:
Then the "Unknown: (0) Yoo wazzup.
work
pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128];
    /*if(text[72] > 72)
    {
        SendClientMessage(playerid, 0xFF0000FF, "Try to short down your text, Please");
        return 0;
    }*/

   
    //(code under)
    format(string, sizeof(string), "(%d) %s", playerid, text);
    SendPlayerMessageToAll(playerid, string);
    return 0;
}
//look under "//code under" ther is my code
i want it to work like this:
Unknown(0): Your text...

but now it is like this
Unknown: (0) Your text...


Re: OnPlayerText - Krx17 - 03.02.2011

pawn Код:
if(text[72] > 72)
should be
pawn Код:
if(strlen(text) > 72)



Re: OnPlayerText - Unknown123 - 03.02.2011

Quote:
Originally Posted by Krx17
Посмотреть сообщение
pawn Код:
if(text[72] > 72)
should be
pawn Код:
if(strlen(text) > 72)
Thanks, You know how to fix chat too?

Unknown(0): Yoo Wazzup!


Re: OnPlayerText - Scenario - 03.02.2011

Try this:

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128], pName[MAX_PLAYER_NAME];
    if(strlen(text) > 72)
    {
        SendClientMessage(playerid, 0xFF0000FF, "Try to short down your text, Please");
        return 0;
    }

    GetPlayerName(playerid, pName, sizeof(pName));
    format(string, sizeof(string), "%s(%d): %s", pName, playerid, text);
    SendClientMessageToAll(COLOR_WHITE, string);
    return 0;
}



Re: OnPlayerText - Unknown123 - 03.02.2011

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Try this:

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128], pName[MAX_PLAYER_NAME];
    if(strlen(text) > 72)
    {
        SendClientMessage(playerid, 0xFF0000FF, "Try to short down your text, Please");
        return 0;
    }

    GetPlayerName(playerid, pName, sizeof(pName));
    format(string, sizeof(string), "%s(%d): %s", pName, playerid, text);
    SendClientMessageToAll(COLOR_WHITE, string);
    return 0;
}
Thnx