i have missed something.
#1

pawn Код:
new File:Cweed;
         new string[4];
         new string2[4];
        Cweed = fopen("Drugs/cweed.txt", io_read);
        fread(Cweed,string);
        fclose(Cweed);
        Cweed = fopen("Drugs/cweed.txt", io_write);
        format(string2, sizeof(string2),"%d",(strval(string)+500)); // here something must be wrong !
        fwrite(Cweed,string2);
        fclose(Cweed);
        return 1;
I have re-checked the code few times, but still i cant find the mistake !

The idea of what i did was:
Read some number from the file, and then add 500 to that number.

The problem is that, it simply crashes the server.
I bet there is something wrong with 'strval' at the the 'format(); //' line.

All help will be appreciated.

Luxeon
Reply
#2

up
Reply
#3

that's a bollshit ...

read what do strval !
Reply
#4

Quote:
Originally Posted by MoroJr™
that's a bollshit ...

read what do strval !
text to number converter ?
Reply
#5

fread(Cweed,string);

if you're string have array 4 , how to read it ?
Reply
#6

Quote:
Originally Posted by MoroJr™
fread(Cweed,string);

if you're string have array 4 , how to read it ?
what the?
If string is up to 4 numbers/letters, then it simply doesn't need more..(that is not the problem 100%)..do you know what array size is for ?

There must be something other wrong !

Luxeon
Reply
#7

Hey,is ur server poor of memory?
You're clever,I know,cuz u consider '\0'.
The problem is,where's the array size for '\r','\n'?
maybe strval(emptystring) = crash,
Why to crash?Im not sure
Try for a bigger array size,trusting me ^^
Reply
#8

changed array size of both strings to 128, and still the same, so stop saying it is arrays size, because as i thought it is not!
Before saying something i always do a research, so in this case i made a test, where i put both arrays sizes to 128..and it still crashed.

The only possible reason for crashing might be, that i am using this at the FS, thou i bet it shouldn't be a problem.
+ i have noticed, that it always gives +'500' in the file, so if at the beginning it was 'empty', the now it is '2500' (5 tests).

Any ideas?

Luxeon
Reply
#9

Wouldn't it be better if like...
pawn Код:
new File:Cweed;
        new var;
        new string[30];
        Cweed = fopen("Drugs/cweed.txt", io_read);
        fread(Cweed,string);
        fclose(Cweed);
        var = strval(string);
        printf("readed string: [%s] | Extracted value: [%d]", string, var); //debug
        Cweed = fopen("Drugs/cweed.txt", io_write);
        format(string, sizeof(string),"%d",var+500);
        fwrite(Cweed,string);
        fclose(Cweed);
        return 1;
Should work. But i don't know really
Also if it's not working, post the debug line here.


Leopard
Reply
#10

Emmmmm...That means...fwrite( Cweed,string2) is called succefully.
Other function causes crash?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)