Clan chat -
ThaCrypte - 19.10.2013
I need help with my clan chat. Everyone who's not in a clan can see it, while it should show only for clan members.
PlayerInfo[i][pClan] = cid;
if(PlayerInfo[i][pClan] == cid)
Should detect if the player is in a clan and send the message to his clan members. (I'm not that good with foreach, so sorry if I'm making a major failure :$.
pawn Код:
stock SendClanMessage(color, string[])
{
foreach(Player, i)
{
new cid;
PlayerInfo[i][pClan] = cid;
if(PlayerInfo[i][pClan] == cid)
{
SendClientMessage(i, color, string);
}
}
return 1;
}
pawn Код:
CMD:c(playerid,params[])
{
new string[128];
if(PlayerInfo[playerid][pClan] < 1) return SendClientMessage(playerid, COLOR_REDD, "[ERROR] You are not in a clan!");
if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_LGREEN, "Usage: /c [text]");
format(string, sizeof(string), "[CLAN] %s: {FFFFFF}%s", PLAYERNAME(playerid), params);
SendClanMessage(COLOR_AMERICA, string);
return 1;
}
Re: Clan chat -
SilentSoul - 19.10.2013
Try that
pawn Код:
stock SendClanMessage(text[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
new cid;
PlayerInfo[i][pClan] = cid;
if(PlayerInfo[i][pClan] == cid)
{
SendClientMessage(i, color, string);
}
}
}
sorry about that edited
Re: Clan chat -
ThaCrypte - 19.10.2013
Quote:
Originally Posted by SilentSoul
Try that
pawn Код:
stock SendMessageToAdmins(text[]) { for(new i = 0; i < MAX_PLAYERS; i++)
{ new cid; PlayerInfo[i][pClan] = cid; if(PlayerInfo[i][pClan] == cid) { SendClientMessage(i, color, string); } } }
|
Isn't that the same thing? Also it's clan chat, not admin chat xDDD
Re: Clan chat -
HardRock - 19.10.2013
Try....
PHP код:
stock SendClanMessage(color, string[])
{
foreach(Player, i)
{
if(PlayerInfo[i][pClan] == 1)// And if player is not in clan hes pClan be '0'.
{
SendClientMessage(i, color, string);
}
}
return 1;
}
Re: Clan chat -
ThaCrypte - 19.10.2013
Quote:
Originally Posted by HardRock
Try....
PHP код:
stock SendClanMessage(color, string[])
{
foreach(Player, i)
{
if(PlayerInfo[i][pClan] == 1)// And if player is not in clan hes pClan be '0'.
{
SendClientMessage(i, color, string);
}
}
return 1;
}
|
There are 15 clans in total, this will only have clan id 1 have a clan chat.
Re: Clan chat -
HardRock - 19.10.2013
PHP код:
stock SendClanMessage(color, string[])
{
foreach(Player, i)
{
if(PlayerInfo[i][pClan] >= 1)
{
SendClientMessage(i, color, string);
}
}
return 1;
}
or
PHP код:
stock SendClanMessage(color, clanid, string[])
{
foreach(Player, i)
{
if(PlayerInfo[i][pClan] == clanid)
{
SendClientMessage(i, color, string);
}
}
return 1;
}
Re: Clan chat -
ThaCrypte - 19.10.2013
Quote:
Originally Posted by HardRock
PHP код:
stock SendClanMessage(color, string[])
{
foreach(Player, i)
{
if(PlayerInfo[i][pClan] >= 1)
{
SendClientMessage(i, color, string);
}
}
return 1;
}
or
PHP код:
stock SendClanMessage(color, clanid, string[])
{
foreach(Player, i)
{
if(PlayerInfo[i][pClan] == clanid)
{
SendClientMessage(i, color, string);
}
}
return 1;
}
|
Above one wont work, as it will send a clan message to all clans, and not to only clan members, not sure about the second one because i can't test it atm. I think it won't work.
Re: Clan chat -
HardRock - 19.10.2013
Do you change SendClanMessage(color, string[]) to SendClanMessage(color, clanid, string[]) in your script?
//Edit:
Try this....
PHP код:
stock SendClanMessage(color, string[])
{
foreach(Player, i)
{
if(PlayerInfo[i][pClan] == PlayerInfo[playerid][pClan])
{
SendClientMessage(i, color, string);
}
}
return 1;
}
Re: Clan chat -
ThaCrypte - 19.10.2013
Quote:
Originally Posted by HardRock
Do you change SendClanMessage(color, string[]) to SendClanMessage(color, clanid, string[]) in your script?
//Edit:
Try this....
PHP код:
stock SendClanMessage(color, string[])
{
foreach(Player, i)
{
if(PlayerInfo[i][pClan] == PlayerInfo[playerid][pClan])
{
SendClientMessage(i, color, string);
}
}
return 1;
}
|
Won't even let me compile.
// edit
Say's empty statement to : SendClanMessage(COLOR_AMERICA, string);
Re: Clan chat -
TonyII - 19.10.2013
Do you have the foreach include? Or just replace it with this - for(new i = 0; i < MAX_PLAYERS; i++)