#1

hi.i have 4 error in this code but i cant find them.help me please
errors:
Код:
C:\Users\asus\Desktop\Advance RolePlay Game\gamemodes\arpg0.1.pwn(126) : error 033: array must be indexed (variable "-unknown-")
C:\Users\asus\Desktop\Advance RolePlay Game\gamemodes\arpg0.1.pwn(128) : error 035: argument type mismatch (argument 4)
C:\Users\asus\Desktop\Advance RolePlay Game\gamemodes\arpg0.1.pwn(129) : error 035: argument type mismatch (argument 4)
C:\Users\asus\Desktop\Advance RolePlay Game\gamemodes\arpg0.1.pwn(130) : error 035: argument type mismatch (argument 4)
code:
Код:
//it is on top of script//
new create_houses_table[42][4][20]=
{
	    {"id",1,11,true},
	    {"canbuy",1,11,false},
	    {"bought",1,11,false},
	    {"price",1,11,false},
	    {"owner_id",1,11,false},
	    {"locked",1,11,false},
	    {"world",1,11,false},
	    {"interior",1,11,false},
	    {"weapon_0",1,11,false},
	    {"weapon_1",1,11,false},
	    {"weapon_2",1,11,false},
	    {"weapon_3",1,11,false},
	    {"weapon_4",1,11,false},
	    {"weapon_5",1,11,false},
	    {"weapon_6",1,11,false},
	    {"weapon_7",1,11,false},
	    {"weapon_8",1,11,false},
	    {"weapon_9",1,11,false},
	    {"weapon_10",1,11,false},
	    {"weapon_11",1,11,false},
	    {"ammo_0",1,11,false},
	    {"ammo_1",1,11,false},
	    {"ammo_2",1,11,false},
	    {"ammo_3",1,11,false},
	    {"ammo_4",1,11,false},
	    {"ammo_5",1,11,false},
	    {"ammo_6",1,11,false},
	    {"ammo_7",1,11,false},
	    {"ammo_8",1,11,false},
	    {"ammo_9",1,11,false},
	    {"ammo_10",1,11,false},
	    {"ammo_11",1,11,false},
	    {"seeds",1,11,false},
	    {"drugs",1,11,false},
	    {"money",1,11,false},
	    {"owner_name",2,20,false},
	    {"en_x",3,11,false},
	    {"en_y",3,11,false},
	    {"en_z",3,11,false},
	    {"ex_x",3,11,false},
	    {"ex_y",3,11,false},
	    {"ex_z",3,11,false}
};
//and this in Ongamemodeinit//
if(!SQL::ExistsTable("sv_houses"))
    {
        new handle=SQL::Open(SQL::CREATE,"sv_houses");
        for(new i=0;i<sizeof(create_houses_table);i++)
		{
		    126: switch(create_houses_table[i][1])
		    {
				128: case 1:SQL::AddTableEntry(handle,create_houses_table[i][0],SQL_TYPE_INT,create_houses_table[i][2],create_houses_table[i][3]);
				129: case 2:SQL::AddTableEntry(handle,create_houses_table[i][0],SQL_TYPE_VCHAR,create_houses_table[i][2],create_houses_table[i][3]);
				130: case 3:SQL::AddTableEntry(handle,create_houses_table[i][0],SQL_TYPE_FLOAT,create_houses_table[i][2],create_houses_table[i][3]);
		    }
		}
        SQL::Close(handle);
    }
Reply
#2

Use an enumerator for the array.
Reply
#3

how?please give me basic example with 3d array and enum
Reply
#4

pawn Код:
enum e_create_houses_table
{
    e_field[20],
    SQL::datatypes: e_type,
    e_maxlength,
    bool:e_auto_increment
};

