Jump to content
  • 0

#main cooldown


Dissidia

Question


  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.03
  • Content Count:  535
  • Reputation:   23
  • Joined:  11/19/11
  • Last Seen:  

how to add 5 seconds cooldown on #main chat? thanks

  • Like 1
Link to comment
Share on other sites

15 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  99
  • Topics Per Day:  0.02
  • Content Count:  623
  • Reputation:   94
  • Joined:  05/11/12
  • Last Seen:  

Go to: emulator/conf/channels.conf

 

    {
        name: "#main"
        alias: "[main]"
        color: "White"
        type: "CHAN_TYPE_PUBLIC"
        delay: 1000
        autojoin: false
        leave: false
},

 

Use delay: 1000, the time setting is in milliseconds.

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.03
  • Content Count:  535
  • Reputation:   23
  • Joined:  11/19/11
  • Last Seen:  

Thank you. :) Problem solved.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

Im having issues with the channel system, and if im using normal account it keeps saying im talking to fast even tho im not.. did you encounter that kind of issue? @Dissidia

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  74
  • Topics Per Day:  0.02
  • Content Count:  420
  • Reputation:   89
  • Joined:  01/30/12
  • Last Seen:  

On 2017. 08. 09. at 5:04 AM, Radian said:

Im having issues with the channel system, and if im using normal account it keeps saying im talking to fast even tho im not.. did you encounter that kind of issue? @Dissidia

Same issue here

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

On 12/24/2017 at 10:49 AM, Antares said:

Same issue here

You encounter this issue too? im trying to look what is causing this problem..

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  74
  • Topics Per Day:  0.02
  • Content Count:  420
  • Reputation:   89
  • Joined:  01/30/12
  • Last Seen:  

@Radian after a re-pull and rebuild it is working properly for me now

Edited by Antares
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

@Antares I did try rebuilding and test it again sometimes its working but most of the time its not.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  74
  • Topics Per Day:  0.02
  • Content Count:  420
  • Reputation:   89
  • Joined:  01/30/12
  • Last Seen:  

On 2018. 01. 10. at 3:15 PM, Radian said:

@Antares I did try rebuilding and test it again sometimes its working but most of the time its not.

Oh :(
I'll keep an eye out and try spamming the channels regularly to see if it's the same for me, or not.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

1 hour ago, Antares said:

Oh :(
I'll keep an eye out and try spamming the channels regularly to see if it's the same for me, or not.

Thank you.. I also try somethings and see what i can find

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  74
  • Topics Per Day:  0.02
  • Content Count:  420
  • Reputation:   89
  • Joined:  01/30/12
  • Last Seen:  

I think I found it out... I can't write into the channels with my regular characters, but I can with my group99 admin character. I am not entirely sure, but so far it looks like this is it.

this is the line that causes the problem (/src/map/channel.cpp, 442):

if(!pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) && channel->msg_delay != 0 && DIFF_TICK(sd->channel_tick[idx] + channel->msg_delay, gettick()) > 0) {

Admins bypass the check, but regular players don't and the tick always returns a number larger than 0, so the "Talking too fast" message is displayed. Either the check rule, or the tick setting is faulty.

If DIFF_TICK retunrs an absolute value, then this check will always be positive:

DIFF_TICK(sd->channel_tick[idx] + channel->msg_delay, gettick()) > 0

Otherwise the sd->channel_tick[idx] part is not set correctly or channel->msg_delay is not a compatible type with sd->channel_tick[idx] , and it yields an incorrect value when added together. I am just guessing here by looking at the code... these are the first possible reasons that occurred to me, but it could be something else as well.

 

Edited by Antares
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  89
  • Topics Per Day:  0.02
  • Content Count:  232
  • Reputation:   15
  • Joined:  11/02/13
  • Last Seen:  

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) {
		char cdmessage[CHAT_SIZE_MAX];
		
		int cdseconds = DIFF_TICK(sd->channel_tick[idx] + channel->msg_delay, gettick()) / 1000;
		int cdmilliseconds = (DIFF_TICK(sd->channel_tick[idx] + channel->msg_delay, gettick()) - (cdseconds * 1000))/100;
      
		//clif_messagecolor(&sd->bl,color_table[COLOR_RED],msg_txt(sd,1455),false,SELF); //You're talking too fast!
		safesnprintf(cdmessage, sizeof(cdmessage), "You still have %d.%d second(s) left before you can use the channel again.", cdseconds, cdmilliseconds);
		clif_displaymessage(sd->fd, cdmessage);
		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;
}

Try this for cooldown message..

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  45
  • Reputation:   7
  • Joined:  11/07/14
  • Last Seen:  

2 hours ago, nasagnilac said:

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) {
		char cdmessage[CHAT_SIZE_MAX];
		
		int cdseconds = DIFF_TICK(sd->channel_tick[idx] + channel->msg_delay, gettick()) / 1000;
		int cdmilliseconds = (DIFF_TICK(sd->channel_tick[idx] + channel->msg_delay, gettick()) - (cdseconds * 1000))/100;
      
		//clif_messagecolor(&sd->bl,color_table[COLOR_RED],msg_txt(sd,1455),false,SELF); //You're talking too fast!
		safesnprintf(cdmessage, sizeof(cdmessage), "You still have %d.%d second(s) left before you can use the channel again.", cdseconds, cdmilliseconds);
		clif_displaymessage(sd->fd, cdmessage);
		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;
}

Try this for cooldown message..

I tried that and now it says I have 1366748.7 second(s) left to wait until next msg, but it was the first msg I attempted. Still work for my admin account.

Edited by Sirique
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  89
  • Topics Per Day:  0.02
  • Content Count:  232
  • Reputation:   15
  • Joined:  11/02/13
  • Last Seen:  

delay: 5000

set this one for 5 seconds cooldown. its normal that admin bypass the cooldown.  In able for you make fast reply.  But you can remove this part 

!pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) && channel->msg_delay != 0 && 

So that all user even gm groups has a cooldown in you #main. 

Edited by nasagnilac
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  45
  • Reputation:   7
  • Joined:  11/07/14
  • Last Seen:  

On 19/03/2018 at 5:16 PM, nasagnilac said:

delay: 5000

set this one for 5 seconds cooldown. its normal that admin bypass the cooldown.  In able for you make fast reply.  But you can remove this part 


!pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) && channel->msg_delay != 0 && 

So that all user even gm groups has a cooldown in you #main. 

Thank you, that fixed it!

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  19
  • Topics Per Day:  0.01
  • Content Count:  34
  • Reputation:   0
  • Joined:  07/19/17
  • Last Seen:  

Help pls

code:
 

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(DIFF_TICK(sd->channel_tick[idx] + channel->msg_delay, gettick()) > 0) {
        char cdmessage[CHAT_SIZE_MAX];
        
        int cdseconds = DIFF_TICK(sd->channel_tick[idx] + channel->msg_delay, gettick()) / 1000;
        int cdmilliseconds = (DIFF_TICK(sd->channel_tick[idx] + channel->msg_delay, gettick()) - (cdseconds * 1000))/100;
      
        //clif_messagecolor(&sd->bl,color_table[COLOR_RED],msg_txt(sd,1455),false,SELF); //You're talking too fast!
        safesnprintf(cdmessage, sizeof(cdmessage), "You still have %d.%d second(s) left before you can use the channel again.", cdseconds, cdmilliseconds);
        clif_displaymessage(sd->fd, cdmessage);
        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;
}

 

screenOrion Online107.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...