dcmd_suspend - help please
#1

Okey, I've made this:

pawn Код:
dcmd_suspend(playerid, params[])
    {
      if(PlayerInfo[playerid][pAdmin] < 1) return 1;
      new id, string[512], server[128], reason, ban[50], ip[50];
    if(sscanf(params,"us",id,reason)) return SendHelpMessage(playerid, ".: Usage: /suspend [playerid/partofname] [reason] :.");
    if(id == INVALID_PLAYER_ID) return SendErrorMessage(playerid, ".: Info: Player not found :.");
    GetPlayerIp(id, ip, sizeof(ip));
        format(server,sizeof(server), "* %s %s(%d) Account BANNED %s(%d).  Reason: %s.  %s *", AdminRankName(playerid), pName(playerid), playerid, pName(id), id, reason, date());
        SendClientMessageToAll(COLOR_DARKRED, server);
        format(ban, sizeof(ban), "%s\r\n", pName(id));
        new File:write = fopen("CLRP/Bans.ban", io_append);
        fwrite(write,ban);
        fclose(write);
        format(string, sizeof(string), "%s %s %s(%d) Account BANNED %s(%d)-(%s). Reason: %s\r\n", date(), AdminRankName(playerid), pName(playerid), playerid, pName(id), id, ip, reason);
        new File:Bans = fopen("logs/bans.txt", io_append);
        fwrite(Bans,string);
        fclose(Bans);
        Kick(id);
    return 1;
    }
And it writes everything nicely, except the .txt file which looks like this:

Код:
[2010/06/23 - 00:15:55] Owner Peter_Johnson(0) Account BANNED Peter_Johnson(0)-(127.0.0.1). Reason: T* Owner Peter_Johnson(0) Account BANNED Peter_Johnson(0).  Reason: Testing.  [2010/06/23 - 00:15:55] *
Someone knows why?
Reply
#2

yep coz when you write to the file lots of times you need to

open the file
read the file looking for a blank line
then write it there
Reply
#3

Quote:
Originally Posted by (SF)Noobanatior
yep coz when you write to the file lots of times you need to

open the file
read the file looking for a blank line
then write it there
Fixed! by making "reason" to "reason[128]"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)