Ein neues Thema erstellen  Auf das Thema antworten  [ 5 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: script fix
BeitragVerfasst: 08.03.2007, 19:40 

Registriert: 18.11.2006, 18:43
Beiträge: 26
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


Nach oben
   
 Betreff des Beitrags:
BeitragVerfasst: 08.03.2007, 20:10 
AM.de Team
Benutzeravatar

Registriert: 27.11.2001, 01:00
Beiträge: 3564
Wohnort: In der Nähe von Bonn
oh ;) A new star is born *gg*

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!

_________________
Fehleranalyse: Poste den Inhalt Deiner liblist.gam, (listen)server.cfg, adminmod.cfg, users.ini, vault.ini, plugin.ini von adminmod und plugins.ini von metamod. Benutze auch die Such-Funktion


Nach oben
   
 Betreff des Beitrags:
BeitragVerfasst: 08.03.2007, 20:16 

Registriert: 18.11.2006, 18:43
Beiträge: 26
ok, some revisions, little changes, and maybe submit :o
Have any suggestions for this ?


Nach oben
   
 Betreff des Beitrags:
BeitragVerfasst: 08.03.2007, 20:51 
AM.de Team
Benutzeravatar

Registriert: 27.11.2001, 01:00
Beiträge: 3564
Wohnort: In der Nähe von Bonn
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.

_________________
Fehleranalyse: Poste den Inhalt Deiner liblist.gam, (listen)server.cfg, adminmod.cfg, users.ini, vault.ini, plugin.ini von adminmod und plugins.ini von metamod. Benutze auch die Such-Funktion


Nach oben
   
 Betreff des Beitrags:
BeitragVerfasst: 08.03.2007, 21:13 

Registriert: 18.11.2006, 18:43
Beiträge: 26
i solved. Thanks
Take a look here : forum/viewtopic.php?t=9942


Nach oben
   
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen  Auf das Thema antworten  [ 5 Beiträge ] 


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Powered by phpBB® Forum Software © phpBB Limited
Deutsche Übersetzung durch phpBB.de
Original Design von "[ Half-Life Admin Mod © Alfred Reynolds 2000-2003 ] - [ site design by Jägermeister ]"