SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 26/02/2014, 07:05 PM   #1
BlackAnt
Little Clucker
 
BlackAnt's Avatar
 
Join Date: Feb 2014
Location: Romania
Posts: 20
Reputation: 0
Default Which is the best way to save chat logs/command logs, etc?

Hello guys! I have searched all day for the best method to save chat logs (only the players' texts), command log (only the commands) and so on. Till now, I have found a way, but isn't working.

So, which is the best way to save these logs? And how about the .txt files, where do I save them?
BlackAnt is offline   Reply With Quote
Old 26/02/2014, 07:10 PM   #2
Blademaster680
Gangsta
 
Blademaster680's Avatar
 
Join Date: Jul 2013
Location: On my Yamaha R6
Posts: 607
Reputation: 26
Default Re: Which is the best way to save chat logs/command logs, etc?

Try this tutorial http://forum.sa-mp.com/showthread.php?t=160593
__________________

Blademaster680 is offline   Reply With Quote
Old 27/02/2014, 08:12 PM   #3
BlackAnt
Little Clucker
 
BlackAnt's Avatar
 
Join Date: Feb 2014
Location: Romania
Posts: 20
Reputation: 0
Default Re: Which is the best way to save chat logs/command logs, etc?

So, i followed that tutorial, but my console crashes after I log in and type something, and the logs are still empty.

This is what I have in my script (exactly this order):

Code:
#include <file>
Code:
forward ChatLog(chattext[]);
Code:
public ChatLog(chattext[])
{
new entry[300],day,month,year,second,hour,minute, File:hFile;
gettime(hour,minute,second);
getdate(year,month,day);
format(entry,sizeof(entry),"[%02d/%02d/%04d %02d:%02d:%02d] %s\n",day, month, year, hour, minute, second, chattext);
hFile = fopen("Logs/chat.txt",io_append);
fwrite(hFile,entry);
fclose(hFile);
}
Code:
public OnPlayerText(playerid, text[])
{
new textv2[128], pname[25], Float:x, Float:y, Float:z, chattext[300];
GetPlayerName(playerid,pname,24);
GetPlayerPos(playerid,x,y,z);
format(textv2,sizeof(textv2), "%s says: %s", pname, text);
for(new i=0;i<MAX_PLAYERS;i++)
{
	if(IsPlayerInRangeOfPoint(i,100.0,x,y,z))
	{
		SendClientMessage(i,COL_WHITE,textv2);
		format(chattext,sizeof(chattext),"%s",textv2);
		ChatLog(chattext);
	}
}
return 0;
}
And this is my crash info:

Code:
[23:14:57] Incoming connection: 127.0.0.1:54308
[23:14:57] [join] BlackThief has joined the server (0:127.0.0.1)
[23:15:03] [debug] Server crashed while executing test0.1.amx
[23:15:03] [debug] AMX backtrace:
[23:15:03] [debug] #0 native fwrite () [004056e0] from samp-server.exe
[23:15:03] [debug] #1 000096d4 in public ChatLog (0x0002f770) from test0.1.amx
[23:15:03] [debug] #2 0000c34c in public OnPlayerText (0x00000000, 0x0002bea8) from test0.1.amx
[23:15:03] [debug] Native backtrace:
[23:15:03] [debug] #0 77ed3632 in ?? () from C:\Windows\SYSTEM32\ntdll.dll
[23:15:03] [debug] #1 00493990 in ?? () from samp-server.exe
[23:15:03] [debug] #2 0040531e in ?? () from samp-server.exe
What's wrong here? I can't figure out. Maybe I ommited something in the tutorials. Please help me.
BlackAnt is offline   Reply With Quote
Old 27/02/2014, 08:16 PM   #4
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,982
Reputation: 1392
Default Re: Which is the best way to save chat logs/command logs, etc?

Replace:
pawn Code:
hFile = fopen("Logs/chat.txt",io_append);
fwrite(hFile,entry);
fclose(hFile);
with:
pawn Code:
hFile = fopen("Logs/chat.txt",io_append);
if (hFile)
{
    fwrite(hFile,entry);
    fclose(hFile);
}

I already mentioned that it can crash the server in that thread. It's good to read the comments before using something!
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Old 27/02/2014, 08:53 PM   #5
BlackAnt
Little Clucker
 
BlackAnt's Avatar
 
Join Date: Feb 2014
Location: Romania
Posts: 20
Reputation: 0
Default Re: Which is the best way to save chat logs/command logs, etc?

Quote:
Originally Posted by Konstantinos View Post
Replace:

I already mentioned that it can crash the server in that thread. It's good to read the comments before using something!
Ok, now is not crashing anymore, but the text doesn't appear in my chat.txt file. Can you tell me why? It is located in Server > Logs > chat.txt

Thank you anyway!
BlackAnt is offline   Reply With Quote
Old 27/02/2014, 08:59 PM   #6
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,982
Reputation: 1392
Default Re: Which is the best way to save chat logs/command logs, etc?

Make sure scriptfiles folder is writeable (the permissions).
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Old 27/02/2014, 09:09 PM   #7
BlackAnt
Little Clucker
 
BlackAnt's Avatar
 
Join Date: Feb 2014
Location: Romania
Posts: 20
Reputation: 0
Default Re: Which is the best way to save chat logs/command logs, etc?

Thank you, is working now.
BlackAnt 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
Chat logs DerickClark Scripting Help 2 18/01/2014 01:28 AM
: I need to save my ban logs, reasons fuem1907 Scripting Help 7 07/07/2012 08:45 PM
Easiest way to save to logs? captainjohn Scripting Help 2 29/03/2012 10:20 PM
[HELP] Stuff won't save when player logs out zouyun Help Archive 1 04/07/2011 09:32 PM
Chat logs slowride326 Client Support 2 09/01/2011 03:29 AM


All times are GMT. The time now is 01:14 PM.


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