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)
+--- Thread: Onplayertext (/showthread.php?tid=486568)



Onplayertext - Acres - 09.01.2014

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);



Re: Onplayertext - offon - 09.01.2014

Код:
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.


Re: Onplayertext - Acres - 09.01.2014

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


Re: Onplayertext - Hansrutger - 09.01.2014

Код:
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


Re: Onplayertext - Konstantinos - 09.01.2014

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);