AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to work with a file [Help] (https://forums.alliedmods.net/showthread.php?t=144457)

Callesson 12-04-2010 08:35

How to work with a file [Help]
 
Hello guys :)

*The plugin im trying to to
My plugin is going to kick you if you use bad words
Previous thread about this http://forums.alliedmods.net/showthread.php?t=144371

* What I want help with
I would someone to explain how I can work with a file for my plugin.
I've founded this http://www.amxmodx.org/funcwiki.php?go=inc&id=3 but I don't know how to use it.

* My code right now
So now my function only runs if you type "shit"
Code:

register_clcmd("say shit", "kick",,"User get kicked for swearing")
* I would like
A textfile like this (Textfile will be in the Config folder.)
Code:

;Bad words list
fuck
shit
damn

And then use those words to run my function.

* One more thing
This will only run player say "shit". Not if he says "you shit".
How can I get the word in a text/sentence ?
Code:

register_clcmd("say shit", "kick",,"User get kicked for swearing")

Bugsy 12-04-2010 08:52

Re: How to work with a file [Help]
 
This may help http://forums.alliedmods.net/showpos...7&postcount=13

Search or browse for hooking say and reading what was said. This has been covered many times.

Callesson 12-04-2010 09:06

Re: How to work with a file [Help]
 
Okey i'm gonna check :)
Thank you!

Callesson 12-04-2010 10:05

Re: How to work with a file [Help]
 
Sorry but it's very hard to me to get it just by looking at the code as i'm new to this :/

If you could explain the steps that would be awesome :) ?

Ty

lucas_7_94 12-04-2010 10:16

Re: How to work with a file [Help]
 
I made this a lot of time ago .

Its not tested , but i think need works .

I have looked a version with tries , but i never understand the tries , and doesn't exist a tutorial , sorry.

Code:
#include <amxmodx> #include <amxmisc> #pragma semicolon 0 static const AUTHOR[] = "Luqqas' aka lucas_7_94"; static const PLUGIN[] = "Don't Insult In This Server!"; new const ARCHIVEINI[] = "anti-insult.ini"; #define MAX_WORDS 100 #define REASONKICK "Don't insult in this sv retard" new szWords[ MAX_WORDS ][ 32 ] ; new Words; new const mycvars[][] = { "amx_insult_block" }; new const mycvarsvalor[][] = { "0" }; enum {     cvar_block_style = 0 } new Cvars[1]; public plugin_init( ) {     register_plugin( PLUGIN, "1.0c", AUTHOR );         // Hooking the 'say' & 'say_team'     register_clcmd( "say", "Filtersay" );     register_clcmd( "say_team", "Filtersay" );         Cvars[0] = register_cvar(mycvars[cvar_block_style] , mycvarsvalor[cvar_block_style]); // 0 , block the message , 1 , kick. } public Filtersay(id) {     new Args[150];     read_args(Args, 149);     remove_quotes(Args);         trim(Args)         for(new i = 0; i < Words; ++i)     {         if(containi(Args , szWords[i]) != -1)         {                         switch(get_pcvar_num(Cvars[0]))             {                 case 0:                 {                     client_print(id, print_chat, "No podes insultar aca")                 }                 case 1:                 {                     message_begin( MSG_ONE , SVC_DISCONNECT , _ , id );                     write_string( REASONKICK );                     message_end( );                     client_print(id, print_chat, "funcion llamada")                 }             }            }     }         return PLUGIN_CONTINUE } public plugin_cfg(){         new szFilename[136];     new szPath[ 64 ];     get_configsdir(szPath, 63);     format(szFilename, 63, "%s/%s",szPath, ARCHIVEINI);         if (file_exists(szFilename))     {             log_amx("Archivo %s ejecutado correctamente",szFilename);                 new szData[64], iLen, iPos = 0;                         while (Words <= MAX_WORDS && read_file( szFilename, iPos++, szData,63,iLen))         {                     if (iLen == 0 || equal(szData, ";", 1))             {                 continue;             }             copy(szWords[Words],31, szData)             ++Words;                     }     }     else     {         log_amx("Archivo %s No encontrado -- Creando...",szFilename);         write_file(szFilename,";Here go you bad words.");         write_file(szFilename,";Made by Lucas_7_94 From Alliedmods.");         write_file(szFilename,";");         write_file(szFilename,"gay");         // Hasta aca     }     }

fysiks 12-04-2010 18:34

Re: How to work with a file [Help]
 
Quote:

Originally Posted by Callesson (Post 1362848)
Sorry but it's very hard to me to get it just by looking at the code as i'm new to this :/

If you could explain the steps that would be awesome :) ?

Ty

The first steps to learning how to write plugins is learning how to 1. Search, 2. Test, 3. Debug, 4. Repeat.

Callesson 12-05-2010 14:40

Re: How to work with a file [Help]
 
I have searched a lot :P And can't find that much about it...

visar1 12-05-2010 14:56

Re: How to work with a file [Help]
 
spam blocker is the best


All times are GMT -4. The time now is 16:09.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.