Need help with dini making file
#1

Ok, so i have this code OnplayerConnect so when the player connect it creates the files but for some reason it's not creating a file can someone help me out?

pawn Код:
new str[128];
format(str, sizeof(str), "Cars/CarKeys/%s.%s.cfg", str);
if(dini_Exists(str))
    {
      strmid(CarKeys[playerid][cCarkey], dini_Get(str, "Vehicle1"), 0, strlen(dini_Get(str, "Vehicle1")), 255);
      strmid(CarKeys[playerid][cCarkey2], dini_Get(str, "Vehicle2"), 0, strlen(dini_Get(str, "Vehicle2")), 255);
      strmid(CarKeys[playerid][cCarkey3], dini_Get(str, "Vehicle3"), 0, strlen(dini_Get(str, "Vehicle3")), 255);
   
    }
    else
    {
      dini_Create(str);
      strmid(CarKeys[playerid][cCarkey], "None", 0, strlen("None"), 255);
      strmid(CarKeys[playerid][cCarkey2], "None", 0, strlen("None"), 255);
      strmid(CarKeys[playerid][cCarkey3], "None", 0, strlen("None"), 255);
     
    }
    return 1;
}
Reply
#2

Try removing that first period in your file name. That may be why.
Reply
#3

Quote:
Originally Posted by Backwardsman97
Try removing that first period in your file name. That may be why.
I have tried that. Here is the new code

pawn Код:
format(str, sizeof(str), "Cars/CarKeys/%s.cfg", str);
if(dini_Exists(str))
    {
      strmid(CarKeys[playerid][cCarkey], dini_Get(str, "Vehicle1"), 0, strlen(dini_Get(str, "Vehicle1")), 255);
      strmid(CarKeys[playerid][cCarkey2], dini_Get(str, "Vehicle2"), 0, strlen(dini_Get(str, "Vehicle2")), 255);
      strmid(CarKeys[playerid][cCarkey3], dini_Get(str, "Vehicle3"), 0, strlen(dini_Get(str, "Vehicle3")), 255);

    }
    else
    {
      dini_Create(str);
      strmid(CarKeys[playerid][cCarkey], "None", 0, strlen("None"), 255);
      strmid(CarKeys[playerid][cCarkey2], "None", 0, strlen("None"), 255);
      strmid(CarKeys[playerid][cCarkey3], "None", 0, strlen("None"), 255);

    }
    return 1;
}

Note this is my first time using dini, I thought i would get to know it
Reply
#4

Try maybe using '\' instead of '/' and see. That's the only thing I can think of.
Reply
#5

Quote:
Originally Posted by Backwardsman97
Try maybe using '\' instead of '/' and see. That's the only thing I can think of.
I tried it and i got this error

error 027: invalid character constant

If i say put the file in the folder (manually)

like i put

myname.cfg it writes the data to the file but it will not create the file. I can't make files manaully for each player it would be to time cousming and confusing
Reply
#6

'\' means either that there comes a invalid char. try with '\\' maybe
Reply
#7

Quote:
Originally Posted by Niixie
'\' means either that there comes a invalid char. try with '\\' maybe
It compiled but it still dosen't create the file that it's suppose to
Reply
#8

I wonder why you make the string like this

format(str, sizeof(str), "Cars/CarKeys/%s.%s.cfg", str);

This would create a file name Cars/CarKeys/Cars/CarKeys.Cars/Carkeys.cfg


Plus try make it a .ini file
Reply
#9

it must be \\ double \ yes? so it would be like this:

Cars\\CarKeys\\Cars\\CarKeys.Cars\\Carkeys.cfg
Reply
#10

You are using 'format' wrong.
format(str, sizeof(str), "Cars/CarKeys/%s.%s.cfg", str);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)