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=178297)
OnPlayertext -
NeverKnow - 21.09.2010
Hello all,
i want to make a thing so when you talk in chat that it shows ur ID.
i did this code but dont working
new name[128];
GetPlayerName(playerid, name, sizeof(name));
new string[128];
format(string, sizeof(string), "%s( %s): %s", name, playerid, text);
SendClientMessage(playerid, GetPlayerColor(playerid), text);
I hope someone can help me.
Thanks!
Re: OnPlayertext -
Mauzen - 21.09.2010
the '%s' placeholders are for strings only. Use %d in the brackets, to insert an integer (playerid)
For more info check this page on the wiki:
https://sampwiki.blast.hk/wiki/Format
Edit: You will also have to return 0 in OnPlayerText, or the normal chattext will be shown too.
Re: OnPlayertext -
Rachael - 21.09.2010
something like this
pawn Код:
public OnPlayerText(playerid, text[])
{
new name[MAX_PLAYER_NAME];
new string[128];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s( %d) says: %s", name, playerid, text);
new Float:x1,Float:y1,Float:z1
GetPlayerPos(playerid,x1,y1,z1);
for(new i = 0; i < MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
Float:x2,Float:y2,Float:z2;
GetPlayerPos(i,x2,y2,z2);
if(GetPlayerInterior(playerid) == GetPlayerInterior(i))
{
new Float:dist = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
if(dist < 20)
{
SendClientMessage(i,0xAFAFAFAA,string);
}
}
}
}
return 0;
}
Re: OnPlayertext -
NeverKnow - 22.09.2010
Quote:
Originally Posted by Rachael
something like this
pawn Код:
public OnPlayerText(playerid, text[]) { new name[MAX_PLAYER_NAME]; new string[128]; GetPlayerName(playerid, name, sizeof(name)); format(string, sizeof(string), "%s( %d) says: %s", name, playerid, text); new Float:x1,Float:y1,Float:z1 GetPlayerPos(playerid,x1,y1,z1); for(new i = 0; i < MAX_PLAYERS;i++) { if(IsPlayerConnected(i)) { Float:x2,Float:y2,Float:z2; GetPlayerPos(i,x2,y2,z2); if(GetPlayerInterior(playerid) == GetPlayerInterior(i)) { new Float:dist = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2)); if(dist < 20) { SendClientMessage(i,0xAFAFAFAA,string); } } } } return 0; }
|
This is not working

but thanks for the help
Re: OnPlayertext -
Vince - 22.09.2010
Quote:
Originally Posted by Rachael
something like this
|
He's not asking for some roleplay text thing.
This is simple, and should work without any further changes:
pawn Код:
public OnPlayerText(playerid, text[])
{
new
str[128];
format(str, sizeof(str), "(%d): %s", playerid, text);
SendPlayerMessageToAll(playerid, str);
return 0;
}
Re: OnPlayertext -
NeverKnow - 03.10.2010
Quote:
Originally Posted by Vince
He's not asking for some roleplay text thing.
This is simple, and should work without any further changes:
pawn Код:
public OnPlayerText(playerid, text[]) { new str[128];
format(str, sizeof(str), "(%d): %s", playerid, text); SendPlayerMessageToAll(playerid, str); return 0; }
|
Thanks Man this is working fine only when i type in Mainchat i get 2 Texts
Re: OnPlayertext -
playbox12 - 03.10.2010
Are you sure you completely replaced it? because it must be return 0; and not 1; otherwise it will send it double (one normal one cutsom)