Raised This Month: $ Target: $400
 0% 

[ES] Escribir y leer en un txt


  
 
 
Thread Tools Display Modes
Author Message
shinoda
Spanish Moderator
Join Date: Nov 2009
Location: ag_crossfire
Old 01-15-2010 , 10:41   [ES] Escribir y leer en un txt
#1

PHP Code:
register_concmd("amx_agregar","agregar_palabra"ADMIN_RCON"<Palabra>")

public 
agregar_palabra(id) {
// Como hago para que esa palabra sea escrita en un txt ??? 
Luego como hago para que el plugin lea ese txt

PHP Code:
public client_connect(id) {
    new 
name[32]
    
get_user_name(idname32)
    for(
i=0i<sizeof(/*LO_QUE_CONTIENE_EL_TXT*/); i++) {
        if(
equali(name/*LO_QUE_CONTIENE_EL_TXT[i]*/)) {
        
server_cmd("kick %s"name)
    }

por ejemplo: yo escribo mediante el comando amx_agregar gayzito, la palabra gayzito se escribe en un txt, luego que el plugin lea todas las palabras que contiene el txt y si una de esas palabras es identico al nick de un jugador que haga el kick.
__________________
Oh hell no this shit is awesome !!!
shinoda is offline
Send a message via MSN to shinoda Send a message via Skype™ to shinoda
01101101
BANNED
Join Date: Nov 2009
Location: 9`su 09`n0n7e`r0f76a
Old 01-15-2010 , 17:23   Re: [ES] Escribir y leer en un txt
#2

Guiate con esto

http://forums.alliedmods.net/showpos...2&postcount=10
01101101 is offline
shinoda
Spanish Moderator
Join Date: Nov 2009
Location: ag_crossfire
Old 01-15-2010 , 19:00   Re: [ES] Escribir y leer en un txt
#3

Quote:
Originally Posted by 01101101 View Post
Ok, probare...
__________________
Oh hell no this shit is awesome !!!
shinoda is offline
Send a message via MSN to shinoda Send a message via Skype™ to shinoda
g_often
Senior Member
Join Date: Jan 2010
Location: In your mind
Old 01-15-2010 , 20:02   Re: [ES] Escribir y leer en un txt
#4

PHP Code:
#include <amxmodx>
#include <amxmisc>

new g_insultos[32]

public 
plugin_init() cargar_insultos()

public 
client_connect(id) {
    new 
name33 ]
    for(new 
g_insultos[i] ; i++) 
    {
        
get_user_name(iname32)
        if(
equali(nameg_insultos) != -1)
            
server_cmd("kick %s"name)
    }
}

public 
cargar_insultos() 
{
    new 
archivo[32], file_insultos[64]
    
get_configsdir(archivo,31)
    
formatex(file_insultos,63,"%s/insultos.ini"archivo)
    if(
file_exists(file_insultos)) 
    {
        new 
linea[128], file fopen(file_insultos"rt")
        while(
file && !feof(file)) 
        {
            
fgets(filelinea127)
            
            
// Nos salteamos las lineas vacias, puntos y comas y //
            
if ((linea[0] == '/' && linea[1] == '/') || linea[0] == ';' || strlen(linea) < 1) continue
            
            for(new 
get_maxplayers() ; i++) copy(g_insultos[i++], 31linea)
        }
        if(
filefclose(file)
    }

no sé si esto funciona pero lo más probable es que no.
g_often is offline
01101101
BANNED
Join Date: Nov 2009
Location: 9`su 09`n0n7e`r0f76a
Old 01-15-2010 , 20:04   Re: [ES] Escribir y leer en un txt
#5

Quote:
Originally Posted by g_often View Post
PHP Code:
#include <amxmodx>
#include <amxmisc>

new g_insultos[32]

public 
plugin_init() cargar_insultos()

public 
client_connect(id) {
    new 
name33 ]
    for(new 
g_insultos[i] ; i++) 
    {
        
get_user_name(iname32)
        if(
equali(nameg_insultos) != -1)
            
server_cmd("kick %s"name)
    }
}

public 
cargar_insultos() 
{
    new 
archivo[32], file_insultos[64]
    
get_configsdir(archivo,31)
    
formatex(file_insultos,63,"%s/insultos.ini"archivo)
    if(
file_exists(file_insultos)) 
    {
        new 
linea[128], file fopen(file_insultos"rt")
        while(
file && !feof(file)) 
        {
            
fgets(filelinea127)
            
            
// Nos salteamos las lineas vacias, puntos y comas y //
            
if ((linea[0] == '/' && linea[1] == '/') || linea[0] == ';' || strlen(linea) < 1) continue
            
            for(new 
get_maxplayers() ; i++) copy(g_insultos[i++], 31linea)
        }
        if(
filefclose(file)
    }

no sé si esto funciona pero lo más probable es que no.
No no va a andar. Fijate como hice el mio.
01101101 is offline
Bailopan.
BANNED
Join Date: Jan 2010
Old 01-15-2010 , 20:06   Re: [ES] Escribir y leer en un txt
#6

Quote:
Originally Posted by 01101101 View Post
No no va a andar. Fijate como hice el mio.
Esta para el culo nunca registraste los "gaber"
Bailopan. is offline
g_often
Senior Member
Join Date: Jan 2010
Location: In your mind
Old 01-15-2010 , 20:08   Re: [ES] Escribir y leer en un txt
#7

Quote:
Originally Posted by 01101101 View Post
No no va a andar. Fijate como hice el mio.
umm ok
g_often is offline
01101101
BANNED
Join Date: Nov 2009
Location: 9`su 09`n0n7e`r0f76a
Old 01-15-2010 , 20:08   Re: [ES] Escribir y leer en un txt
#8

El array esta mal hecho. Tiene que ser de dos dimensions, o mejor, con arraydinamicas (mi segundo ejemplo)
01101101 is offline
Bailopan.
BANNED
Join Date: Jan 2010
Old 01-15-2010 , 20:14   Re: [ES] Escribir y leer en un txt
#9

Quote:
Originally Posted by 01101101 View Post
El array esta mal hecho. Tiene que ser de dos dimensions, o mejor, con arraydinamicas (mi segundo ejemplo)
Sos mogolico o te haces? Nunca registraste la variable como queres que ande rubio pelotudo
Bailopan. is offline
shinoda
Spanish Moderator
Join Date: Nov 2009
Location: ag_crossfire
Old 01-15-2010 , 20:33   Re: [ES] Escribir y leer en un txt
#10

PHP Code:
#include <amxmodx>
#include <amxmisc>

new const mensaje_kick[] = "Kickeado por putear"
new Array:g_insultos

public plugin_init() 
{
    
register_plugin("insulto = Kick""0.0.1""g_often")
    
register_clcmd("say""block_insultos")
    
register_clcmd("say_team""block_insultos")
    
g_insultos ArrayCreate(321)
    
cargar_insultos()
}

public 
block_insultos(index)
{
    new 
Args[621], buffer[32]
    
read_args(Args620)
    
    for(new 
ArraySize(g_insultos) ; i++)
    {
        
ArrayGetString(g_insultosibuffer31)
        if(
containi(Argsbuffer) != -1)
        {
            
emessage_begin(MSG_ONESVC_DISCONNECT_index)
            
ewrite_stringmensaje_kick )
            
emessage_end()
            return 
1
        
}
    }
    return 
0
}  


public 
cargar_insultos() 
{
    new 
archivo[32], file_insultos[64]
    
get_configsdir(archivo,31)
    
formatex(file_insultos,63,"%s/insultos.ini"archivo)
    if(
file_exists(file_insultos)) 
    {
        new 
linea[128]
        new 
file fopen(file_insultos"rt")
        while(
file && !feof(file)) 
        {
            
fgets(filelinea127)
            
            
// Nos salteamos las lineas vacias, puntos y comas y //
            
if ((linea[0] == '/' && linea[1] == '/') || linea[0] == ';' || strlen(linea) < 1) continue
            
            
ArrayPushString(g_insultoslinea)
        }
        if(
filefclose(file)
    }

al escribir en el insultos.ini por ejemplo:
pete
gay
puto
caca
goku

El plugin solo me lee la ultima linea, osea "goku" =S
__________________
Oh hell no this shit is awesome !!!
shinoda is offline
Send a message via MSN to shinoda Send a message via Skype™ to shinoda
 



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 19:35.


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