More garage help
#1

Here is what i am getting the errors in i think
Код:
// Garage Settings
enum garageInfo
{
	gLevel,
	gPrice,
	gStatus,
	gOwner[32],
	Float:gX,
	Float:gY,
	Float:gZ,
	gPickup,
	Text3D:gText
}
new GarageInfo[MAX_GARAGES][garageInfo];

stock LoadGarages()
{
	new binfo[21][32];
	new string[256];
	new File:file = fopen("garages.cfg", io_read);
	if(file)
	{
	    new idx = 1;
		while(idx < MAX_GARAGES)
		{
		    fread(file, string);
		    split(string, binfo, '|');
		    GarageInfo[idx][gLevel] = strval(binfo[0]);
		    GarageInfo[idx][gPrice] = strval(binfo[1]);
		    GarageInfo[idx][gStatus] = strval(binfo[2]);
		    format(GarageInfo[idx][gOwner], 32, "%s", binfo[3]);
		    GarageInfo[idx][gX] = floatstr(binfo[4]);
		    GarageInfo[idx][gY] = floatstr(binfo[5]);
		    GarageInfo[idx][gZ] = floatstr(binfo[6]);
			if(GarageInfo[idx][gLevel])
			{
			    GarageInfo[idx][gPickup] = CreateDynamicPickup(1272, 1, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ], 0);
                if(!strcmp("The State", GarageInfo[idx][gOwner])) format(string, sizeof(string), "ID: %d\nGarage (Lvl: %d)\nOwner: %s\nStatus: For Sale\nPrice: $%d", idx, GarageInfo[idx][gLevel], GarageInfo[idx][gOwner], GarageInfo[idx][gPrice]);
				else format(string, sizeof(string), "ID: %d\nGarage (Lvl: %d)\nOwner: %s\nStatus: %s", idx, GarageInfo[idx][gLevel], GarageInfo[idx][gOwner], RHS(idx));
				GarageInfo[idx][hText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ]+0.3, 15);

			}
			idx++;
	    }
	}
	print("Garages loaded successfully.");
	return 1;
}

stock SaveGarages()
{
	new idx = 1, File:file;
	new string[256];
	while(idx < MAX_GARAGES)
	{
	    format(string, sizeof(string), "%d|%d|%d|%s|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d\r\n",
	    GarageInfo[idx][gLevel],
	    GarageInfo[idx][gPrice],
	    GarageInfo[idx][gStatus],
	    GarageInfo[idx][gOwner],
	    GarageInfo[idx][gX],
	    GarageInfo[idx][gY],
	    GarageInfo[idx][gZ],
		);
	    if(idx == 1)
	    {
	        file = fopen("garages.cfg", io_write);
	    }
	    else
	    {
	    	file = fopen("garages.cfg", io_append);
	    }
		fwrite(file, string);
		fclose(file);
		idx++;
	}
	print("Garages saved successfully.");
}
Here are the codes
Код:
C:\Users\Ryan Wharton\Desktop\zGaming Roleplay\gamemodes\ZRP.pwn(1950) : warning 213: tag mismatch
C:\Users\Ryan Wharton\Desktop\zGaming Roleplay\gamemodes\ZRP.pwn(1950) : error 032: array index out of bounds (variable "GarageInfo")
C:\Users\Ryan Wharton\Desktop\zGaming Roleplay\gamemodes\ZRP.pwn(1966 -- 1974) : error 029: invalid expression, assumed zero
C:\Users\Ryan Wharton\Desktop\zGaming Roleplay\gamemodes\ZRP.pwn(1966 -- 1974) : error 001: expected token: ",", but found ";"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Reply
#2

The error is not there because this
pawn Код:
#include <a_samp>
main(){}

#define MAX_GARAGES 10
//max garages test number
enum garageInfo
{
    gLevel,
    gPrice,
    gStatus,
    gOwner[32],
    Float:gX,
    Float:gY,
    Float:gZ,
    gPickup,
    Text3D:gText
}
new GarageInfo[MAX_GARAGES][garageInfo];

