Global Chat Help? -
Tass007 - 28.04.2016
Hi. I'm sure this is an easy as fix. But I'm making a global chat that doesn't have a range point on it. So it's global. I've created this:
PHP код:
new str[256], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
format(str, sizeof(str), "%s: {FFFFFF}%s", playername, text);
SendClientMessageToAll(DEFAULT_YELLOW, str);
However once I go ingame it displays:
Код:
[22:06:59] <Bob>: Test
[22:06:59]
[22:07:06] <Bob>: Test.
[22:07:06]
Any ideas? Also how would you possible make it like
Код:
[22:07:06] <Bob> {FF0000}[0] {FFFFFF}: Test.
As always whom ever successfully helps will get a +1 Rep.
Thanks in advance for your help.
Re: Global Chat Help? -
BloodyRP - 28.04.2016
PHP код:
new str[144], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
format(str, sizeof(str), "%s {FF0000}[%d]: {FFFFFF}%s", playername,playerid, text);
SendClientMessageToAll(DEFAULT_YELLOW, str);
Re: Global Chat Help? -
oMa37 - 28.04.2016
Change your code to this:
PHP код:
new str[256], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
format(str, sizeof(str), "%s{FF0000}[%d]: {FFFFFF}%s", playername, playerid, text);
SendClientMessageToAll(DEFAULT_YELLOW, str);
Always
BloodyRP faster than me :P
Re: Global Chat Help? -
Tass007 - 07.05.2016
That worked with the ID adding. Thank you. But I still keep getting the added enter after I press enter...
Код:
[15:47:01] BoB{FF0000}[0]: {FFFFFF}Test
[15:47:01]
[15:47:03] BoB{FF0000}[0]: {FFFFFF}Test
[15:47:03]
Any ideas?
Re: Global Chat Help? -
Sew_Sumi - 07.05.2016
What else have you got in that callback, because it'll be that.
Re: Global Chat Help? -
Tass007 - 07.05.2016
PHP код:
public OnPlayerText(playerid, text[])
{
// Anti Adv
if(AntiAdv(playerid, text)) return 0;
// The Rest
new string[128];
/*format(ircMsg, sizeof(ircMsg), "02[%d] 07%s: %s", playerid, RPN(playerid), text);
IRC_GroupSay(groupID, IRC_CHANNEL, ircMsg); */
if(Mobile[playerid] != INVALID_PLAYER_ID)
{
format(string, sizeof(string), "(Cellphone) %s says: %s", RPN(playerid), text);
if(IsPlayerInAnyVehicle(playerid)) { //Windows closed.
format(string, sizeof(string), "%s", string);
SendNearbyMessage(playerid, 3.0, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
} else {
SendNearbyMessage(playerid, 3.0, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
}
if(Mobile[playerid] == 914)
{
if(!text[0])
{
SendClientMessage(playerid, TEAM_CYAN_COLOR, "Dispatch: Sorry, I don't understand?");
return 0;
}
SendClientMessage(playerid, TEAM_CYAN_COLOR, "Dispatch: We have alerted all units in the area.");
SendClientMessage(playerid, TEAM_CYAN_COLOR, "Thank you for reporting this incident");
format(string, sizeof(string), "Dispatch: All Units IA: Caller: %s",RPN(playerid));
SendLSFMDMessage(COLOR_TWPINK, string);
format(string, sizeof(string), "Dispatch: Incident: %s",text);
SendLSFMDMessage(COLOR_TWPINK, string);
foreach(Player, i)
{
if(IsPlayerInRangeOfPoint(i, 100.0, 1498.6595,-2182.5081,14.1682) || IsPlayerInRangeOfPoint(i, 25.0, 2408.0505,-1330.7889,879.7735))
{
PlayAudioStreamForPlayer(i, "http://vc-rp.eu/firetone.mp3");
format(string, sizeof(string), "* The fire alarm tone rings out as a call comes in *");
SendClientMessage(i, ACTION, string);
}
}
CalledMedics[playerid] = 1;
MedicsCallTime[playerid] = 60;
ShowPlayerBeaconForMedics(playerid);
SendClientMessage(playerid, COLOR_WHITE, " They hung up...");
Mobile[playerid] = INVALID_PLAYER_ID;
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
RemovePlayerAttachedObject(playerid, 9);
return 0;
}
if(Mobile[playerid] == 913)
{
if(!text[0])
{
SendClientMessage(playerid, COLOR_ALLDEPT, "EMERGENCY: Sorry, I don't understand?");
return 0;
}
if(strcmp("no", text, true) == 0)
{
SendClientMessage(playerid, COLOR_DBLUE, "Police HQ: We have alerted all units in the area.");
SendClientMessage(playerid, COLOR_DBLUE, "Thank you for reporting this crime.");
format(string, sizeof(string), "HQ: All Units APB: Reporter: %s",RPN(playerid));
SendFBIMessage(COLOR_DBLUE, string);
SendCopMessage(COLOR_DBLUE, string);
format(string, sizeof(string), "HQ: Crime: %s, Suspect: Unknown",PlayerCrime[playerid][pAccusing]);
SendFBIMessage(COLOR_DBLUE, string);
SendCopMessage(COLOR_DBLUE, string);
CalledCops[playerid] = 1;
CopsCallTime[playerid] = 60;
ShowPlayerBeaconForCops(playerid);
SendClientMessage(playerid, COLOR_WHITE, " They hung up...");
Mobile[playerid] = INVALID_PLAYER_ID;
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
RemovePlayerAttachedObject(playerid, 9);
return 0;
}
new badguy = playerid;
if(IsPlayerConnected(badguy))
{
if(badguy != INVALID_PLAYER_ID)
{
if(PlayerInfo[badguy][pCrimes] > 0)
{
SendClientMessage(playerid, COLOR_DBLUE, "Police HQ: Units are already assigned to that case...");
SendClientMessage(playerid, COLOR_DBLUE, "Thank you for reporting this crime.");
SendClientMessage(playerid, COLOR_WHITE, " They hung up...");
Mobile[playerid] = INVALID_PLAYER_ID;
return 0;
}
if(badguy == playerid)
{
SendClientMessage(playerid, COLOR_DBLUE, "Police HQ: Don't fool around. This is an emergency line.");
SendClientMessage(playerid, COLOR_WHITE, " They hung up...");
Mobile[playerid] = INVALID_PLAYER_ID;
return 0;
}
SendClientMessage(playerid, COLOR_DBLUE, "Police HQ: We have alerted all units in the area.");
SendClientMessage(playerid, COLOR_DBLUE, "Thank you for reporting this crime.");
format(string, sizeof(string), "HQ: All Units APB: Reporter: %s",RPN(playerid));
SendFBIMessage(COLOR_DBLUE, string);
SendCopMessage(COLOR_DBLUE, string);
format(string, sizeof(string), "HQ: Crime: %s, Suspect: %s",PlayerCrime[playerid][pAccusing], RPN(badguy));
SendFBIMessage(COLOR_DBLUE, string);
SendCopMessage(COLOR_DBLUE, string);
CalledCops[playerid] = 1;
CopsCallTime[playerid] = 60;
ShowPlayerBeaconForCops(playerid);
SendClientMessage(playerid, COLOR_WHITE, " They hung up...");
Mobile[playerid] = INVALID_PLAYER_ID;
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
RemovePlayerAttachedObject(playerid, 9);
return 0;
}
return 0;
}
else
{
format(string, sizeof(string), "Police HQ: I have no information on %s, are you sure that's the correct name?",text);
SendClientMessage(playerid, COLOR_DBLUE, string);
return 0;
}
}
if(Mobile[playerid] == 912)
{
if(!text[0])
{
SendClientMessage(playerid, COLOR_ALLDEPT, "EMERGENCY: Sorry, I don't understand?");
return 0;
}
strmid(PlayerCrime[playerid][pAccusing], text, 0, strlen(text), 255);
SendClientMessage(playerid, COLOR_DBLUE, "Police HQ: If you know the assailant's name or part of it say it now or just say no.");
Mobile[playerid] = 913;
return 0;
}
if(Mobile[playerid] == 911)
{
if(!text[0])
{
SendClientMessage(playerid, COLOR_ALLDEPT, "EMERGENCY: Sorry, I don't understand - police or paramedic?");
return 0;
}
else if(strcmp("police", text, true) == 0)
{
SendClientMessage(playerid, COLOR_ALLDEPT, "EMERGENCY: I am patching you to police headquarters, please hold...");
Mobile[playerid] = 912;
SendClientMessage(playerid, COLOR_DBLUE, "Police HQ: Please give me a short description of the crime.");
return 0;
}
else if(strcmp("paramedic", text, true) == 0)
{
SendClientMessage(playerid, COLOR_ALLDEPT, "EMERGENCY: I am patching you to Medical Emergency Services headquarters, please hold...");
Mobile[playerid] = 914;
SendClientMessage(playerid, TEAM_CYAN_COLOR, "Dispatch: Please give me a short description of the incident.");
return 0;
}
else
{
SendClientMessage(playerid, COLOR_ALLDEPT, "EMERGENCY: Sorry, I don't understand - police or paramedic?");
return 0;
}
}
if(IsPlayerConnected(Mobile[playerid]))
{
if(Mobile[Mobile[playerid]] == playerid)
{
if(SpeakerPhone[playerid] != 0)
{
format(string, sizeof(string), "(speakerphone) %s says: %s", RPN(playerid), text);
SendNearbyMessage(Mobile[playerid], 3.0, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
}
else
{
SendClientMessage(Mobile[playerid], COLOR_YELLOW, string);
}
if(PlayerInfo[playerid][pBugged] == 1)
{
format(string, sizeof(string), "(bug) %s (cellphone): %s", RPN(playerid), text);
SendAdminMessage(COLOR_LIGHTGREEN, 1, string);
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "There's nobody there!");
CellTime[playerid] = 0;
SendClientMessage(playerid, COLOR_WHITE, " You hung up.");
Mobile[playerid] = INVALID_PLAYER_ID;
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
RemovePlayerAttachedObject(playerid, 9);
}
return 0;
}
else if(Live[playerid])
{
if(IsNewsVehicle(GetPlayerVehicleID(playerid)))
{
format(string, sizeof(string), "** [Live News]: %s: %s", RPN(playerid), text);
SendClientMessageToAll(COLOR_LIGHTGREEN, string);
/*format(ircMsg, sizeof(ircMsg), "3[Live News] %s(%d): %s", RPN(playerid), playerid, text);
IRC_GroupSay(groupID, IRC_CHANNEL, ircMsg); */
}
}
else
{
new str[256], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
format(str, sizeof(str), "%s{FF0000}[%d]: {FFFFFF}%s", playername, playerid, text);
SendClientMessageToAll(DEFAULT_YELLOW, str);
}
SendNearbyMessage(playerid, 10, string, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
Log("logs/chat.log", string);
return 0;
}
Re: Global Chat Help? -
jlalt - 07.05.2016
You're sending string at
PHP код:
SendNearbyMessage(playerid, 10, string, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
while string is empty, simple remove it or format the string >>
PHP код:
public OnPlayerText(playerid, text[])
{
// Anti Adv
if(AntiAdv(playerid, text)) return 0;
// The Rest
new string[128];
/*format(ircMsg, sizeof(ircMsg), "02[%d] 07%s: %s", playerid, RPN(playerid), text);
IRC_GroupSay(groupID, IRC_CHANNEL, ircMsg); */
if(Mobile[playerid] != INVALID_PLAYER_ID)
{
format(string, sizeof(string), "(Cellphone) %s says: %s", RPN(playerid), text);
if(IsPlayerInAnyVehicle(playerid)) { //Windows closed.
format(string, sizeof(string), "%s", string);
SendNearbyMessage(playerid, 3.0, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
} else {
SendNearbyMessage(playerid, 3.0, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
}
if(Mobile[playerid] == 914)
{
if(!text[0])
{
SendClientMessage(playerid, TEAM_CYAN_COLOR, "Dispatch: Sorry, I don't understand?");
return 0;
}
SendClientMessage(playerid, TEAM_CYAN_COLOR, "Dispatch: We have alerted all units in the area.");
SendClientMessage(playerid, TEAM_CYAN_COLOR, "Thank you for reporting this incident");
format(string, sizeof(string), "Dispatch: All Units IA: Caller: %s",RPN(playerid));
SendLSFMDMessage(COLOR_TWPINK, string);
format(string, sizeof(string), "Dispatch: Incident: %s",text);
SendLSFMDMessage(COLOR_TWPINK, string);
foreach(Player, i)
{
if(IsPlayerInRangeOfPoint(i, 100.0, 1498.6595,-2182.5081,14.1682) || IsPlayerInRangeOfPoint(i, 25.0, 2408.0505,-1330.7889,879.7735))
{
PlayAudioStreamForPlayer(i, "http://vc-rp.eu/firetone.mp3");
format(string, sizeof(string), "* The fire alarm tone rings out as a call comes in *");
SendClientMessage(i, ACTION, string);
}
}
CalledMedics[playerid] = 1;
MedicsCallTime[playerid] = 60;
ShowPlayerBeaconForMedics(playerid);
SendClientMessage(playerid, COLOR_WHITE, " They hung up...");
Mobile[playerid] = INVALID_PLAYER_ID;
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
RemovePlayerAttachedObject(playerid, 9);
return 0;
}
if(Mobile[playerid] == 913)
{
if(!text[0])
{
SendClientMessage(playerid, COLOR_ALLDEPT, "EMERGENCY: Sorry, I don't understand?");
return 0;
}
if(strcmp("no", text, true) == 0)
{
SendClientMessage(playerid, COLOR_DBLUE, "Police HQ: We have alerted all units in the area.");
SendClientMessage(playerid, COLOR_DBLUE, "Thank you for reporting this crime.");
format(string, sizeof(string), "HQ: All Units APB: Reporter: %s",RPN(playerid));
SendFBIMessage(COLOR_DBLUE, string);
SendCopMessage(COLOR_DBLUE, string);
format(string, sizeof(string), "HQ: Crime: %s, Suspect: Unknown",PlayerCrime[playerid][pAccusing]);
SendFBIMessage(COLOR_DBLUE, string);
SendCopMessage(COLOR_DBLUE, string);
CalledCops[playerid] = 1;
CopsCallTime[playerid] = 60;
ShowPlayerBeaconForCops(playerid);
SendClientMessage(playerid, COLOR_WHITE, " They hung up...");
Mobile[playerid] = INVALID_PLAYER_ID;
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
RemovePlayerAttachedObject(playerid, 9);
return 0;
}
new badguy = playerid;
if(IsPlayerConnected(badguy))
{
if(badguy != INVALID_PLAYER_ID)
{
if(PlayerInfo[badguy][pCrimes] > 0)
{
SendClientMessage(playerid, COLOR_DBLUE, "Police HQ: Units are already assigned to that case...");
SendClientMessage(playerid, COLOR_DBLUE, "Thank you for reporting this crime.");
SendClientMessage(playerid, COLOR_WHITE, " They hung up...");
Mobile[playerid] = INVALID_PLAYER_ID;
return 0;
}
if(badguy == playerid)
{
SendClientMessage(playerid, COLOR_DBLUE, "Police HQ: Don't fool around. This is an emergency line.");
SendClientMessage(playerid, COLOR_WHITE, " They hung up...");
Mobile[playerid] = INVALID_PLAYER_ID;
return 0;
}
SendClientMessage(playerid, COLOR_DBLUE, "Police HQ: We have alerted all units in the area.");
SendClientMessage(playerid, COLOR_DBLUE, "Thank you for reporting this crime.");
format(string, sizeof(string), "HQ: All Units APB: Reporter: %s",RPN(playerid));
SendFBIMessage(COLOR_DBLUE, string);
SendCopMessage(COLOR_DBLUE, string);
format(string, sizeof(string), "HQ: Crime: %s, Suspect: %s",PlayerCrime[playerid][pAccusing], RPN(badguy));
SendFBIMessage(COLOR_DBLUE, string);
SendCopMessage(COLOR_DBLUE, string);
CalledCops[playerid] = 1;
CopsCallTime[playerid] = 60;
ShowPlayerBeaconForCops(playerid);
SendClientMessage(playerid, COLOR_WHITE, " They hung up...");
Mobile[playerid] = INVALID_PLAYER_ID;
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
RemovePlayerAttachedObject(playerid, 9);
return 0;
}
return 0;
}
else
{
format(string, sizeof(string), "Police HQ: I have no information on %s, are you sure that's the correct name?",text);
SendClientMessage(playerid, COLOR_DBLUE, string);
return 0;
}
}
if(Mobile[playerid] == 912)
{
if(!text[0])
{
SendClientMessage(playerid, COLOR_ALLDEPT, "EMERGENCY: Sorry, I don't understand?");
return 0;
}
strmid(PlayerCrime[playerid][pAccusing], text, 0, strlen(text), 255);
SendClientMessage(playerid, COLOR_DBLUE, "Police HQ: If you know the assailant's name or part of it say it now or just say no.");
Mobile[playerid] = 913;
return 0;
}
if(Mobile[playerid] == 911)
{
if(!text[0])
{
SendClientMessage(playerid, COLOR_ALLDEPT, "EMERGENCY: Sorry, I don't understand - police or paramedic?");
return 0;
}
else if(strcmp("police", text, true) == 0)
{
SendClientMessage(playerid, COLOR_ALLDEPT, "EMERGENCY: I am patching you to police headquarters, please hold...");
Mobile[playerid] = 912;
SendClientMessage(playerid, COLOR_DBLUE, "Police HQ: Please give me a short description of the crime.");
return 0;
}
else if(strcmp("paramedic", text, true) == 0)
{
SendClientMessage(playerid, COLOR_ALLDEPT, "EMERGENCY: I am patching you to Medical Emergency Services headquarters, please hold...");
Mobile[playerid] = 914;
SendClientMessage(playerid, TEAM_CYAN_COLOR, "Dispatch: Please give me a short description of the incident.");
return 0;
}
else
{
SendClientMessage(playerid, COLOR_ALLDEPT, "EMERGENCY: Sorry, I don't understand - police or paramedic?");
return 0;
}
}
if(IsPlayerConnected(Mobile[playerid]))
{
if(Mobile[Mobile[playerid]] == playerid)
{
if(SpeakerPhone[playerid] != 0)
{
format(string, sizeof(string), "(speakerphone) %s says: %s", RPN(playerid), text);
SendNearbyMessage(Mobile[playerid], 3.0, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
}
else
{
SendClientMessage(Mobile[playerid], COLOR_YELLOW, string);
}
if(PlayerInfo[playerid][pBugged] == 1)
{
format(string, sizeof(string), "(bug) %s (cellphone): %s", RPN(playerid), text);
SendAdminMessage(COLOR_LIGHTGREEN, 1, string);
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "There's nobody there!");
CellTime[playerid] = 0;
SendClientMessage(playerid, COLOR_WHITE, " You hung up.");
Mobile[playerid] = INVALID_PLAYER_ID;
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
RemovePlayerAttachedObject(playerid, 9);
}
return 0;
}
else if(Live[playerid])
{
if(IsNewsVehicle(GetPlayerVehicleID(playerid)))
{
format(string, sizeof(string), "** [Live News]: %s: %s", RPN(playerid), text);
SendClientMessageToAll(COLOR_LIGHTGREEN, string);
/*format(ircMsg, sizeof(ircMsg), "3[Live News] %s(%d): %s", RPN(playerid), playerid, text);
IRC_GroupSay(groupID, IRC_CHANNEL, ircMsg); */
}
}
else
{
new str[256], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
format(str, sizeof(str), "%s{FF0000}[%d]: {FFFFFF}%s", playername, playerid, text);
SendClientMessageToAll(DEFAULT_YELLOW, str);
}
format(string,sizeof string,text);
SendNearbyMessage(playerid, 10, string, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
Log("logs/chat.log", string);
return 0;
}
Re: Global Chat Help? -
Dayrion - 07.05.2016
PHP код:
public OnPlayerText(playerid, text[])
[...]
else
{
new str[256], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
format(str, sizeof(str), "%s{FF0000}[%d]: {FFFFFF}%s", playername, playerid, text);
SendClientMessageToAll(DEFAULT_YELLOW, str); // -> 1 message
}
SendNearbyMessage(playerid, 10, string, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5); // -> second message
Log("logs/chat.log", string);
return 0;
}
Aren't you sending 2 times a message ? I'm maybe wrong.
Re: Global Chat Help? -
PrO.GameR - 07.05.2016
return SendClientMessageToAll(DEFAULT_YELLOW, str); so the code in the callback won't follow or simply remove the last SendNearbyMessage after your chat.
Re: Global Chat Help? -
Sew_Sumi - 07.05.2016
As jlalt said, string is empty. and it's still sending SendNearbyMessage (Which is simply a renamed ProxDetector).
You also don't need 256 strings because the client can only display 144 characters.
Rather than using your "str", "string" was already defined in the beginning of the callback.