SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 13/01/2017, 12:44 PM   #1
Ahmed21
Big Clucker
 
Join Date: Jul 2016
Posts: 158
Reputation: 3
Default My admin log

Hello, I've made simple & basic admin log. It creates a file and writes in it.

Problem:
It is supposed to write in the file and then make a new line, but it's writing everything in same line. I mean, there is no different if I keep that \n or I remove it.

Script:
PHP Code:
forward adminLog(logstring[]);
public 
adminLog(logstring[])
{
    new 
File:hFile;
    new 
entry[256];
    
format(entrysizeof(entry), "%s\n",logstring);
    
hFile fopen("Logs/admin_log.log"io_append);
    
fwrite(hFileentry);
    
fclose(hFile);

Ahmed21 is offline   Reply With Quote
Old 13/01/2017, 12:57 PM   #2
Lordzy
High-roller
 
Lordzy's Avatar
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,698
Reputation: 1177
Default Re: My admin log

Quote:
Originally Posted by SAMPWiki
A little explanation about the escape codes; the "\n" will begin a new line, and the \r makes sure it starts at the beginning, not somewhere in the middle of a line, so it wont end up like
Try adding "\r" before "\n". But still your code is supposed to generate a new line, which may not write from beginning. I'm also suggesting you to check if the file handle is valid before using fwrite and fclose.
__________________
Currently inactive - I don't play at any SA-MP servers nor work on anything in PAWN for now. The projects that I've done so far in PAWN, which requires updates will be taking some time.
Lordzy is offline   Reply With Quote
Old 13/01/2017, 12:59 PM   #3
Ahmed21
Big Clucker
 
Join Date: Jul 2016
Posts: 158
Reputation: 3
Default Re: My admin log

Quote:
Originally Posted by Lordzy View Post
Try adding "\r" before "\n". But still your code is supposed to generate a new line, which may not write from beginning. I'm also suggesting you to check if the file handle is valid before using fwrite and fclose.
Amazing, thank you, it worked! +REP'd
Ahmed21 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ADMIN FS++]Aro's Admin!! [45+cmds] Account Saving System!!!!! matt2127 Filterscripts 31 04/09/2014 11:20 AM
[FilterScript] mzAdmin - Admin/Donor System | 20+ Admin Commands [v1] mobiliz Filterscripts 11 28/05/2014 09:39 AM
You can spawn a jetpack and admin commands without admin rights Goldino Scripting Help 14 25/01/2013 07:58 PM
V-ADMIN LOGIN HELP: NO REPLY IN V-ADMIN TOPIC: PLEASE HELP RE-OPEN MY SERVER!!!! wilcock33 Help Archive 1 19/08/2009 02:19 PM


All times are GMT. The time now is 09:10 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.