Chat ID Fix -
Sting. - 16.08.2014
Do you guys have any idea how to fix this? The silly thing is that I didn't fix it last time. I can't even remember where I put the code for the ID to appear. It was a coon's age.....
Here's a screenshot,
Do you guys know how to move the ID number back to the name like this:
Sting(0):?
Help will be much
appreciated.
Re: Chat ID Fix -
biker122 - 16.08.2014
check your OnPlayerText callback
Re: Chat ID Fix -
SyneR - 16.08.2014
%s(%d): %s and arguments variablePlayerName, playerid, msg
in OnPlayerText callback find format and change it
AW: Chat ID Fix -
Mellnik - 16.08.2014
Chat messages are handled in
.
Re: Chat ID Fix -
Sting. - 16.08.2014
Код:
new string[256], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "{FFFF00}(%i){FFFFFF} %s",playerid, text);
SendPlayerMessageToAll(playerid,string);
That's exactly in my OnPlayerText, what do I
change now?
Re: Chat ID Fix -
biker122 - 16.08.2014
Do you ONLY have this much? or do you still have some more?
I really don't see the player name getting formatted here but on the msg it shows with the name..
Re: Chat ID Fix -
Sting. - 16.08.2014
Alright I have that OnPlayerText, I also have this but this is on OnPlayerCommandText. Its a team message thing. (/t )
Код:
new idx,cmd[128];
cmd = strtok(cmdtext,idx);
if(strcmp("/t",cmd,true) == 0 || strcmp("/team",cmd,true) == 0)
{
new pName[MAX_PLAYER_NAME],formatted[156];
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[128];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result)) return SendClientMessage(playerid,-1,"Usage: /t(eam) text");
GetPlayerName(playerid,pName,sizeof(pName));
format(formatted,sizeof(formatted),"[Team]: %s(%d): %s",pName,playerid,result);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(GetPlayerTeam(i) == GetPlayerTeam(playerid))
{
SendClientMessage(i,-1,formatted);
}
}
return 1;
}
return 0;
I found other parts in my server which contains a name change but I thought its necessary to show. Next, I have a command to teleport to Verdant Meadows. (/ay)
Код:
if(!strcmp(cmdtext,"/ay",true))
{
SetPlayerPos(playerid,389.5595,2536.3604,16.5391);
GameTextForPlayer(playerid, "~g~Welcome to the Air Yard!", 2500, 0);
SendClientMessage(playerid, 0x33CCFFAA, "You successfully teleported to the Air Yard!");
new Name[MAX_PLAYER_NAME],
string[128];
GetPlayerName(playerid, Name, sizeof(Name));
format(string, sizeof(string), "%s has teleported to the Air Yard over at Verdant Meadows!", Name);
SendClientMessageToAll(0x33CCFFAA, string);
return 1;
}
And last one is top kills one.... when a player has more than 6 kills, it announces....
Код:
if(TopKills == 6)
{
SendClientMessage(killerid,0x00ff00ff,"Wow you're a killer!");
GameTextForPlayer(playerid, "Super Killer!", 3000, 1);
GivePlayerMoney(killerid,10000);
SetPlayerScore(killerid, GetPlayerScore(killerid)+50);
new Name[MAX_PLAYER_NAME], // Name
string[128];
GetPlayerName(killerid, Name, sizeof(Name));
format(string, sizeof(string), "The killer named %s has just made his way to the top!", Name);
SendClientMessageToAll(0x33CCFFAA, string);
TopKills = 0;
}
return 1;
That's all the chat id's I have in my server.
Re: Chat ID Fix -
Affan - 16.08.2014
You have to set a player's color first.
pawn Код:
public OnGameModeInit()
{
SetPlayerColor(playerid, COLOR_RED); // Change to your preference
return 1;
}
public OnPlayerText(playerid, text[])
{
new name[MAX_PLAYER_NAME], str[256];
GetPlayerName(playerid, name, sizeof(name));
format(str, sizeof(str), "%s[%d]: {FFFFFF}%s", name, playerid, text);
SendClientMessageToAll(GetPlayerColor(playerid), str);
return 1;
}
Re: Chat ID Fix -
Sting. - 16.08.2014
The color is set for me at on PlayerClass selection, so if I pick team A, but haven't spawn yet, but talk in chat... my name is red. Then I switch over to team B, the color is blue, it works like that. Is there a getplayercolor way or something like that?
Re: Chat ID Fix -
Stinged - 16.08.2014
As long as the player color was changed with SetPlayerColor, it will work.
You can also use this:
pawn Код:
format(str, sizeof(str), "{%06x}%s[%d]: {FFFFFF}%s", GetPlayerColor(playerid) >>> 8, name, playerid, text);
SendClientMessageToAll(-1, str);
If you like it to look like the normal chat but with id.