Help with fread.
#1

Ok there is one problem i have .
I create speed cam, and when i load them function LoadSpeedCams, return 0 or what ever i don't know, but that only happens when i have more than 1 line in file.
Here is code to add speed cams:

pawn Код:
public AddSpeedCam(playerid, speed){
    new Float:X, Float:Y, Float:Z, scString[128];
    new File:SpeedCamsFile = fopen("speedcams.txt", io_append);
    GetPlayerPos(playerid, X, Y, Z);
    format(scString, sizeof(scString), "%f,%f,%f,%d\n", X, Y, Z, speed);
    fwrite(SpeedCamsFile, scString);
    fclose(SpeedCamsFile);
    return 1;
}
And here is code to load them:

pawn Код:
public LoadSpeedCams(){
    print("Loading SpeedCams...");
    new String_SC[256], Split_String[5][20], SC;
    if(!dini_Exists("speedcams.txt")){
        print("4029");
        return 1;
    }
    SC = 0;
    new File:LoadSC = fopen("speedcams.txt", io_read);
    while(fread(LoadSC, String_SC)){
        printf("%s", String_SC);
        split(String_SC, Split_String, ',');
        SpeedCams[SC][scX] = floatstr(Split_String[0]);
        SpeedCams[SC][scY] = floatstr(Split_String[1]);
        SpeedCams[SC][scZ] = floatstr(Split_String[2]);
        SpeedCams[SC][scMax_Speed] = strval(Split_String[3]);
        SC++;
    }
    fclose(LoadSC);
    return 1;
}
so please if anyone know what is the problem help me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)