Problem with small code
#1

Hi all,i've added a log to the /ban command,but i've a problem:

First,here is the code i've added:

Код:
  new File:log = fopen("bans.log", io_write);
                fwrite(log), "%s banned for %s", giveplayername, reason);
                fclose(log);
And this are the errors:

Код:
C:\Documents and Settings\Symone\Desktop\COD5.pwn(7170) : warning 202: number of arguments does not match definition
C:\Documents and Settings\k\Desktop\COD5.pwn(7170) : warning 215: expression has no effect
C:\Documents and Settings\k\Desktop\COD5.pwn(7170) : warning 215: expression has no effect
C:\Documents and Settings\k\Desktop\COD5.pwn(7170) : warning 215: expression has no effect
C:\Documents and Settings\k\Desktop\COD5.pwn(7170) : error 001: expected token: ";", but found ")"
C:\Documents and Settings\k\Desktop\COD5.pwn(7170) : error 029: invalid expression, assumed zero
C:\Documents and Settings\k\Desktop\COD5.pwn(7170) : warning 215: expression has no effect
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#2

You seem to have made a few errors in your syntax. fwrite does not accept string formatting parameters, you must format a string first and use it then. Like so:

pawn Код:
new string[64];
new File:log = fopen("bans.log", io_write);
format(string,64, "%s banned for %s", giveplayername, reason);
fwrite(log, string);
fclose(log);
Reply
#3

Thank u
Reply
#4

You probably want to change your write mode too.

pawn Код:
fopen("bans.log", io_write)
This will overwrite the contents of bans.log. Everytime you ban someone, it will only have the last ban.
pawn Код:
fopen("bans.log", io_append)
This will add each ban at the end of the file so you have a full list.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)