My server wont start
#1

Hello why wont my server start, it stops when its trying to load the owned vehicles
it all started after i added this line
pawn Код:
strmid(CarInfo[idx][cPTReason], arrCoords[47], 0, strlen(arrCoords[47]), 255);

This is the loading functin
pawn Код:
forward LoadCars();
public LoadCars()
{
    new arrCoords[50][64];
    new strFromFile2[456];
    new File: file = fopen("cars.cfg", io_read);
    if (file)
    {
        new idx;
        while (idx < sizeof(CarInfo))
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, ',');
            CarInfo[idx][cModel] = strval(arrCoords[0]);
            CarInfo[idx][cLocationx] = floatstr(arrCoords[1]);
            CarInfo[idx][cLocationy] = floatstr(arrCoords[2]);
            CarInfo[idx][cLocationz] = floatstr(arrCoords[3]);
            CarInfo[idx][cAngle] = floatstr(arrCoords[4]);
            CarInfo[idx][cColorOne] = strval(arrCoords[5]);
            CarInfo[idx][cColorTwo] = strval(arrCoords[6]);
            strmid(CarInfo[idx][cOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
            strmid(CarInfo[idx][cDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
            CarInfo[idx][cValue] = strval(arrCoords[9]);
            strmid(CarInfo[idx][cPlate], arrCoords[10], 0, strlen(arrCoords[10]), 255);
            CarInfo[idx][cOwnedCar] = strval(arrCoords[11]);
            CarInfo[idx][cLock] = strval(arrCoords[12]);
            CarInfo[idx][cMod][0] = strval(arrCoords[13]);
            CarInfo[idx][cMod][1] = strval(arrCoords[14]);
            CarInfo[idx][cMod][2] = strval(arrCoords[15]);
            CarInfo[idx][cMod][3] = strval(arrCoords[16]);
            CarInfo[idx][cMod][4] = strval(arrCoords[17]);
            CarInfo[idx][cMod][5] = strval(arrCoords[18]);
            CarInfo[idx][cMod][6] = strval(arrCoords[19]);
            CarInfo[idx][cMod][7] = strval(arrCoords[20]);
            CarInfo[idx][cMod][8] = strval(arrCoords[21]);
            CarInfo[idx][cMod][9] = strval(arrCoords[22]);
            CarInfo[idx][cDonate] = strval(arrCoords[23]);
            CarInfo[idx][cInsure] = strval(arrCoords[24]);
            CarInfo[idx][cTrunkWep][1] = strval(arrCoords[25]);
            CarInfo[idx][cTrunkAmmo][1] = strval(arrCoords[26]);
            CarInfo[idx][cTrunkWep][2] = strval(arrCoords[27]);
            CarInfo[idx][cTrunkAmmo][2] = strval(arrCoords[28]);
            CarInfo[idx][cTrunkWep][3] = strval(arrCoords[29]);
            CarInfo[idx][cTrunkAmmo][3] = strval(arrCoords[30]);
            CarInfo[idx][cTrunkWep][4] = strval(arrCoords[31]);
            CarInfo[idx][cTrunkAmmo][4] = strval(arrCoords[32]);
            CarInfo[idx][cTrunkArmour] = floatstr(arrCoords[33]);
            CarInfo[idx][cTrunkCounter] = strval(arrCoords[34]);
            CarInfo[idx][cAlarm] = strval(arrCoords[35]);
            CarInfo[idx][cTrunkPot] = strval(arrCoords[36]);
            CarInfo[idx][cTrunkCrack] = strval(arrCoords[37]);
            CarInfo[idx][cTrunkMatsa] = strval(arrCoords[38]);
            CarInfo[idx][cTrunkMatsb] = strval(arrCoords[39]);
            CarInfo[idx][cTrunkMatsc] = strval(arrCoords[40]);
            CarInfo[idx][cImpounded] = strval(arrCoords[41]);
            CarInfo[idx][cImpoundedPrice] = strval(arrCoords[42]);
            CarInfo[idx][cDestroys] = strval(arrCoords[43]);
            CarInfo[idx][cInsurePrice] = strval(arrCoords[44]);
            CarInfo[idx][cPTicket] = strval(arrCoords[45]);
            CarInfo[idx][cPTPrice] = strval(arrCoords[46]);
            strmid(CarInfo[idx][cPTReason], arrCoords[47], 0, strlen(arrCoords[47]), 255);
            idx++;
        }
    }
    fclose(file);
    return 1;
}
Saving
pawn Код:
public SaveCars()
{
    new idx, coordsstring[456];
    new File: file2 = fopen("cars.cfg", io_write);
    if (!file2) return; // couldn't open file, stop right here
    while (idx < sizeof(CarInfo))
    {
        //new coordsstring[256];       //            0  1  2  4  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
        format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%i,%i,%i,%i,%i,%i,%i,%i,%f,%i,%d,%i,%i,%i,%i,%i,%i,%i,%d,%d,%d,%d,%s\n",
        CarInfo[idx][cModel], // 0
        CarInfo[idx][cLocationx], // 1
        CarInfo[idx][cLocationy], // 2
        CarInfo[idx][cLocationz],  // 3
        CarInfo[idx][cAngle],  //4
        CarInfo[idx][cColorOne], //5
        CarInfo[idx][cColorTwo], //6
        CarInfo[idx][cOwner], //7
        CarInfo[idx][cDescription], //8
        CarInfo[idx][cValue], //9
        CarInfo[idx][cPlate], //10
        CarInfo[idx][cOwnedCar], //11
        CarInfo[idx][cLock], //12
        CarInfo[idx][cMod][0], //13
        CarInfo[idx][cMod][1], //14
        CarInfo[idx][cMod][2], //15
        CarInfo[idx][cMod][3], //16
        CarInfo[idx][cMod][4], //17
        CarInfo[idx][cMod][5], //18
        CarInfo[idx][cMod][6], //19
        CarInfo[idx][cMod][7], //20
        CarInfo[idx][cMod][8], //21
        CarInfo[idx][cMod][9], //22
        CarInfo[idx][cDonate], //23
        CarInfo[idx][cInsure], //24
        CarInfo[idx][cTrunkWep][1], //25
        CarInfo[idx][cTrunkAmmo][1], //26
        CarInfo[idx][cTrunkWep][2], //27
        CarInfo[idx][cTrunkAmmo][2], //28
        CarInfo[idx][cTrunkWep][3], //29
        CarInfo[idx][cTrunkAmmo][3], //30
        CarInfo[idx][cTrunkWep][4], //31
        CarInfo[idx][cTrunkAmmo][4], //32
        CarInfo[idx][cTrunkArmour], //33
        CarInfo[idx][cTrunkCounter], //34
        CarInfo[idx][cAlarm], //35
        CarInfo[idx][cTrunkPot], //36
        CarInfo[idx][cTrunkCrack], //37
        CarInfo[idx][cTrunkMatsa], //38
        CarInfo[idx][cTrunkMatsb], //39
        CarInfo[idx][cTrunkMatsc], //40
        CarInfo[idx][cImpounded], //41
        CarInfo[idx][cImpoundedPrice], //42
        CarInfo[idx][cDestroys], //43
        CarInfo[idx][cInsurePrice], //44
        CarInfo[idx][cPTicket], //45
        CarInfo[idx][cPTPrice], //46
        CarInfo[idx][cPTReason]); //47
        fwrite(file2, coordsstring);
        idx++;
    }
    fclose(file2);
}
And Enum
pawn Код:
enum cInfo
{
    cModel,
    Float:cLocationx,
    Float:cLocationy,
    Float:cLocationz,
    Float:cAngle,
    cColorOne,
    cColorTwo,
    cOwner[MAX_PLAYER_NAME],
    cDescription[MAX_PLAYER_NAME],
    cValue,
    cPlate[15],
    cRegistration,
    cOwnedCar,
    cLock,
    cMod[10],
    cDonate,
    cInsure,
    cTrunkWep[MAX_TRUNK_SLOTS],
    cTrunkAmmo[MAX_TRUNK_SLOTS],
    Float:cTrunkArmour,
    cTrunkCounter,
    cAlarm,
    cTrunkPot,
    cTrunkCrack,
    cTrunkMatsa,
    cTrunkMatsb,
    cTrunkMatsc,
    cImpounded,
    cImpoundedPrice,
    cDestroys,
    cInsurePrice,
    cPTicket,
    cPTPrice,
    cPTReason,
};

new CarInfo[SCRIPT_OWNCARS][cInfo];
Reply
#2

If you are using the strmid function on cPTReason, why is it not declared as a string in the enum?

EDIT:
Also: you can ommit the comma behind the last value in the enum.
Reply
#3

For one its
Код:
enum cInfo
{
	cModel,
	Float:cLocationx,
	Float:cLocationy,
	Float:cLocationz,
	Float:cAngle,
	cColorOne,
	cColorTwo,
	cOwner[MAX_PLAYER_NAME],
	cDescription[MAX_PLAYER_NAME],
	cValue,
	cPlate[15],
	cRegistration,
	cOwnedCar,
	cLock,
	cMod[10],
	cDonate,
	cInsure,
	cTrunkWep[MAX_TRUNK_SLOTS],
	cTrunkAmmo[MAX_TRUNK_SLOTS],
	Float:cTrunkArmour,
	cTrunkCounter,
	cAlarm,
	cTrunkPot,
	cTrunkCrack,
	cTrunkMatsa,
	cTrunkMatsb,
	cTrunkMatsc,
	cImpounded,
	cImpoundedPrice,
	cDestroys,
	cInsurePrice,
	cPTicket,
	cPTPrice,
	cPTReason
};

new CarInfo[SCRIPT_OWNCARS][cInfo];
As i removed the last ","
Reply
#4

Quote:
Originally Posted by WhiteGhost
Посмотреть сообщение
For one its
...
As i removed the last ","
Haha, you must have posted, while I was editing my reply .
Reply
#5

Thank you guys, cPTReason if for parking tickets, the "reason"
but if i place a ticet on a car example reason "TEST" and i restart the server
and when i spawn the car it will just say reason "TE" but when i check the cars.cfg its still "TEST" why that?
Reply
#6

Try
pawn Код:
cPTReason[128]
in your enum
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)