[code]dlabmap:SetText( file.Read( "mapfiles/"..game.GetMap()..".txt", "DATA" ) )[/code]
This is a code I'm using in a DLabel to try and make one of my labels load certain text depending on the map. However, upon using this code, I'm getting this error(line 237 is the line shown above in code tags)
[code]
[ERROR] addons/rebelsvscombine/gamemodes/infiltrate/gamemode/cl_init.lua:237: bad argument #1 to 'SetText' (string expected, got no value)
1. SetText - [C]:-1
2. unknown - addons/rebelsvscombine/gamemodes/infiltrate/gamemode/cl_init.lua:237
Couldn't Load Init Script: 'infiltrate/gamemode/cl_init.lua'
[/code]
What am I doing wrong with file.Read?
In case you know, the text file I have in my mapfiles folder called gm_construct.txt is this:
[code]"Testing!"[/code]
What's wrong?
Just so you know, this is the EXACT directory of my .txt file:
GarrysMod/garrysmod/addons/rebelsvscombine/mapfiles/[b]gm_construct.txt[/b]
It's that file in the client inside
garrysmod/garrysmod/mapfiles/gm_construct.txt?
[QUOTE=gonzalolog;47892959]It's that file in the client inside
garrysmod/garrysmod/mapfiles/gm_construct.txt?[/QUOTE]
No. It's in my addon's file.
[QUOTE=A Fghtr Pilot;47892985]No. It's in my addon's file.[/QUOTE]
It should be ~/data/maplists/gm_construct.txt
[QUOTE=code_gs;47893067]It should be ~/data/maplists/gm_construct.txt[/QUOTE]
Uhh.... How would I create the maplists file in the data folder and then write my default files in it? I know of file.Write but putting it all together sort of confuses me
[QUOTE=A Fghtr Pilot;47893210]Uhh.... How would I create the maplists file in the data folder and then write my default files in it? I know of file.Write but putting it all together sort of confuses me[/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/file/CreateDir]file.CreateDir[/url]
Look at the file table next time :v
[QUOTE=gonzalolog;47892959]It's that file in the client inside
garrysmod/garrysmod/mapfiles/gm_construct.txt?[/QUOTE]
What he means by this is that file.Read will attempt to read files in the CLIENT'S data directory, not the SERVER'S, if called clientside. You need to create a file clientside if you want that to work. As Kevlon said, just use file.CreateDir and then file.Write. Also, those two functions can only be used in the data folder, so all paths should be relative to the data directory.
Sorry, you need to Log In to post a reply to this thread.