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

read from file and print in chat


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ltv
Junior Member
Join Date: Jul 2007
Old 07-31-2007 , 14:19   read from file and print in chat
Reply With Quote #1

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.
Ltv is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 07-31-2007 , 15:20   Re: read from file and print in chat
Reply With Quote #2

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 }
__________________
stupok is offline
Ltv
Junior Member
Join Date: Jul 2007
Old 07-31-2007 , 17:23   Re: read from file and print in chat
Reply With Quote #3

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 ...
Ltv is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 07-31-2007 , 19:41   Re: read from file and print in chat
Reply With Quote #4

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 }
__________________
stupok is offline
Ltv
Junior Member
Join Date: Jul 2007
Old 08-01-2007 , 09:18   Re: read from file and print in chat
Reply With Quote #5

I have change "filepatch" to "amxmodx/configs/text.txt" (In text.txt data)And this doesn't work, write only "*".
Ltv is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 08-01-2007 , 12:41   Re: read from file and print in chat
Reply With Quote #6

"addons/amxmodx/configs/text.txt"
__________________
stupok is offline
Ltv
Junior Member
Join Date: Jul 2007
Old 08-01-2007 , 13:40   Re: read from file and print in chat
Reply With Quote #7

Has made filepatch - "addons/amxmodx/configs/text.txt", and this doesn't work, write only "*".
Ltv is offline
Deviance
Veteran Member
Join Date: Nov 2004
Location: Sweden
Old 08-01-2007 , 13:45   Re: read from file and print in chat
Reply With Quote #8

Code:
register_clcmd("command", "print_from_file", ADMIN_KICK)
->
Code:
register_concmd("command", "print_from_file", ADMIN_KICK)
Deviance is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 08-01-2007 , 13:48   Re: read from file and print in chat
Reply With Quote #9

Quote:
Originally Posted by Deviance View Post
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?
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Deviance
Veteran Member
Join Date: Nov 2004
Location: Sweden
Old 08-01-2007 , 13:53   Re: read from file and print in chat
Reply With Quote #10

Quote:
Originally Posted by Zenith77 View Post
Do I kill you now, or do I kill you now?
If you got nothing better to type, then shut up.
Deviance 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:08.


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