Habilis
New member
Hello I was about to release popular commands in Russian comunity
such as @emotion @heart (Emotions without delay) as plugins for herc
But i encountered a problem with chat flood (3 times one word phrase, even if command)
So, I decided to make it configurable how many times command will be executed
The comand is executed ex: 20 times but so fast, emotions merge one into another.
I made a function to delay a bit, but it seems delay is not respected, no matter how much time i set as delay....
waitDelay is my delay function...
such as @emotion @heart (Emotions without delay) as plugins for herc
But i encountered a problem with chat flood (3 times one word phrase, even if command)
So, I decided to make it configurable how many times command will be executed
The comand is executed ex: 20 times but so fast, emotions merge one into another.
I made a function to delay a bit, but it seems delay is not respected, no matter how much time i set as delay....
waitDelay is my delay function...
Code:
/*
=============================================
@emo
Converted by: samsudin
Original Made by: OnPlay
inspired by: Anarchist
================================================
v1.0 Initial Release
Displays the emotions without delay
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include "../common/HPMi.h"
#include "../common/nullpo.h"
#include "../map/clif.h"
#include "../map/atcommand.h"
#include "../map/script.h"
#include "../map/pc.h"
#include "../common/timer.h"
#include "../common/HPMDataCheck.h"
HPExport struct hplugin_info pinfo =
{
"@emo", // Plugin name
SERVER_TYPE_MAP,// Which server types this plugin works with?
"0.1", // Plugin version
HPM_VERSION, // HPM Version (don't change, macro is automatically updated)
};
/*==========================================
* @emo by OnNplay
* inspired by Anarchist
* => Displays the emotions without delay
*------------------------------------------
*/
int emotion_max_repeat = 20; //max repeat without delay
int emotion_max = 81;
int delay_repeats = 5000;
void waitDelay (void)
{
unsigned int tick;
tick = timer->gettick()+delay_repeats;
while (timer->gettick() < tick);
}
ACMD(emo)
{
int emotion = 0, repeat = 0, nbargs=0;
char err_msg[1024];
nbargs=sscanf(message, "%d %d", &emotion, &repeat);
if (!message || !*message || nbargs != 2 || emotion < 1 || emotion > emotion_max || repeat < 1 || repeat > emotion_max_repeat) {
sprintf(err_msg, "usage: @emo <emotion (1-%d)> <repeat (max %d)>", emotion_max, emotion_max_repeat);
clif->message(fd, err_msg);
return -1;
}
for (int i = 0; i < repeat; i++)
{
clif->emotion(&sd->bl, emotion);
waitDelay();
}
return 1;
}
/* Server Startup */
HPExport void plugin_init (void)
{
addAtcommand("emo",emo);
}
Last edited by a moderator: