SA-MP Forums Archive
argument type mismatch????? - 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)
+--- Thread: argument type mismatch????? (/showthread.php?tid=633427)



argument type mismatch????? - Miladinovic - 30.04.2017

PHP код:
new File:handle fopen(REGLOGio_read),buf[128];
if(
handle)
{
    while(
fread(handlebuf)) print(buf);
    
fwrite(handlestrval(buf) + 1);
    
fclose(handle);

Код:
dm_arena.pwn(319) : error 035: argument type mismatch (argument 2)
Error is in  fwrite(handle, strval(buf) + 1);
TY in advance...


Re: argument type mismatch????? - Sebz - 30.04.2017

I could be completely wrong as I'm unfamiliar with fwrite, but I read up on the wiki. It appears you're converting a string to an integer and passing it into fwrite which wants a string that it can convert to an integer. Perhaps pass the string, let it be converted to an integer, then add + 1 to that value.


Re: argument type mismatch????? - NaS - 30.04.2017

The simplest solution would be

Код:
valstr(buf, strval(buf) + 1);
fwrite(handle, buf);
instead of

Код:
fwrite(handle, strval(buf) + 1);
This will compile but it will crash the server (or not write the line).

You open the file with mode io_read, but still attempt to write to it. Use io_readwrite.


Re: argument type mismatch????? - Miladinovic - 01.05.2017

Thanks guys! I fixed it