AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   write_file "Couldn't create temp file" (https://forums.alliedmods.net/showthread.php?t=146434)

Elusive138 12-28-2010 04:02

write_file "Couldn't create temp file"
 
Hi

I need to be able to read origins from a file and write new origins to the same file. To do this I've used
PHP Code:

format(writeLinecharsmax(writeLine), "%s CT,%f,%f,%f"writeLinegCtOrigin[0], gCtOrigin[1], gCtOrigin[2]) 

to format a string which I then write with
PHP Code:

write_file(gSpawnsFilewriteLinegFileLine

This works when I'm writing a new line (where gFileLine = -1, which means the line didn't exist when I read it) but if I try to overwrite an existing line (gFileLine >= 0), I get an error:
Code:

L 12/28/2010 - 19:52:19: Couldn't create temp file
L 12/28/2010 - 19:52:19: [AMXX] Displaying debug trace (plugin "DefendTheVIP.amxx")
L 12/28/2010 - 19:52:19: [AMXX] Run time error 10: native error (native "write_file")
L 12/28/2010 - 19:52:19: [AMXX]    [0] DefendTheVIP.sma::WriteFile (line

Any help with this would be much appreciated!

Thanks.

ConnorMcLeod 12-28-2010 04:24

Re: write_file "Couldn't create temp file"
 
Do you rent a server ?
I think the problem is more ftp rights than your code.

Elusive138 12-28-2010 04:36

Re: write_file "Couldn't create temp file"
 
It's a listenserver, running on my computer (Vista). My account has "Full Control" over the file in question. I'm pretty sure it's not an access control problem.

I find it easier to test new, half-written plugins on my own computer, not that I have any other server :P

Thanks.

Flipper_SPb 12-28-2010 05:06

Re: write_file "Couldn't create temp file"
 
I think, hlds (or listen server) doesn't have rights to write tmp file in C:\ dir.

Flipper_SPb 12-28-2010 05:12

Re: write_file "Couldn't create temp file"
 
I had the same problem. But I run server with limited access...

Elusive138 12-28-2010 05:13

Re: write_file "Couldn't create temp file"
 
Quote:

Originally Posted by Flipper_SPb (Post 1380765)
I think, hlds (or listen server) doesn't have rights to write tmp file in C:\ dir.

What? If amxmodx needs access above the game directory, just to edit a file (which I remind you I have no problems writing a new line to, just can't overwrite existing lines), then there's something seriously wrong.

EDIT: I just double checked, by forcing full permissions for the root drive, and "Run As Administrator". Still no.. sorry.

ConnorMcLeod 12-28-2010 05:47

Re: write_file "Couldn't create temp file"
 
When you overwrite a line, amxx needs to create a temp file to copy original file datas, and then the original file is completely rewritten.

Code:

        // adding a new line in a middle of already existing file
        FILE* pTemp;
        char buffor[2048];

        if ((pTemp = tmpfile()) == NULL)
        {
                LogError(amx, AMX_ERR_NATIVE, "Couldn't create temp file");
                return 0;
        }


Elusive138 12-28-2010 05:55

Re: write_file "Couldn't create temp file"
 
Do you know where that temp file is created and/or why I can't seem to create one?

Also, if anyone has an alternative method to save (modifiable) origins for spawning entities?

Thanks!

Flipper_SPb 12-28-2010 08:32

Re: write_file "Couldn't create temp file"
 
Quote:

Originally Posted by Elusive138 (Post 1380786)
Do you know where that temp file is created


For Windows XP/2003 it is root of system partition (С:\)
Not sure with Win Vista/7

Exolent[jNr] 12-28-2010 13:18

Re: write_file "Couldn't create temp file"
 
Quote:

Originally Posted by Elusive138 (Post 1380786)
Do you know where that temp file is created and/or why I can't seem to create one?

Also, if anyone has an alternative method to save (modifiable) origins for spawning entities?

Thanks!

Maybe because you don't have specific permissions to write in that directory?

The alternative would be to use the new file natives (fopen, fputs, etc.).
When saving, read the whole file data into variables, then write to the file again with all of the updated data.


All times are GMT -4. The time now is 01:58.

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