stock LoadGarages()
{
    new binfo[21][32];
    new string[256];
    new File:file = fopen("garages.cfg", io_read);
    if(file)
    {
        new idx = 1;
        while(idx < MAX_GARAGES)
        {
            fread(file, string);
            split(string, binfo, '|');
            GarageInfo[idx][gLevel] = strval(binfo[0]);
            GarageInfo[idx][gPrice] = strval(binfo[1]);
            GarageInfo[idx][gStatus] = strval(binfo[2]);
            format(GarageInfo[idx][gOwner], 32, "%s", binfo[3]);
            GarageInfo[idx][gX] = floatstr(binfo[4]);
            GarageInfo[idx][gY] = floatstr(binfo[5]);
            GarageInfo[idx][gZ] = floatstr(binfo[6]);
            if(GarageInfo[idx][gLevel])
            {
                GarageInfo[idx][gPickup] = CreateDynamicPickup(1272, 1, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ], 0);
                if(!strcmp("The State", GarageInfo[idx][gOwner])) format(string, sizeof(string), "ID: %d\nGarage (Lvl: %d)\nOwner: %s\nStatus: For Sale\nPrice: $%d", idx, GarageInfo[idx][gLevel], GarageInfo[idx][gOwner], GarageInfo[idx][gPrice]);
                else format(string, sizeof(string), "ID: %d\nGarage (Lvl: %d)\nOwner: %s\nStatus: %s", idx, GarageInfo[idx][gLevel], GarageInfo[idx][gOwner], RHS(idx));
                GarageInfo[idx][hText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ]+0.3, 15);

            }
            idx++;
        }
    }
    print("Garages loaded successfully.");
    return 1;
}

stock SaveGarages()
{
    new idx = 1, File:file;
    new string[256];
    while(idx < MAX_GARAGES)
    {
        format(string, sizeof(string), "%d|%d|%d|%s|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d\r\n",
        GarageInfo[idx][gLevel],
        GarageInfo[idx][gPrice],
        GarageInfo[idx][gStatus],
        GarageInfo[idx][gOwner],
        GarageInfo[idx][gX],
        GarageInfo[idx][gY],
        GarageInfo[idx][gZ],
        );
        if(idx == 1)
        {
            file = fopen("garages.cfg", io_write);
        }
        else
        {
            file = fopen("garages.cfg", io_append);
        }
        fwrite(file, string);
        fclose(file);
        idx++;
    }
    print("Garages saved successfully.");
}
Compiles fine for me
Reply
#3

Hmmm. Then i have no idea what it is.
Reply
#4

Is there a way i can see what line the error is coming from?
Reply
#5

Your error codes:

C:\Users\Ryan Wharton\Desktop\zGaming Roleplay\gamemodes\ZRP.pwn(1950) : warning 213: tag mismatch
C:\Users\Ryan Wharton\Desktop\zGaming Roleplay\gamemodes\ZRP.pwn(1950) : error 032: array index out of bounds (variable "GarageInfo")
C:\Users\Ryan Wharton\Desktop\zGaming Roleplay\gamemodes\ZRP.pwn(1966 -- 1974) : error 029: invalid expression, assumed zero
C:\Users\Ryan Wharton\Desktop\zGaming Roleplay\gamemodes\ZRP.pwn(1966 -- 1974) : error 001: expected token: ",", but found ";"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


3 Errors.

The numbers between the () are the lines
CTRL + G to go to a line
Reply
#6

Okay, After i go to the lines the error is i can still not find a error wrong with it.

C:\Users\Ryan Wharton\Desktop\zGaming Roleplay\gamemodes\ZRP.pwn(1966 -- 1974) : error 029: invalid expression, assumed zero
C:\Users\Ryan Wharton\Desktop\zGaming Roleplay\gamemodes\ZRP.pwn(1966 -- 1974) : error 001: expected token: ",", but found ";"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#7

tell me which line(s) it start.
Copy the 1966 line
Reply
#8

tell me which line(s) it start.
Copy the 1966 line

Edit:
pawn Код:
{
        format(string, sizeof(string), "%d|%d|%d|%s|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d\r\n",
        GarageInfo[idx][gLevel],
        GarageInfo[idx][gPrice],
        GarageInfo[idx][gStatus],
        GarageInfo[idx][gOwner],
        GarageInfo[idx][gX],
        GarageInfo[idx][gY],
        GarageInfo[idx][gZ],
        );
Try this:
pawn Код:
{
        format(string, sizeof(string)), "%d|%d|%d|%s|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d\r\n",
        GarageInfo[idx][gLevel],
        GarageInfo[idx][gPrice],
        GarageInfo[idx][gStatus],
        GarageInfo[idx][gOwner],
        GarageInfo[idx][gX],
        GarageInfo[idx][gY],
        GarageInfo[idx][gZ],
Changed: format(string, sizeof(string)) | the double )) at the end |
and removed the: ); | Why is it there? |
Reply
#9

Nope, That just made more errors
Reply
#10

pawn Код:
//                               1  2  3  4  5 6  7  8  9  10 11 12 13 14 15 16 17 18 19 20 21
format(string, sizeof(string), "%d|%d|%d|%s|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d\r\n",
        GarageInfo[idx][gLevel],//1
        GarageInfo[idx][gPrice],//2
        GarageInfo[idx][gStatus],//3
        GarageInfo[idx][gOwner],//4
        GarageInfo[idx][gX],//5
        GarageInfo[idx][gY],//6
        GarageInfo[idx][gZ],//7
        //Where's the other scripts?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)