本文整理汇总了C++中pc_has_permission函数的典型用法代码示例。如果您正苦于以下问题:C++ pc_has_permission函数的具体用法?C++ pc_has_permission怎么用?C++ pc_has_permission使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pc_has_permission函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: channel_ban
/**
* Bans a character from the given channel.
*
* @param chan The channel.
* @param ssd The source character, if any.
* @param tsd The target character.
* @retval HCS_STATUS_OK if the operation succeeded.
* @retval HCS_STATUS_ALREADY if the target character is already banned.
* @retval HCS_STATUS_NOPERM if the source character doesn't have enough permissions.
* @retval HCS_STATUS_FAIL in case of generic failure.
*/
enum channel_operation_status channel_ban(struct channel_data *chan, const struct map_session_data *ssd, struct map_session_data *tsd)
{
struct channel_ban_entry *entry = NULL;
nullpo_retr(HCS_STATUS_FAIL, chan);
nullpo_retr(HCS_STATUS_FAIL, tsd);
if (ssd && chan->owner != ssd->status.char_id && !pc_has_permission(ssd, PC_PERM_HCHSYS_ADMIN))
return HCS_STATUS_NOPERM;
if (pc_has_permission(tsd, PC_PERM_HCHSYS_ADMIN))
return HCS_STATUS_FAIL;
if (chan->banned && idb_exists(chan->banned, tsd->status.account_id))
return HCS_STATUS_ALREADY;
if (!chan->banned)
chan->banned = idb_alloc(DB_OPT_BASE|DB_OPT_ALLOW_NULL_DATA|DB_OPT_RELEASE_DATA);
CREATE(entry, struct channel_ban_entry, 1);
safestrncpy(entry->name, tsd->status.name, NAME_LENGTH);
idb_put(chan->banned, tsd->status.account_id, entry);
channel->leave(chan, tsd);
return HCS_STATUS_OK;
}
示例2: party_invite
int party_invite (struct map_session_data *sd, struct map_session_data *tsd)
{
struct party_data *p;
int i;
nullpo_ret (sd);
if ( (p = party_search (sd->status.party_id)) == NULL)
return 0;
// confirm if this player is a party leader
ARR_FIND (0, MAX_PARTY, i, p->data[i].sd == sd);
if (i == MAX_PARTY || !p->party.member[i].leader) {
clif_displaymessage (sd->fd, msg_txt (282));
return 0;
}
// confirm if there is an open slot in the party
ARR_FIND (0, MAX_PARTY, i, p->party.member[i].account_id == 0);
if (i == MAX_PARTY) {
clif_party_inviteack (sd, (tsd ? tsd->status.name : ""), 3);
return 0;
}
// confirm whether the account has the ability to invite before checking the player
if (!pc_has_permission (sd, PC_PERM_PARTY) || (tsd && !pc_has_permission (tsd, PC_PERM_PARTY))) {
clif_displaymessage (sd->fd, msg_txt (81)); // "Your GM level doesn't authorize you to preform this action on the specified player."
return 0;
}
if (tsd == NULL) {
clif_party_inviteack (sd, "", 7);
return 0;
}
if (!battle_config.invite_request_check) {
if (tsd->guild_invite > 0 || tsd->trade_partner || tsd->adopt_invite) {
clif_party_inviteack (sd, tsd->status.name, 0);
return 0;
}
}
if (!tsd->fd) { //You can't invite someone who has already disconnected.
clif_party_inviteack (sd, tsd->status.name, 1);
return 0;
}
if (tsd->status.party_id > 0 || tsd->party_invite > 0) {
// already associated with a party
clif_party_inviteack (sd, tsd->status.name, 0);
return 0;
}
tsd->party_invite = sd->status.party_id;
tsd->party_invite_account = sd->status.account_id;
clif_party_invite (sd, tsd);
return 1;
}
示例3: channel_pcjoin
/**
* A player is attempting to join a channel
* @param sd: Player data
* @param chname: Channel name
* @param pass: Channel password
* @return 0 on success or -1 on failure
*/
int channel_pcjoin(struct map_session_data *sd, char *chname, char *pass){
struct Channel *channel;
char output[CHAT_SIZE_MAX];
if(!sd || !chname)
return 0;
if( channel_chk(chname,NULL,1) ) {
clif_displaymessage(sd->fd, msg_txt(sd,1405));// Channel name must start with '#'.
return -1;
}
channel = channel_name2channel(chname,sd,1);
if(channel){
if (!pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) && !channel_pccheckgroup(channel, sd->group_id)) {
sprintf(output, msg_txt(sd,1407), chname); // Channel '%s' is not available.
clif_displaymessage(sd->fd, output);
return -1;
}
if(channel_haspc(channel,sd)==1) {
sprintf(output, msg_txt(sd,1434),chname); // You're already in the '%s' channel.
clif_displaymessage(sd->fd, output);
return -1;
}
else if( channel->pass[0] != '\0') { //chan has a pass
if(strcmp(channel->pass,pass) != 0){ //wrong pass entry
if( pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
sd->stealth = true;
} else {
sprintf(output, msg_txt(sd,1401),chname,"@join"); // Channel '%s' is password-protected (usage: %s <#channel_name> <password>).
clif_displaymessage(sd->fd, output);
return -1;
}
}
}
}
else {
sprintf(output, msg_txt(sd,1400),chname,"@join"); // Unknown channel '%s' (usage: %s <#channel_name>).
clif_displaymessage(sd->fd, output);
return -1;
}
switch(channel->type){
case CHAN_TYPE_ALLY: channel_gjoin(sd,3); break;
case CHAN_TYPE_MAP: channel_mjoin(sd); break;
default: //private and public atm
if (channel_join(channel,sd) != 0)
return -1;
}
if( ( channel->opt & CHAN_OPT_ANNOUNCE_SELF ) ) {
sprintf(output, msg_txt(sd,1403),chname); // You're now in the '%s' channel.
clif_displaymessage(sd->fd, output);
}
return 0;
}
示例4: channel_unban
/**
* Unbans a character from the given channel.
*
* @param chan The channel.
* @param ssd The source character, if any.
* @param tsd The target character. If no target character is specified, all characters are unbanned.
* @retval HCS_STATUS_OK if the operation succeeded.
* @retval HCS_STATUS_ALREADY if the target character is not banned.
* @retval HCS_STATUS_NOPERM if the source character doesn't have enough permissions.
* @retval HCS_STATUS_FAIL in case of generic failure.
*/
enum channel_operation_status channel_unban(struct channel_data *chan, const struct map_session_data *ssd, struct map_session_data *tsd)
{
nullpo_retr(HCS_STATUS_FAIL, chan);
if (ssd && chan->owner != ssd->status.char_id && !pc_has_permission(ssd, PC_PERM_HCHSYS_ADMIN))
return HCS_STATUS_NOPERM;
if (!chan->banned)
return HCS_STATUS_ALREADY;
if (!tsd) {
// Unban all
db_destroy(chan->banned);
chan->banned = NULL;
return HCS_STATUS_OK;
}
// Unban one
if (!idb_exists(chan->banned, tsd->status.account_id))
return HCS_STATUS_ALREADY;
idb_remove(chan->banned, tsd->status.account_id);
if (!db_size(chan->banned)) {
db_destroy(chan->banned);
chan->banned = NULL;
}
return HCS_STATUS_OK;
}
示例5: channel_send
/**
* Sends a message to a channel.
*
* @param chan The destination channel.
* @param sd The source character.
* @param msg The message to send.
*
* If no source character is specified, it'll send an anonymous message.
*/
void channel_send(struct channel_data *chan, struct map_session_data *sd, const char *msg)
{
char message[150];
nullpo_retv(chan);
nullpo_retv(msg);
if (sd && chan->msg_delay != 0
&& DIFF_TICK(sd->hchsysch_tick + chan->msg_delay*1000, timer->gettick()) > 0
&& !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
clif->messagecolor_self(sd->fd, COLOR_RED, msg_sd(sd,1455));
return;
} else if (sd) {
safesnprintf(message, 150, "[ #%s ] %s : %s", chan->name, sd->status.name, msg);
clif->channel_msg(chan,sd,message);
if (chan->type == HCS_TYPE_IRC)
ircbot->relay(sd->status.name,msg);
if (chan->msg_delay != 0)
sd->hchsysch_tick = timer->gettick();
} else {
safesnprintf(message, 150, "[ #%s ] %s", chan->name, msg);
clif->channel_msg2(chan, message);
if (chan->type == HCS_TYPE_IRC)
ircbot->relay(NULL, msg);
}
}
示例6: channel_send
/**
* Sends a message to a channel.
*
* @param chan The destination channel.
* @param sd The source character.
* @param msg The message to send.
*
* If no source character is specified, it'll send an anonymous message.
*/
static void channel_send(struct channel_data *chan, struct map_session_data *sd, const char *msg)
{
char message[150];
nullpo_retv(chan);
nullpo_retv(msg);
if (sd && chan->msg_delay != 0
&& DIFF_TICK(sd->hchsysch_tick + chan->msg_delay*1000, timer->gettick()) > 0
&& !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
clif->messagecolor_self(sd->fd, COLOR_RED, msg_sd(sd,1455));
return;
} else if (sd) {
int i;
safesnprintf(message, 150, "[ #%s ] %s : %s", chan->name, sd->status.name, msg);
clif->channel_msg(chan,sd,message);
if (chan->type == HCS_TYPE_IRC)
ircbot->relay(sd->status.name,msg);
if (chan->msg_delay != 0)
sd->hchsysch_tick = timer->gettick();
for (i = 0; i < MAX_EVENTQUEUE; i++) {
if (chan->handlers[i][0] != '\0') {
pc->setregstr(sd, script->add_str("@channelmes$"), msg);
npc->event(sd, chan->handlers[i], 0);
}
}
} else {
safesnprintf(message, 150, "[ #%s ] %s", chan->name, msg);
clif->channel_msg2(chan, message);
if (chan->type == HCS_TYPE_IRC)
ircbot->relay(NULL, msg);
}
}
示例7: chat_kickchat
/**
* Kick a member from a chat room.
* @param sd : player requesting
* @param kickusername : player name to be kicked
* @retur 1:success, 0:failure
*/
int chat_kickchat(struct map_session_data* sd, const char* kickusername)
{
struct chat_data* cd;
int i;
nullpo_retr(1, sd);
cd = (struct chat_data *)map_id2bl(sd->chatID);
if( cd == NULL || (struct block_list *)sd != cd->owner )
return -1;
ARR_FIND( 0, cd->users, i, strncmp(cd->usersd[i]->status.name, kickusername, NAME_LENGTH) == 0 );
if( i == cd->users )
return -1;
if (pc_has_permission(cd->usersd[i], PC_PERM_NO_CHAT_KICK))
return 0; //gm kick protection [Valaris]
idb_put(cd->kick_list,cd->usersd[i]->status.char_id,(void*)1);
chat_leavechat(cd->usersd[i],1);
return 0;
}
示例8: channel_pckick
/**
* A player is attemting to kick a player
* @param sd: Player data
* @param chname: Channel name
* @param pname: Player name to kick
* @return 0 on success or -1 on failure
*/
int channel_pckick(struct map_session_data *sd, char *chname, char *pname) {
struct Channel *channel;
char output[CHAT_SIZE_MAX];
struct map_session_data *tsd = map_nick2sd(pname,false);
if( channel_chk(chname,NULL,1) ) {
clif_displaymessage(sd->fd, msg_txt(sd,1405));// Channel name must start with '#'.
return -1;
}
channel = channel_name2channel(chname,sd,0);
if( !channel ) {
sprintf(output, msg_txt(sd,1407), chname);// Channel '%s' is not available.
clif_displaymessage(sd->fd, output);
return -1;
}
if (!tsd) {
clif_displaymessage(sd->fd, msg_txt(sd,3));
return -1;
}
if( !pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
if (channel->char_id != sd->status.char_id) {
sprintf(output, msg_txt(sd,1412), chname);// You're not the owner of channel '%s'.
clif_displaymessage(sd->fd, output);
} else if (!channel_config.private_channel.kick) {
sprintf(output, msg_txt(sd,766), chname); // You cannot kick a player from channel '%s'.
clif_displaymessage(sd->fd, output);
}
return -1;
}
if (channel_pc_haschan(sd, channel) < 0) {
sprintf(output, msg_txt(sd,1425), chname); // You're not part of the '%s' channel.
clif_displaymessage(sd->fd, output);
return -1;
}
if (channel->char_id == sd->status.char_id) {
clif_displaymessage(sd->fd, msg_txt(sd, 767)); // You're not allowed to kick a player.
return -1;
}
if( !channel_config.closing && (channel->opt & CHAN_OPT_ANNOUNCE_LEAVE) ) {
safesnprintf(output, CHAT_SIZE_MAX, msg_txt(sd,768), channel->alias, tsd->status.name); // %s %s has been kicked.
clif_channel_msg(channel,output,channel->color);
}
switch(channel->type){
case CHAN_TYPE_ALLY: channel_pcquit(tsd,3); break;
case CHAN_TYPE_MAP: channel_pcquit(tsd,4); break;
default: //private and public atm
channel_clean(channel,tsd,0);
}
return 1;
}
示例9: chat_joinchat
/*==========================================
* join an existing chatroom
*------------------------------------------*/
bool chat_joinchat(struct map_session_data* sd, int chatid, const char* pass) {
struct chat_data* cd;
nullpo_ret(sd);
nullpo_ret(pass);
cd = map->id2cd(chatid);
if (cd == NULL || cd->bl.type != BL_CHAT || cd->bl.m != sd->bl.m
|| sd->state.vending || sd->state.buyingstore || sd->chat_id != 0
|| ((cd->owner->type == BL_NPC) ? cd->users+1 : cd->users) >= cd->limit
) {
clif->joinchatfail(sd,0); // room full
return false;
}
if( !cd->pub && strncmp(pass, cd->pass, sizeof(cd->pass)) != 0 && !pc_has_permission(sd, PC_PERM_JOIN_ALL_CHAT) )
{
clif->joinchatfail(sd,1); // wrong password
return false;
}
if( sd->status.base_level < cd->minLvl || sd->status.base_level > cd->maxLvl ) {
if(sd->status.base_level < cd->minLvl)
clif->joinchatfail(sd,5); // too low level
else
clif->joinchatfail(sd,6); // too high level
return false;
}
if( sd->status.zeny < cd->zeny ) {
clif->joinchatfail(sd,4); // not enough zeny
return false;
}
if( cd->owner->type != BL_NPC && idb_exists(cd->kick_list,sd->status.char_id) ) {
clif->joinchatfail(sd,2); // You have been kicked out of the room.
return false;
}
pc_stop_walking(sd, STOPWALKING_FLAG_FIXPOS);
cd->usersd[cd->users] = sd;
cd->users++;
pc_setchatid(sd,cd->bl.id);
clif->joinchatok(sd, cd); //To the person who newly joined the list of all
clif->addchat(cd, sd); //Reports To the person who already in the chat
clif->dispchat(cd, 0); //Reported number of changes to the people around
chat->trigger_event(cd); //Event
return true;
}
示例10: chat_joinchat
/**
* Join an existing chat room.
* @param sd : player requesting
* @param chatid : ID of the chat room
* @param pass : password of chat room
* @return 0
*/
int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass)
{
struct chat_data* cd;
nullpo_ret(sd);
cd = (struct chat_data*)map_id2bl(chatid);
if( cd == NULL || cd->bl.type != BL_CHAT || cd->bl.m != sd->bl.m || sd->state.vending || sd->state.buyingstore || sd->chatID || ((cd->owner->type == BL_NPC) ? cd->users+1 : cd->users) >= cd->limit ) {
clif_joinchatfail(sd,0);
return 0;
}
if( !cd->pub && strncmp(pass, cd->pass, sizeof(cd->pass)) != 0 && !pc_has_permission(sd, PC_PERM_JOIN_ALL_CHAT) ) {
clif_joinchatfail(sd,1);
return 0;
}
if( sd->status.base_level < cd->minLvl || sd->status.base_level > cd->maxLvl ) {
if(sd->status.base_level < cd->minLvl)
clif_joinchatfail(sd,5);
else
clif_joinchatfail(sd,6);
return 0;
}
if( sd->status.zeny < cd->zeny ) {
clif_joinchatfail(sd,4);
return 0;
}
if( cd->owner->type != BL_NPC && idb_exists(cd->kick_list,sd->status.char_id) ) {
clif_joinchatfail(sd,2);//You have been kicked out of the room.
return 0;
}
pc_stop_walking(sd,1);
cd->usersd[cd->users] = sd;
cd->users++;
pc_setchatid(sd,cd->bl.id);
clif_joinchatok(sd, cd); //To the person who newly joined the list of all
clif_addchat(cd, sd); //Reports To the person who already in the chat
clif_dispchat(cd, 0); //Reported number of changes to the people around
if (cd->owner->type == BL_PC)
achievement_update_objective(map_id2sd(cd->owner->id), AG_CHAT_COUNT, 1, cd->users);
chat_triggerevent(cd); //Event
return 0;
}
示例11: channel_join
/**
* Joins a channel.
*
* Ban and password checks are performed before joining the channel.
* If the channel is an HCS_TYPE_ALLY channel, alliance channels are automatically joined.
*
* @param chan The channel to join
* @param sd The character
* @param password The specified join password, if any
* @param silent If true, suppress the "You're now in the <x> channel" greeting message
* @retval HCS_STATUS_OK if the operation succeeded
* @retval HCS_STATUS_ALREADY if the character is already in the channel
* @retval HCS_STATUS_NOPERM if the specified password doesn't match
* @retval HCS_STATUS_BANNED if the character is in the channel's ban list
* @retval HCS_STATUS_FAIL in case of generic error
*/
enum channel_operation_status channel_join(struct channel_data *chan, struct map_session_data *sd, const char *password, bool silent)
{
bool stealth = false;
nullpo_retr(HCS_STATUS_FAIL, chan);
nullpo_retr(HCS_STATUS_FAIL, sd);
nullpo_retr(HCS_STATUS_FAIL, password);
if (idb_exists(chan->users, sd->status.char_id)) {
return HCS_STATUS_ALREADY;
}
if (chan->password[0] != '\0' && strcmp(chan->password, password) != 0) {
if (pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
stealth = true;
} else {
return HCS_STATUS_NOPERM;
}
}
if (chan->banned && idb_exists(chan->banned, sd->status.account_id)) {
return HCS_STATUS_BANNED;
}
if (!silent && !(chan->options&HCS_OPT_ANNOUNCE_JOIN)) {
char output[CHAT_SIZE_MAX];
if (chan->type == HCS_TYPE_MAP) {
sprintf(output, msg_sd(sd,1435), chan->name, map->list[chan->m].name); // You're now in the '#%s' channel for '%s'
} else {
sprintf(output, msg_sd(sd,1403), chan->name); // You're now in the '%s' channel
}
clif->messagecolor_self(sd->fd, COLOR_DEFAULT, output);
}
if (chan->type == HCS_TYPE_ALLY) {
struct guild *g = sd->guild;
int i;
for (i = 0; i < MAX_GUILDALLIANCE; i++) {
struct guild *sg = NULL;
if (g->alliance[i].opposition == 0 && g->alliance[i].guild_id && (sg = guild->search(g->alliance[i].guild_id)) != NULL) {
if (!(sg->channel->banned && idb_exists(sg->channel->banned, sd->status.account_id))) {
channel->join_sub(sg->channel, sd, stealth);
}
}
}
}
channel->join_sub(chan, sd, stealth);
return HCS_STATUS_OK;
}
示例12: channel_pccolor
/**
* A player is attempting to change the channel color
* @param sd: Player data
* @param chname: Channel name
* @param color: New color
* @return 0 on success or -1 on failure
*/
int channel_pccolor(struct map_session_data *sd, char *chname, char *color){
struct Channel *channel;
char output[CHAT_SIZE_MAX];
int k;
if(!sd)
return 0;
if( channel_chk(chname,NULL,1) ) {
clif_displaymessage(sd->fd, msg_txt(sd,1405));// Channel name must start with '#'.
return -1;
}
channel = channel_name2channel(chname,sd,0);
if( !channel ) {
sprintf(output, msg_txt(sd,1407), chname);// Channel '%s' is not available.
clif_displaymessage(sd->fd, output);
return -1;
}
if( !pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
if (channel->char_id != sd->status.char_id) {
sprintf(output, msg_txt(sd,1412), chname);// You're not the owner of channel '%s'.
clif_displaymessage(sd->fd, output);
return -1;
}
else if (!(channel->opt&CHAN_OPT_COLOR_OVERRIDE)) {
sprintf(output, msg_txt(sd,764), chname); // You cannot change the color for channel '%s'.
clif_displaymessage(sd->fd, output);
return -1;
}
}
ARR_FIND(0,channel_config.colors_count,k,( strcmpi(color,channel_config.colors_name[k]) == 0 ) );
if( k >= channel_config.colors_count ) {
sprintf(output, msg_txt(sd,1411), color);// Unknown color '%s'.
clif_displaymessage(sd->fd, output);
return -1;
}
channel->color = channel_config.colors[k];
sprintf(output, msg_txt(sd,1413),chname,channel_config.colors_name[k]);// '%s' channel color updated to '%s'.
clif_displaymessage(sd->fd, output);
return 0;
}
示例13: channel_join
/**
* Make a player join a channel
* - Add player to channel user list
* - Add channel to user channel list
* @param channel: Channel data
* @param sd: Player data
* @return
* 0: Success
* -1: Invalid channel or player
* -2: Player already in channel
* -3: Player banned
* -4: Reached max limit
*/
int channel_join(struct Channel *channel, struct map_session_data *sd) {
if(!channel || !sd)
return -1;
if(sd->state.autotrade)
return 0; // fake success
if(channel_haspc(channel,sd)==1)
return -2;
if (!pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) && !channel_pccheckgroup(channel, sd->group_id))
return -2;
if(channel_haspcbanned(channel,sd)==1){
char output[CHAT_SIZE_MAX];
sprintf(output, msg_txt(sd,1438),channel->name); //You're currently banned from the '%s' channel.
clif_displaymessage(sd->fd, output);
return -3;
}
if (channel->type == CHAN_TYPE_PRIVATE && db_size(channel->users) >= channel_config.private_channel.max_member) {
char output[CHAT_SIZE_MAX];
sprintf(output, msg_txt(sd,760), channel->name, channel_config.private_channel.max_member); // You cannot join channel '%s'. Limit of %d has been met.
clif_displaymessage(sd->fd, output);
return -4;
}
RECREATE(sd->channels, struct Channel *, ++sd->channel_count);
sd->channels[ sd->channel_count - 1 ] = channel;
idb_put(channel->users, sd->status.char_id, sd);
RECREATE(sd->channel_tick, t_tick, sd->channel_count);
sd->channel_tick[sd->channel_count-1] = 0;
if( sd->stealth ) {
sd->stealth = false;
} else if( channel->opt & CHAN_OPT_ANNOUNCE_JOIN ) {
char output[CHAT_SIZE_MAX];
safesnprintf(output, CHAT_SIZE_MAX, msg_txt(sd,761), channel->alias, sd->status.name); // %s %s has joined.
clif_channel_msg(channel,output,channel->color);
}
/* someone is cheating, we kindly disconnect the bastard */
if( sd->channel_count > 200 ) {
set_eof(sd->fd);
}
return 0;
}
示例14: channel_pcautojoin_sub
/**
* Attempt to autojoin a player to a channel
*/
int channel_pcautojoin_sub(DBKey key, DBData *data, va_list ap) {
struct Channel *channel = (struct Channel *)db_data2ptr(data);
struct map_session_data *sd = NULL;
char channame[CHAN_NAME_LENGTH+1];
nullpo_ret(channel);
nullpo_ret((sd = va_arg(ap, struct map_session_data *)));
if (channel->pass[0])
return 0;
if (!(channel->opt&CHAN_OPT_AUTOJOIN))
return 0;
if (!pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) && !channel_pccheckgroup(channel, sd->group_id))
return 0;
safesnprintf(channame, sizeof(channame), "#%s", channel->name);
channel_pcjoin(sd, channame, NULL);
return 1;
}
示例15: channel_send
/**
* Format message from player to send to the channel
* - Also truncate extra characters if message is too long
* @param channel: Channel data
* @param sd: Player data
* @param msg: Message to send
* @return
* 0: Success
* -1: Invalid player, channel, or message
* -2: Delay message from last message
*/
int channel_send(struct Channel *channel, struct map_session_data *sd, const char *msg) {
int idx = 0;
if(!channel || !sd || !msg || (idx = channel_pc_haschan(sd, channel)) < 0)
return -1;
if(!pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) && channel->msg_delay != 0 && DIFF_TICK(sd->channel_tick[idx] + channel->msg_delay, gettick()) > 0) {
clif_messagecolor(&sd->bl,color_table[COLOR_RED],msg_txt(sd,1455),false,SELF); //You're talking too fast!
return -2;
}
else {
char output[CHAT_SIZE_MAX];
unsigned long color = channel->color;
if((channel->opt&CHAN_OPT_COLOR_OVERRIDE) && sd->fontcolor && sd->fontcolor < channel_config.colors_count && channel_config.colors[sd->fontcolor])
color = channel_config.colors[sd->fontcolor];
safesnprintf(output, CHAT_SIZE_MAX, "%s %s : %s", channel->alias, sd->status.name, msg);
clif_channel_msg(channel,output,color);
sd->channel_tick[idx] = gettick();
}
return 0;
}