| AdminMod.de https://www.adminmod.de/ |
|
| script fix https://www.adminmod.de/viewtopic.php?t=9941 |
Seite 1 von 1 |
| Autor: | caramel [ 08.03.2007, 19:40 ] |
| Betreff des Beitrags: | script fix |
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 example2) 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 |
|
| Autor: | Sir Drink a lot [ 08.03.2007, 20:10 ] |
| Betreff des Beitrags: | |
oh okay... some issues: 1. AdminMod uses different code than AMXMod. Download AdminMod and unzip it to your computer. Change to halflife-admin-2.50.60-win\Adminmod\scripting an take a look into \include folder. These functions you can use. Take also a look into \examples folder to see, how to register cmds and using public functions;) 2. You can't register cvars with AdminMod. You need to add vault.ini entries to store values. 3. AdminMod has an plugin_antiflood, which may be do same you want to do. Take a look. If you need more help, ask again! |
|
| Autor: | caramel [ 08.03.2007, 20:16 ] |
| Betreff des Beitrags: | |
ok, some revisions, little changes, and maybe submit Have any suggestions for this ? |
|
| Autor: | Sir Drink a lot [ 08.03.2007, 20:51 ] |
| Betreff des Beitrags: | |
oh... too many details to explain. I maybe rewrite the plugin (if i got time) that it works. It is easier for you to understand then. If you donwload AdminMod Full Version and unzip it, you maybe can copy your plugin_test.sma to: halflife-admin-2.50.60-win\Adminmod\scripting\myscripts and hit "compile_all.bat" Then you will see all error messages in plugin plugin_test.sma(7) Error [070]: rational number support was not enabled plugin_test.sma(103) Error [035]: argument type mismatch (argument 3) (7) and (103) are the line numbers. |
|
| Autor: | caramel [ 08.03.2007, 21:13 ] |
| Betreff des Beitrags: | |
i solved. Thanks Take a look here : forum/viewtopic.php?t=9942 |
|
| Seite 1 von 1 | Alle Zeiten sind UTC+01:00 |
| Powered by phpBB® Forum Software © phpBB Limited https://www.phpbb.com/ |
|