Problem with small code - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with small code (
/showthread.php?tid=191226)
Problem with small code -
Face9000 - 18.11.2010
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.
Re: Problem with small code -
JaTochNietDan - 18.11.2010
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);
Re: Problem with small code -
Face9000 - 18.11.2010
Thank u
Re: Problem with small code -
randomkid88 - 18.11.2010
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.