Posts: 252
Threads: 16
Joined: Jun 2012
Hey, I've made a little snippet of code to change my server's admin's public chat color, but everytime I try to use it, I get 2 messages sent, and they aren't even setting the color, and yes, I have return 0; at the end, did I mess something up in my code?
Код:
if(PlayerInfo[playerid][pAdmin] > 1)
{
new output[128];
new pcol = GetPlayerColor(playerid);
SetPlayerColor(playerid, pcol);
format(output, sizeof(output), "%s(%i):{00FF00} %s", playerid, text);
SendPlayerMessageToAll(playerid, output);
session[messages] = session[messages] + 1;
return 0;
}
Or should I try it like it says in the Wiki?
https://sampwiki.blast.hk/wiki/OnPlayerText
Posts: 252
Threads: 16
Joined: Jun 2012
Quote:
Originally Posted by Shetch
Код:
new output[128], name[MAX_PLAYER_NAME];
new pcol = GetPlayerColor(playerid);
SetPlayerColor(playerid, pcol);
GetPlayerName(playerid, name, sizeof(name));
format(output, sizeof(output), "%s(%d):{00FF00} %s", name, playerid, text);
SendPlayerMessageToAll(playerid, output);
session[messages] = session[messages] + 1;
|
Still doesn't work, and it sends two messages into the chat, and it does something weird with the second message though, it adds my name twice, one in black, and one in white,**Thats caused becuase GetPlayerColor isn't working, for some odd reason**
Picture
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
SendPlayerMessage already incorporates the player's name, so you don't need to fetch it again. Also GetPlayerColor doesn't work if SetPlayerColor hasn't been used before. It says that on the wiki page.
Posts: 1,905
Threads: 63
Joined: Oct 2011
Reputation:
0
I'm not sure what sends them twice, but GetPlayerColor returns 0 if SetPlayerColor hasn't been used.
EDIT: I'm late^
Posts: 252
Threads: 16
Joined: Jun 2012
Quote:
Originally Posted by Vince
SendPlayerMessage already incorporates the player's name, so you don't need to fetch it again. Also GetPlayerColor doesn't work if SetPlayerColor hasn't been used before. It says that on the wiki page.
|
Oh Okay, That makes sense, Guess I'll have to make a player color save feature, and when he joins, it will set the saved color, and I found out something else, I had to edit something else in the script, because it was conflicting with the code above
Problem Solved, Thanks for your help guys. + Rep