Author Topic: FileExists/WriteFile and FTP  (Read 1252 times)

0 Members and 1 Guest are viewing this topic.

Offline Spasman

  • Major
  • *
  • Posts: 55
FileExists/WriteFile and FTP
« on: February 24, 2008, 09:31:21 pm »
I just rented a server from U13 and I have ftp access to the scripts folder. I had my old server run on an old pc of mine, and everything worked fine until i uploaded it to my new u13 one.

Code: [Select]
if getpiece(text,' ',0) = '/donated' then begin
WriteConsole(ID,GetPlayerStat(strtoint(GetPiece(Text, ' ', 1)),'ip')+' added to donators.',$EE81FAA1);
WriteFile('/scripts/donators/'+GetPlayerStat(strtoint(GetPiece(Text, ' ', 1)),'ip')+'.txt','donated');
end;

What this does is add a file named the Player ID's ip to a folder. It worked on my old server but now it doesnt on the new FTP u13 one. Is there something certain i have to do with the directory name or what?
« Last Edit: February 24, 2008, 09:33:20 pm by Spasman »

Offline mar77a

  • Global Moderator
  • Veteran
  • *****
  • Posts: 1295
  • mad
    • random stuffs
Re: FileExists/WriteFile and FTP
« Reply #1 on: February 25, 2008, 07:31:26 am »
Write permissions?

Offline Spasman

  • Major
  • *
  • Posts: 55
Re: FileExists/WriteFile and FTP
« Reply #2 on: February 25, 2008, 11:16:35 am »
I have them, yes. What I am mainly concerned for though is just checking if the file actually exists.

Offline mar77a

  • Global Moderator
  • Veteran
  • *****
  • Posts: 1295
  • mad
    • random stuffs
Re: FileExists/WriteFile and FTP
« Reply #3 on: February 25, 2008, 12:47:15 pm »
Even though I don't see you using the FileExists function in that snippet, it's a known bug that it doesn't work properly in every operative system.

Offline Spasman

  • Major
  • *
  • Posts: 55
Re: FileExists/WriteFile and FTP
« Reply #4 on: February 25, 2008, 08:01:21 pm »
Yeah, FileExists is in a different part of the script. Here.

Code: [Select]
if Text = '/getmoney' then begin
if (FileExists('scripts/donators/'+GetPlayerStat(ID,'ip')+'.txt')) then begin
WriteConsole(ID,'Here you go, '+GetPlayerStat(ID,'name')+'.',$EE81FAA1);
WriteConsole(ID,'Thanks again for donating!',$EE81FAA1);
zombmoney[ID] := 100000;
end;
end;

Offline sai`ke

  • Camper
  • ***
  • Posts: 318
  • Can't be arsed to remove christmas avatar
Re: FileExists/WriteFile and FTP
« Reply #5 on: March 02, 2008, 06:27:24 am »
Well, on one of the TTW servers (I think it's a selfkill server) FileExists doesn't work either. So I tried a try/except/end structure around the reading section and just returned an empty string on exception, but that fails to properly catch the error. It is still mentioned as an I/O error 103 in console and after a certain number of errors the script is terminated.

So I'd like to know, what is the proper way of circumventing these problems, if there is any?
#soldat.ttw #ttw.gather --- Quakenet!
http://ttwforums.com

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: FileExists/WriteFile and FTP
« Reply #6 on: March 02, 2008, 08:04:38 am »
you could try WriteLnFile something in that file and then read it. If it existed it won't be overwritten, and if it didn't - it would be created. Then just read it and see what's there, you get me ::)

Offline sai`ke

  • Camper
  • ***
  • Posts: 318
  • Can't be arsed to remove christmas avatar
Re: FileExists/WriteFile and FTP
« Reply #7 on: March 02, 2008, 08:42:27 am »
Thanks for the tip. I think that would work yes. I'll implement it later today. +1 for danmer
#soldat.ttw #ttw.gather --- Quakenet!
http://ttwforums.com