AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with read_file please (https://forums.alliedmods.net/showthread.php?t=24828)

[DumB]Steamsucks 03-03-2006 09:08

Help with read_file please
 
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..

p3tsin 03-03-2006 09:20

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)

[DumB]Steamsucks 03-03-2006 09:41

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

p3tsin 03-03-2006 14:33

.. the $moddir, which is for example:
C:\Program Files\Steam\SteamApps\[email protected]\counter-strike\cstrike


All times are GMT -4. The time now is 20:26.

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