new create_houses_table[][e_create_houses_table]=
{
    {"id",SQL_TYPE_INT,11,true},
    {"canbuy",SQL_TYPE_INT,11,false},
    {"bought",SQL_TYPE_INT,11,false},
    {"price",SQL_TYPE_INT,11,false},
    {"owner_id",SQL_TYPE_INT,11,false},
    {"locked",SQL_TYPE_INT,11,false},
    {"world",SQL_TYPE_INT,11,false},
    {"interior",SQL_TYPE_INT,11,false},
    {"weapon_0",SQL_TYPE_INT,11,false},
    {"weapon_1",SQL_TYPE_INT,11,false},
    {"weapon_2",SQL_TYPE_INT,11,false},
    {"weapon_3",SQL_TYPE_INT,11,false},
    {"weapon_4",SQL_TYPE_INT,11,false},
    {"weapon_5",SQL_TYPE_INT,11,false},
    {"weapon_6",SQL_TYPE_INT,11,false},
    {"weapon_7",SQL_TYPE_INT,11,false},
    {"weapon_8",SQL_TYPE_INT,11,false},
    {"weapon_9",SQL_TYPE_INT,11,false},
    {"weapon_10",SQL_TYPE_INT,11,false},
    {"weapon_11",SQL_TYPE_INT,11,false},
    {"ammo_0",SQL_TYPE_INT,11,false},
    {"ammo_1",SQL_TYPE_INT,11,false},
    {"ammo_2",SQL_TYPE_INT,11,false},
    {"ammo_3",SQL_TYPE_INT,11,false},
    {"ammo_4",SQL_TYPE_INT,11,false},
    {"ammo_5",SQL_TYPE_INT,11,false},
    {"ammo_6",SQL_TYPE_INT,11,false},
    {"ammo_7",SQL_TYPE_INT,11,false},
    {"ammo_8",SQL_TYPE_INT,11,false},
    {"ammo_9",SQL_TYPE_INT,11,false},
    {"ammo_10",SQL_TYPE_INT,11,false},
    {"ammo_11",SQL_TYPE_INT,11,false},
    {"seeds",SQL_TYPE_INT,11,false},
    {"drugs",SQL_TYPE_INT,11,false},
    {"money",SQL_TYPE_INT,11,false},
    {"owner_name",SQL_TYPE_VCHAR,20,false},
    {"en_x",SQL_TYPE_FLOAT,11,false},
    {"en_y",SQL_TYPE_FLOAT,11,false},
    {"en_z",SQL_TYPE_FLOAT,11,false},
    {"ex_x",SQL_TYPE_FLOAT,11,false},
    {"ex_y",SQL_TYPE_FLOAT,11,false},
    {"ex_z",SQL_TYPE_FLOAT,11,false}
};
pawn Код:
...

for(new i=0;i<sizeof(create_houses_table);i++)
{
    SQL::AddTableEntry(handle, create_houses_table[i][e_field], create_houses_table[i][e_type], create_houses_table[i][e_maxlength], create_houses_table[i][e_auto_increment]);
}

...
On another note, "id" should be set as primary key and that's one of the reasons you should learn SQL and don't rely to such includes: the best way to save weapons: https://sampforum.blast.hk/showthread.php?tid=505081
Reply
#5

thanks a lot
Reply
#6

what can i do about this?
warning:
Код:
(138) : warning 213: tag mismatch
Код:
function LoadHouses(){
    new handle=SQL::Open(SQL::MTREAD,"sv_houses");
	SQL_GetCallback(handle,i){
	    Iter_Add(House,i);
	    for(new d=0;d<sizeof(create_houses_table);d++){
    		if(create_houses_table[d][e_type]==SQL_TYPE_INT)SQL::ReadInt(handle,create_houses_table[d][e_field],HD[i][h_data:d],i);
    		else if(create_houses_table[d][e_type]==SQL_TYPE_VCHAR)SQL::ReadString(handle,create_houses_table[d][e_field],HD[i][h_data:d],create_houses_table[d][e_maxlength],i);
    		138= else if(create_houses_table[d][e_type]==SQL_TYPE_FLOAT)SQL::ReadFloat(handle,create_houses_table[d][e_field],HD[i][h_data:d],i);}}
	SQL::Close(handle);
	return 1;}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)