Hi,
first, my code:
Code:
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
#define VERSION 0.1
enum action
{
action_say,
player_gag,
player_kick,
player_ban
};
new MAX_SPAM = 3;
new MAX_SPAM_TIME = 5;
new START_W_ACTION = player_gag;
new GAG_TIME = 20;
new BAN_TIME = 360; // ban player for 360 seconds :P
new LastText[MAX_PLAYERS][MAX_TEXT_LENGTH];
new SpamCount[MAX_PLAYERS];
new FirstTime[MAX_PLAYERS];
new GagTime[MAX_PLAYERS];
public hook_say(HLCommand, HLData, HLUserName, u)
{
new Data[MAX_DATA_LENGTH];
new User[MAX_NAME_LENGTH];
new s[MAX_TEXT_LENGTH];
new Time[MAX_TEXT_LENGTH];
new now;
now = servertime(Time,MAX_TEXT_LENGTH);
if ( GagTime[u] > now )
return PLUGIN_HANDLED;
convert_string(HLData,Data,MAX_DATA_LENGTH);
convert_string(HLUserName,User,MAX_NAME_LENGTH);
strstripquotes(Data);
if( (strlen(Data)>0) && (streq( Data, LastText[u] ) == 1) )
{
SpamCount[u] = SpamCount[u] + 1;
if ( (SpamCount[u] >= MAX_SPAM) && ((FirstTime[u] + MAX_SPAM_TIME) > now)) {
switch ( START_W_ACTION ) {
case action_say:
{
snprintf(s,MAX_TEXT_LENGTH,"Don't spam idiot, %s.",User);
say(s);
}
case player_gag:
{
GagTime[u] = now + GAG_TIME;
snprintf(s,MAX_TEXT_LENGTH,"%s has been gagged %d seconds for spamming.", User, GAG_TIME);
say(s);
}
case player_kick:
{
snprintf(s,MAX_TEXT_LENGTH,"%s has kicked because is an idiot an spam server",User);
say(s);
kick(User);
}
case player_ban:
{
snprintf(s,MAX_TEXT_LENGTH,"%s has been banned %d minutes for spamming.",User,BAN_TIME);
say(s);
ban(User,BAN_TIME);
}
}
SpamCount[u]=0;
FirstTime[u]=0;
}
}
else
{
strcpy(LastText[u],Data,MAX_TEXT_LENGTH);
FirstTime[u] = now;
}
return PLUGIN_CONTINUE;
}
public plugin_init()
{
new j; // the contor
plugin_registerinfo("new plugin test","me",VERSION);
plugin_registercmd("say","hook_say",0);
for(j=0;j<MAX_PLAYERS;j++)
{
SpamCount[j]=0;
LastText[j][0]=0;
FirstTime[j]=0;
}
return PLUGIN_CONTINUE;
}
1) I want to add cvars for set the ban time, gag time etc . Give me an example
2) Fix if have any bugs,
Initial i scripting amxx plugins, but i don't so somebody who interests adminmod coding, so i deside to make new plugins
So fix it,
Thanks