public OnPlayerText(playerid, text[])
{
new name[MAX_PLAYER_NAME], File:chatlog[128];
GetPlayerName(playerid, name, sizeof(name));
format(chatlog, sizeof(chatlog), "Logs/Chat/%s.txt", name);
fopen(chatlog, io_readwrite);
new chat[128], chater[128], day, month, year, hour, minute, second;
GetPlayerName(playerid,chater,sizeof(chater));
gettime(hour, minute, second);
getdate(year, month, day);
format(chat,sizeof(chat),"[%d/%d %d %d:%d:%d]: ( %s ): %s\n", day, month, year, hour, minute, second, chater, text);
if(chatlog)
{
if(fexist(chatlog))
{
fwrite(chatlog,chat);
fclose(chatlog);
}
}
return 1;
}
I dont know if you figured it out, but im trying to make a chat log, like when a player chats, it gets written in the file that has same name as the player .txt. And if that file doesnt exist, the server will create it.
|
public OnPlayerText(playerid, text[])
{
new string[128];
new name[24];
GetPlayerName(playerid, name, 24);
new File:log = fopen(string, io_append);
new hour, minute, second, year, month, day;
gettime(hour, minute, second);
getdate(year, month, day);
format(string,sizeof(string), "[%d/%d/%d][%d:%d:%d]%s\r\n", day, month, year, hour, minute, second, text);
fwrite(log, string);
fclose(log);
return 1;
}
pawn Код:
|
public OnPlayerText(playerid, text[])
{
new string[128];
new name[24];
GetPlayerName(playerid, name, 24);
format(string,sizeof(string), "Logs/Chat/%s.txt", name); // THIS WAS THE ERROR
new File:log = fopen(string, io_append);
new hour, minute, second, year, month, day;
gettime(hour, minute, second);
getdate(year, month, day);
format(string,sizeof(string), "[%d/%d/%d][%d:%d:%d]%s\r\n", day, month, year, hour, minute, second, text);
fwrite(log, string);
fclose(log);
return 1;
}
public OnPlayerText(playerid, text[])
{
new name[MAX_PLAYER_NAME], file[128], chat[128], chater[MAX_PLAYER_NAME], year, month, day, hour, minute, second;
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "Logs/Chat/%s.txt", name);
fopen(file, io_readwrite);
GetPlayerName(playerid, chater, sizeof(chater));
gettime(hour, minute, second);
getdate(year, month, day);
format(chat,sizeof(chat),"[%d/%d-%d %d:%d:%d]: ( %s ): %s\n", day, month, year, hour, minute, second, chater, text);
if(file)
{
if(fexist(file))
{
fwrite(file,chat);
fclose(file);
}
}
return 1;
}
C:\Users\Simon\Desktop\samp server rpg\gamemodes\rpg-gm.pwn(609) : error 033: array must be indexed (variable "file") C:\Users\Simon\Desktop\samp server rpg\gamemodes\rpg-gm.pwn(613) : error 035: argument type mismatch (argument 1) C:\Users\Simon\Desktop\samp server rpg\gamemodes\rpg-gm.pwn(614) : error 035: argument type mismatch (argument 1) Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 3 Errors.
if(file)
fwrite(file,chat);
fclose(file);
New version:
pawn Код:
|
I made this already:
pawn Код:
Код:
C:\Users\Simon\Desktop\samp server rpg\gamemodes\rpg-gm.pwn(609) : error 033: array must be indexed (variable "file") C:\Users\Simon\Desktop\samp server rpg\gamemodes\rpg-gm.pwn(613) : error 035: argument type mismatch (argument 1) C:\Users\Simon\Desktop\samp server rpg\gamemodes\rpg-gm.pwn(614) : error 035: argument type mismatch (argument 1) Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 3 Errors. pawn Код:
|
Originally Posted by file.inc
native File:fopen(const name[], filemode: mode = io_readwrite);
|
stock Mytag:ExampleStock();
//You can only do
new Mytag:a;
a = ExampleStock();
//and not
new a;
a = ExampleStock();