SA-MP Forums Archive
File path - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: File path (/showthread.php?tid=595396)



File path - TwinkiDaBoss - 02.12.2015

So I got some problems & questions about File path, Im trying to basically open the file upon GameModeInit and close it later on on GameModeExit so I dont have to constantly open the file and close it. Is there a way for it?

Currently what I have it simple

pawn Код:
public SomeLog(LogString[]) {
    new entry[128],Year, Month, Day, Hour, Minute, Second;
    getdate(Year, Month, Day);
    gettime(Hour, Minute, Second);
    format(entry, sizeof(entry), "\r\n[%02d/%02d/%d][%02d:%02d:%02d]%s",Day,Month,Year, Hour, Minute, Second,LogString);
    new File:hFile;
    hFile = fopen("Logs/Admin/Login.log",io_append);
    fwrite(hFile,entry);
    fclose(hFile);
    return true;
}


Now my concern is, is there a way to get file path somehow?
I looked up at https://sampwiki.blast.hk/wiki/File_Functions but couldnt find anything related to it


Re: File path - Crayder - 02.12.2015

I'm confused. What is your question?

First you said you wanted to open/close with the gamemode. That's relatively simple.

pawn Код:
new File:logFile;
public OnGameModeInit() {
    logFile = fopen("Logs/Admin/Login.log",io_append);
    return 1;
}
public OnGameModeExit() {
    fclose(logFile);
    return 1;
}
public SomeLog(LogString[]) {
    new entry[128],Year, Month, Day, Hour, Minute, Second;
    getdate(Year, Month, Day);
    gettime(Hour, Minute, Second);
    format(entry, sizeof(entry), "\r\n[%02d/%02d/%d][%02d:%02d:%02d]%s",Day,Month,Year, Hour, Minute, Second,LogString);
    fwrite(logFile,entry);
    return true;
}
Now, getting a file's path, use the filemanager plugin. I don't see why you would need to do this, unless you're just too damn lazy to do it yourself...


Re: File path - TwinkiDaBoss - 02.12.2015

I need the file path for something else but thats another subject, thanks mate, thats what I also needed