Playerid
#1

How to make that when a People type what and he send it in the chat, that the ID is too screened? Like "Blackazur (0): test".
Reply
#2

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128];
    format(string, sizeof(string), "%s(%d): %s" GetName(playerid), playerid, text);
    SendClientMessageToAll(-1, string);
    return 0;
}
Add this stock anywhere in your script.
Код:
stock GetName(playerid)
{
    new
        name[24];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
Reply
#3

error 001: expected token: "-string end-", but found "-identifier-"
warning 215: expression has no effect
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

On this line:
Quote:

format(string, sizeof(string), "%s(%d): %s" GetName(playerid), playerid, text);

Reply
#4

You are missing a comma after the format of the string.
Reply
#5

Worked, thx. But all Names are now in White, how can i change that to my Colors on my Script?
Reply
#6

Remove the "stock GetName(playerid)" and "public OnPlayerText(playerid,text[])" and put this callback:
pawn Код:
public OnPlayerText(playerid,text[])
{
        new string[256];
        format(string, sizeof(string), "{FFFF00}(%i):{FFFFFF} %s",playerid, text);
        SendPlayerMessageToAll(playerid,string);
        return 0;
}
Reply
#7

You forgot to include the name in the format string and to pass it.
Reply
#8

DuRex code work fine. What do you mean Bakr? I tried it and my name was like: RTR: (0): I love SA-MP!

What's the problem with the code?
Reply
#9

Quote:
Originally Posted by Bakr
Посмотреть сообщение
You forgot to include the name in the format string and to pass it.
SendPlayerMessageToAll is different. You don't need to put the name in the string.
More informations here: https://sampwiki.blast.hk/wiki/SendPlayerMessageToAll

Quote:
Originally Posted by RTR12
Посмотреть сообщение
DuRex code work fine. What do you mean Bakr? I tried it and my name was like: RTR: (0): I love SA-MP!

What's the problem with the code?
Remove the points in the string. It should show like this RTR: (0) I love SA-MP!
Reply
#10

Quote:
Originally Posted by Windows32
Посмотреть сообщение
pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128];
    format(string, sizeof(string), "%s(%d): %s" GetName(playerid), playerid, text);
    SendClientMessageToAll(-1, string);
    return 0;
}
Add this stock anywhere in your script.
Код:
stock GetName(playerid)
{
    new
        name[24];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
Why are you unnecessarily creating a stock? Just GetPlayerName with a pname var of MAX_PLAYER_NAME size is enough..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)