11.02.2009, 19:52
oh, well you'll need to be able to recognise what a clantag is, let's just presume it's always the first bit of a players name.. like.. [CLAN]PlayerName, and can only be of this type: [TAG] (most are)
something like that
Код:
stock GetPlayerClanTag(playerid) // I like this function name much more
{
new playername[32], clantag[5];
GetPlayerName(playerid,playername,32);
// why not bigger than 4? some people have their names in brackets, just a filter,also fits nicely with the clantag string atm
if (strfind(playername, "[", false) == 0 && 5 > strfind(playername, "]", false) > 1)
{
strmid(clantag, playername, 0, strfind(playername, "]", false)+1);
return clantag;
}
return -1;
}
Код:
if (strcmp(cmdtext, "/clanchat", true) == 0)
{
if (GetPlayerClanTag(playerid) == -1)
return SendClientMessage(playerid, COLOUR, "You cannot use this command");
// one nice string coming up
new params[128], string[128], playername[32];
GetPlayerName(playerid, playername, 32);
strmid(params, cmdtext, strfind(cmdtext," ", strlen(params));
format(string, sizeof(string), "[CLANCHAT] %s: %s", playername, params);
// by now, you owe me already
for (new i; i < MAX_PLAYERS; i++)
{
if (!IsPlayerConnected(i))
continue;
if (strcmp(GetPlayerClanTag(playerid), GetPlayerClanTag(i) == 0)
SendClientMessage(i, COLOR, string);
}
return 1;
}

