AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   read from file and print in chat (https://forums.alliedmods.net/showthread.php?t=58682)

Ltv 07-31-2007 14:19

read from file and print in chat
 
Hi all.

Tell me please how to make this... I have a file where stored data in a column and i want when i write command in game, this data from file print_chat in a line.

I tried to make, but at me it turns out only in a column.

stupok 07-31-2007 15:20

Re: read from file and print in chat
 
I suggest posting your code, because I don't know exactly what you want to do. Maybe this will help:

Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "Example" #define VERSION "1.0" #define AUTHOR "stupok69" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_clcmd("command", "print_from_file", ADMIN_KICK) } public print_from_file(id, level, cid) {     if(!cmd_access(id, level, cid, 1))         return PLUGIN_HANDLED         new file = fopen("filepath", "rt")         if(file)     {         new buffer[256]                 while(!feof(file))         {             fgets(file, buffer, 255)                         if(contain(buffer, "something") != -1)             {                 //we found "something"                 client_print(id, print_chat, buffer)             }         }     }         fclose(file)         return PLUGIN_HANDLED }

Ltv 07-31-2007 17:23

Re: read from file and print in chat
 
Well, may be bad have explained.

One file contain and have this structure

Code:


de_dust
de_aztec
cs_italy
de_prodigy
...

And what i want, when i type in console "command". In game in chat write in line.

Code:


* de_dust de_aztec cs_italy de_prodigy ...


stupok 07-31-2007 19:41

Re: read from file and print in chat
 
I think this should do it:

Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "Example" #define VERSION "1.0" #define AUTHOR "stupok69" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_clcmd("command", "print_from_file", ADMIN_KICK) } public print_from_file(id, level, cid) {     if(!cmd_access(id, level, cid, 1))         return PLUGIN_HANDLED         new file = fopen("filepath", "rt")         new text[256], textlen     if(file)     {         new buffer[256]                 while(!feof(file))         {             fgets(file, buffer, 255)                         if(buffer[0])             {                 textlen += format(text[textlen], 255-textlen, "%s ", buffer)             }         }     }         fclose(file)         client_print(id, print_chat, "* %s", text)         return PLUGIN_HANDLED }

Ltv 08-01-2007 09:18

Re: read from file and print in chat
 
I have change "filepatch" to "amxmodx/configs/text.txt" (In text.txt data)And this doesn't work, write only "*".

stupok 08-01-2007 12:41

Re: read from file and print in chat
 
"addons/amxmodx/configs/text.txt"

Ltv 08-01-2007 13:40

Re: read from file and print in chat
 
Has made filepatch - "addons/amxmodx/configs/text.txt", and this doesn't work, write only "*". :(

Deviance 08-01-2007 13:45

Re: read from file and print in chat
 
Code:
register_clcmd("command", "print_from_file", ADMIN_KICK)
->
Code:
register_concmd("command", "print_from_file", ADMIN_KICK)

Zenith77 08-01-2007 13:48

Re: read from file and print in chat
 
Quote:

Originally Posted by Deviance (Post 511109)
Code:
register_clcmd("command", "print_from_file", ADMIN_KICK)
->
Code:
register_concmd("command", "print_from_file", ADMIN_KICK)

Do I kill you now, or do I kill you now?

Deviance 08-01-2007 13:53

Re: read from file and print in chat
 
Quote:

Originally Posted by Zenith77 (Post 511112)
Do I kill you now, or do I kill you now?

If you got nothing better to type, then shut up.


All times are GMT -4. The time now is 11:10.

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