28.06.2012, 21:03
(
Последний раз редактировалось milanosie; 29.06.2012 в 22:24.
)
REMOVED
TOTAL BULLCRAP I POSTED.
TOTAL BULLCRAP I POSTED.
Do you know WHY people claim that dini isn't a very good file system? Because it's slow! Why is it slow? Because it opens, writes, and closes, the file for EVERY operation instead of buffering data for more efficient writes. You figure out why I'm telling you this.
Also, we have a shiny new "Includes" forum - I moved this one there but you might want to pay more attention in the future. |
new File:cmdlog = fopen("logs/commands.txt", io_append); fwrite(cmdlog, text); fwrite(cmdlog, "\r\n"); fclose(cmdlog);
new logline[MAX_PLAYERS][10][128];
new logamount[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
logamount[playerid] = 0;
canpm[playerid] = 1;
return 1;
}
forward writecmdlog(text[]);
stock writecmdlog(text[])
{
if(logamount[playerid] < 10)
{
logamount[playerid] ++;
format(logline[playerid][logamount[playerid]], sizeof(logline[playerid][logamount[playerid]]), text);
}
else
{
new File:cmdlog = fopen("logs/commands.txt", io_append);
for(new i=1; i<11; i++)
{
fwrite(cmdlog, logline[playerid][i]);
fwrite(cmdlog, "\r\n");
}
fclose(cmdlog);
}
return 1;
}
forward GetFirstName(playerid);
stock GetFirstName(playerid)
{
new name[MAX_PLAYER_NAME],pos;
GetPlayerName(iPlayer, name, MAX_PLAYER_NAME);
pos = strfind(name, "_");
strdel(name, pos, 24), strins(name, " ", iUSPos, 24);
return name;
}
name[pos] = EOS;
// or
name[pos] = '\0';
Hey. For starters, did you actually try compiling with the include?
I might be mistaken, but I think iUSPos is undefined in the function below. Also, stock functions do not need to be forwarded! pawn Код:
Additionally, as a small thing to remember, you do not need to use strdel if you're deleting the end of a string. You can terminate the string otherwise: pawn Код:
|
static
pos
;
pos = strfind(name, "_");
if(pos > 2) {
name[pos] = '\0';
return name;
}
Do you know WHY people claim that dini isn't a very good file system? Because it's slow! Why is it slow? Because it opens, writes, and closes, the file for EVERY operation instead of buffering data for more efficient writes. You figure out why I'm telling you this.
Also, we have a shiny new "Includes" forum - I moved this one there but you might want to pay more attention in the future. |
new File:cmdlog;
public OnGameModeInit()
{
cmdlog = fopen("logs/commands.txt", io_append);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
fwrite(cmdlog, cmdtext);
fwrite(cmdlog, "\r\n");
return 0;
}
public OnGameModeExit()
{
fclose(cmdlog);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new File:cmdlog = fopen("logs/commands.txt", io_append);
fwrite(cmdlog, cmdtext);
fwrite(cmdlog, "\r\n");
fclose(cmdlog);
return 0;
}