SA-MP Forums Archive
chat problem - 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: chat problem (/showthread.php?tid=222509)



chat problem - omer5198 - 07.02.2011

hi i made this code that supose to do teh chat like [omer5198]: TEXT [id:0 | Player] (or if the player is admin then Player>Admin...) but it doesn't write anything ingame... it just says the usual : omer5198: TEXT
so plz help...
b.t.w: sorry for my bad english.
code:
PHP код:
public OnPlayerText(playeridtext[])
{
new 
chater[128], chat[128];
if(
IsPlayerAdmin(playerid)){
format(chatsizeof(chat), "[%s]: %d [id:%d | Admin]"chatertextplayerid);
}
else
{
GetPlayerName(playeridchatersizeof(chater));
format(chatsizeof(chat), "[%s]: %d [id:%d | Player]"chatertextplayerid);
}
    return 
1;




Re: chat problem - alpha500delta - 07.02.2011

Well, you need to use a loop in order to send it to everyone, and you need a function I forgot lol... I believe it was "SendPlayerMessageToAll"


Re: chat problem - JaTochNietDan - 07.02.2011

Simply because "text" is a string, and you are trying to format it in the string as an integer, you need to format it as a string for it to be formatted correctly!

pawn Код:
format(chat, sizeof(chat), "[%s]: %s [id:%d | Admin]", chater, text, playerid);
Additionally you don't even send the message anywhere, I assume you want it to be sent to all players? Well then use the following:

pawn Код:
SendClientMessageToAll(color,chat);
Also you should consider using return 0; in OnPlayerText, otherwise the normal text will be passed to the chatbox as normal.


Re: chat problem - alpha500delta - 07.02.2011

By the way use return 0; because now admin is going to recieve all chats 2x


- omer5198 - 07.02.2011

thx but now i got another problem... i will open a new thread

hi... i have another problem with my chat... when i type something it says []RANDOMNUMBER [id:id | player/Admin]
[] - in here it suppose to write the player's name
RANDOMNUMBER - was suppose to be the text... no metter what i write even agalhjshjskh it just write a random number...
the id is fine and admin/player is fine... another thing that its write the ^^ but it writes the orginal thing too : NAME: TEXT
code :
PHP код:
public OnPlayerText(playeridtext[])
{
new 
chater[128], chat[128];
new 
playercolor GetPlayerColor(playerid);
if(
IsPlayerAdmin(playerid)){
format(chatsizeof(chat), "[%s]: %d [id:%d | Admin]"chatertextplayerid);
SendClientMessageToAll(playercolorchat);
}
else
{
GetPlayerName(playeridchatersizeof(chater));
format(chatsizeof(chat), "[%s]: %d [id:%d | Player]"chatertextplayerid);
SendClientMessageToAll(playercolorchat);
}
    return 
1;

there are no errors... only 2 warning... ( of loosing indentation )
photo:



Re: another chat problem - JaTochNietDan - 07.02.2011

Did you read what I said in the last topic? You are trying to format the text variable into that string as an integer, but it's a string that contains the text you are typing into the chat, like I said already you need to format it as a string!

pawn Код:
format(chat, sizeof(chat), "[%s]: %s [id:%d | Admin]", chater, text, playerid);
Also don't create a topic for the same discussion, I will merge both of these topics.


Re: chat problem - omer5198 - 07.02.2011

thx but it still write the [NAME] TEXT [ID || PLAYER/ADMIN] &&&&&&&&& NAME : TEXT
but i dont want &&&& NAME : TEXT to be seen... only [NAME] TEXT [ID || PLAYER/ADMIN]... look at the photo and you will understand... another thing is that when i write(else if i change the color with an admin command) it write in black... in the picture i did the /visible command... plz help


Re: chat problem - HyperZ - 07.02.2011

Try this:
pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128];
    new playercolor = GetPlayerColor(playerid);
    if(IsPlayerAdmin(playerid))
    {
        new aName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, aName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "[%s]: %s [id:%d | Admin]", aName, text, playerid);
        SendClientMessageToAll(playercolor, string);
    }
    else
    {
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "[%s]: %s [id:%d | Player]", pName, text, playerid);
        SendClientMessageToAll(playercolor, string);
    }
    return 0;
}



Re: chat problem - omer5198 - 07.02.2011

thx now you can see the name but you are helping me to fix the problems one at a time... cant you just fix it all at ones? it still do the:
[omer5198] TEXT [id:0 | Player/Admin]
And
omer5198: TEXT
... how can i do that only the " [omer5198] TEXT [id:0 | Player/Admin] " will save? and the "omer5198: TEXT" will nto be seen?


Re: chat problem - JaTochNietDan - 07.02.2011

Quote:
Originally Posted by omer5198
Посмотреть сообщение
thx now you can see the name but you are helping me to fix the problems one at a time... cant you just fix it all at ones? it still do the:
[omer5198] TEXT [id:0 | Player/Admin]
And
omer5198: TEXT
... how can i do that only the " [omer5198] TEXT [id:0 | Player/Admin] " will save? and the "omer5198: TEXT" will nto be seen?
I don't think you realize, I answered every one of your questions in my first post in this topic! Including the one you're asking right now. Try reading it again.