Raised This Month: $51 Target: $400
 12% 

How to work with a file [Help]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Callesson
Member
Join Date: Jan 2010
Old 12-04-2010 , 08:35   How to work with a file [Help]
Reply With Quote #1

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")
__________________

Last edited by Callesson; 12-04-2010 at 08:37. Reason: Miss
Callesson is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-04-2010 , 08:52   Re: How to work with a file [Help]
Reply With Quote #2

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.
__________________
Bugsy is offline
Callesson
Member
Join Date: Jan 2010
Old 12-04-2010 , 09:06   Re: How to work with a file [Help]
Reply With Quote #3

Okey i'm gonna check
Thank you!
__________________
Callesson is offline
Callesson
Member
Join Date: Jan 2010
Old 12-04-2010 , 10:05   Re: How to work with a file [Help]
Reply With Quote #4

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
__________________
Callesson is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 12-04-2010 , 10:16   Re: How to work with a file [Help]
Reply With Quote #5

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     }     }
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-04-2010 , 18:34   Re: How to work with a file [Help]
Reply With Quote #6

Quote:
Originally Posted by Callesson View Post
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.
__________________
fysiks is offline
Callesson
Member
Join Date: Jan 2010
Old 12-05-2010 , 14:40   Re: How to work with a file [Help]
Reply With Quote #7

I have searched a lot And can't find that much about it...
__________________
Callesson is offline
visar1
Member
Join Date: Nov 2009
Old 12-05-2010 , 14:56   Re: How to work with a file [Help]
Reply With Quote #8

spam blocker is the best
visar1 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:35.


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