Raised This Month: $ Target: $400
 0% 

Help with read_file please


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
[DumB]Steamsucks
Junior Member
Join Date: Feb 2006
Location: uk
Old 03-03-2006 , 09:08   Help with read_file please
Reply With Quote #1

Code:
#include <amxmodx> #include <amxmisc> #include <file> new saytext[192] new inifile[101] new readdata[401]         // the data on the line it is reading new col1[101]               // the first bit of the line new col2[101]               // the second bit of the line new col3[101]               // the third bit of the line new col4[101]               // the third bit of the line   new linelength = 0       // how long the line is new currline=0 public plugin_init() {     register_plugin("Speak English", "0.1a", "[DumB]SteamSucks")         register_clcmd("say", "cmd_say")     register_clcmd("say_team", "cmd_sayteam")         inifile ="words.txt"    } public cmd_say(id)     {     new arg[192]     read_args(arg, 191)     remove_quotes(arg) // Say Message are encase in Quotes           while(read_file(inifile,currline,readdata,400,linelength) != 0){  //checks every line in inifile, stores what it finds in readdata, and what line its on in currline         parse(readdata,col1,100,col2,100,col3,100,col4,100)   //reads the data on each line and stores it in col1 etc.         if( containi(arg,col1) || containi(arg,col2) || containi(arg,col3)) {         server_print("user would be getting booted now")             return PLUGIN_HANDLED         }         currline++ //goes to the next line       }     PLUGIN_HANDLED }

the ini file is like this
Code:
testword1 testword2 testword3 testword4
testword5 testword6 testword7 testword8
the ini file is tabbed spaces

and the error i get is

Code:
L 03/03/2006 - 14:00:57: [AMXX] Displaying debug trace (plugin "SpeakEnglish.amxx")
L 03/03/2006 - 14:00:57: [AMXX] Run time error 10: native error (native "read_file")
L 03/03/2006 - 14:00:57: [AMXX]    [0] SpeakEnglish.sma::cmd_say (line 32)
line 32 code is

Code:
while(read_file(inifile,currline,readdata,400,linelength) != 0){  //checks every line in inifile, stores what it finds in readdata, and what line its on in currline
any ideas guys whats going wrong and why please


regards..
__________________
If it works then i wrote it if it erros on less then 50 lines i had help with it if it breaks totally it wasnt me..
[DumB]Steamsucks is offline
Send a message via MSN to [DumB]Steamsucks
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 03-03-2006 , 09:20  
Reply With Quote #2

i would guess that u dont have words.txt file in ur $moddir
or as ure not resetting currline every time cmd_say() is called the plugin may try to read line 3 (which doesnt exist)
__________________
plop
p3tsin is offline
[DumB]Steamsucks
Junior Member
Join Date: Feb 2006
Location: uk
Old 03-03-2006 , 09:41  
Reply With Quote #3

Quote:
Originally Posted by p3tsin
i would guess that u dont have words.txt file in ur $moddir
or as ure not resetting currline every time cmd_say() is called the plugin may try to read line 3 (which doesnt exist)
this happens the first time i say anything and the dirs i have tried to put the wrods.txt in are

dedicated server\cstrike\addons\amxmodx\configs
dedicated server\cstrike\addons\amxmodx\plugins
dedicated server\cstrike\addons\amxmodx\modules

but to no avail

i also added

Code:
        currline++ //goes to the next line       }     currline = 0 // reset to line 0     PLUGIN_HANDLED }

if i just call "somefile.extension" with no dir structure what dir / dirs will it check for that file
__________________
If it works then i wrote it if it erros on less then 50 lines i had help with it if it breaks totally it wasnt me..
[DumB]Steamsucks is offline
Send a message via MSN to [DumB]Steamsucks
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 03-03-2006 , 14:33  
Reply With Quote #4

.. the $moddir, which is for example:
C:\Program Files\Steam\SteamApps\[email protected]\counter-strike\cstrike
__________________
plop
p3tsin 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 20:26.


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