Onplayertext
#1

Hey guys could i get help with this problem onplayertext whats wrong with it is that if i talk in chat usiing "t" normal chat as making freeroam server then how i can make this to make in one line because if i talk in game Ex: Shark Player: and then next line is Shark: asasad...

heres the code
Код:
    new textv2[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    format(textv2, sizeof (textv2), "{00FF00}Player{FFFFFF} %s:", playerid, name, text);
    SendPlayerMessageToAll(playerid, textv2);
Reply
#2

Код:
new textv2[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof (name));
format(textv2, sizeof (textv2), "{00FF00}Player{FFFFFF} %s: %s", playerid, name, text);
SendPlayerMessageToAll(playerid, textv2);
If you don't have return 0; in OnPlayerText, but instead have return 1; change it to 0.
Reply
#3

hmm thats weird it worked though but it like tells my name what ever i write....
Reply
#4

Код:
format(textv2, sizeof (textv2), "{00FF00}Player{FFFFFF} %s: %s", name, text);
You added "playerid" for some reason. Playerid is a number not a string and I assume you want to print out "name" and not the player id. :P
Reply
#5

As offon said, you should return 0 at the end of the callback so it will prevent the default chat from being sent. Although, this is not the only problem. SA-MP Wiki has an incorrect code and it's not corrected. Player Message start with the player's name and the color and the rest are white. The rest are the playerid and the text because the name is already given by the function itself.

I don't know what exactly you want to display to the screen but an example (with what you've shown so far) would be:
pawn Код:
new textv2[128];
format(textv2, sizeof (textv2), "(%i): %s", playerid, text);
SendPlayerMessageToAll(playerid, textv2);
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)