SA-MP Forums Archive
Reading Number from File - 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: Reading Number from File (/showthread.php?tid=337427)



Reading Number from File - Deduction - 26.04.2012

So Basicly i'm trying to read a number from a file, and its bringing up 1 error in pawn.
I will label the error.

pawn Код:
LoadNumber()
{
        new File: file = fopen("number.cfg", io_read);
        new string, string2[128];
        fread(file, string); //ERROR / error 035: argument type mismatch (argument 2)
        Number = string;
        format(string2, sizeof(string2), "Number: %d", string);
        print(string2);
        fclose(file);
        return 1;
}
Thats the code without revealing anything of my script.
How would I go about this?


Re: Reading Number from File - Niko_boy - 26.04.2012

firstly i twill be like Number = strval(string);
secondly u used that var to carry string value but u never actualy used it ?
and about error
fix:==
new string[128];
then at to take it as integer do new var;
var = strval(string);
^ var here will be "Number"
na leave it >>> see this the fix
pawn Код:
LoadNumber()
{
        new File: file = fopen("number.cfg", io_read);
        new string[128], string2[128], Number;
        fread(file, string); //ERROR / error 035: argument type mismatch (argument 2)
        Number = strval(string);
        format(string2, sizeof(string2), "Number: %d", Number);
        print(string2);
        fclose(file);
        return 1;
}



Re: Reading Number from File - Deduction - 26.04.2012

Wow, trying to think to simple, not thinking of those functions.
Thanks +Rep