error 035: argument type mismatch (argument 2) -
Cerealguy - 14.12.2016
PHP код:
id = db_get_field_int(queryresult, "RID");
Rooftop[id][EnterPos][0] = db_get_field_float(queryresult, "EnterX");
Rooftop[id][EnterPos][1] = db_get_field_float(queryresult, "EnterY");
Rooftop[id][EnterPos][2] = db_get_field_float(queryresult, "EnterZ");
Rooftop[id][TelePos][0] = db_get_field_float(queryresult, "ExitX");
Rooftop[id][TelePos][1] = db_get_field_float(queryresult, "ExitY");
Rooftop[id][TelePos][2] = db_get_field_float(queryresult, "ExitZ");
error 035: argument type mismatch (argument 2)
Re: error 035: argument type mismatch (argument 2) -
Konstantinos - 14.12.2016
https://sampwiki.blast.hk/wiki/Db_get_field_assoc_int
https://sampwiki.blast.hk/wiki/Db_get_field_assoc_float
Respuesta: error 035: argument type mismatch (argument 2) -
Cerealguy - 14.12.2016
PHP код:
new DBResult:queryresult;
PHP код:
forward LoadRooftop();
public LoadRooftop()
{
queryresult = db_query(Database, "SELECT * FROM `ROOFTOP`");
if(db_num_rows(queryresult) > 0)
{
new id;
for (new x=0; x<db_num_rows(queryresult); x++)
{
id = db_get_field_int(queryresult, "RID");
Rooftop[id][EnterPos][0] = db_get_field_float(queryresult, "EnterX");
Rooftop[id][EnterPos][1] = db_get_field_float(queryresult, "EnterY");
Rooftop[id][EnterPos][2] = db_get_field_float(queryresult, "EnterZ");
Rooftop[id][TelePos][0] = db_get_field_float(queryresult, "ExitX");
Rooftop[id][TelePos][1] = db_get_field_float(queryresult, "ExitY");
Rooftop[id][TelePos][2] = db_get_field_float(queryresult, "ExitZ");
Rooftop[id][checkpointidx][0] = CreateDynamicCP(Rooftop[id][EnterPos][0], Rooftop[id][EnterPos][1], Rooftop[id][EnterPos][2], 1.5, 0, -1, -1, 50.0);
Rooftop[id][checkpointidx][1] = CreateDynamicCP(Rooftop[id][TelePos][0], Rooftop[id][TelePos][1], Rooftop[id][TelePos][2], 1.5, 0, -1, -1, 50.0);
Rooftop[id][textid][0] = CreateDynamic3DTextLabel("[ROOFTOP]", COLOR_VIP, Rooftop[id][EnterPos][0], Rooftop[id][EnterPos][1], Rooftop[id][EnterPos][2], 15.0);
Rooftop[id][textid][1] = CreateDynamic3DTextLabel("[Exit]", COLOR_VIP, Rooftop[id][TelePos][0], Rooftop[id][TelePos][1], Rooftop[id][TelePos][2], 15.0);
db_next_row(queryresult);
}
}
roofid = db_num_rows(queryresult);
new string[60];
format(string,sizeof(string),"%d rooftop loaded.",db_num_rows(queryresult));
printf(string);
db_free_result(queryresult);
return 1;
}
I do not understand what I do wrong
Re: error 035: argument type mismatch (argument 2) -
Konstantinos - 14.12.2016
You use wrong functions. Those expect an integer (field id) as second parameter and not a string (field name).
By the way, store the number of rows to a variable instead of calling
db_num_rows so many times.
Respuesta: error 035: argument type mismatch (argument 2) -
Cerealguy - 14.12.2016
PHP код:
forward LoadRooftop();
public LoadRooftop()
{
queryresult = db_query(Database, "SELECT * FROM `ROOFTOP`");
new count = db_num_rows(queryresult);
if(count > 0)
{
new id, ftd[30];
for (new x=0; x<count; x++)
{
db_get_field_assoc(queryresult, "RID", ftd, 26);
id = strval(ftd);
db_get_field_assoc(queryresult, "EnterX", ftd, 30);
Rooftop[id][EnterPos][0] = floatstr(ftd);
db_get_field_assoc(queryresult, "EnterY", ftd, 30);
Rooftop[id][EnterPos][1] = floatstr(ftd);
db_get_field_assoc(queryresult, "EnterZ", ftd, 30);
Rooftop[id][EnterPos][2] = floatstr(ftd);
db_get_field_assoc(queryresult, "ExitX", ftd, 30);
Rooftop[id][TelePos][0] = floatstr(ftd);
db_get_field_assoc(queryresult, "ExitY", ftd, 30);
Rooftop[id][TelePos][1] = floatstr(ftd);
db_get_field_assoc(queryresult, "ExitZ", ftd, 30);
Rooftop[id][TelePos][2] = floatstr(ftd);
Rooftop[id][checkpointidx][0] = CreateDynamicCP(Rooftop[id][EnterPos][0], Rooftop[id][EnterPos][1], Rooftop[id][EnterPos][2], 1.5, 0, -1, -1, 50.0);
Rooftop[id][checkpointidx][1] = CreateDynamicCP(Rooftop[id][TelePos][0], Rooftop[id][TelePos][1], Rooftop[id][TelePos][2], 1.5, 0, -1, -1, 50.0);
Rooftop[id][textid][0] = CreateDynamic3DTextLabel("[ROOFTOP]", COLOR_VIP, Rooftop[id][EnterPos][0], Rooftop[id][EnterPos][1], Rooftop[id][EnterPos][2], 15.0);
Rooftop[id][textid][1] = CreateDynamic3DTextLabel("[Exit]", COLOR_VIP, Rooftop[id][TelePos][0], Rooftop[id][TelePos][1], Rooftop[id][TelePos][2], 15.0);
db_next_row(queryresult);
}
}
roofid = count;
new string[60];
format(string,sizeof(string),"%d rooftop loaded.", count);
printf(string);
db_free_result(queryresult);
return 1;
}
fix, It's okay like he did?
Re: error 035: argument type mismatch (argument 2) -
Konstantinos - 14.12.2016
Why would you use a string and convert to integer/float when those two functions do that for you? All you had to change was the name of the functions (add
_assoc before
_int or
_float).
As for the code: it will work but if RID is auto-generated (auto increment) and it exceeds the size of
Rooftop array, it will cause run time error.
Respuesta: error 035: argument type mismatch (argument 2) -
Cerealguy - 14.12.2016
Oh friend I had not noticed that the function was badly written, and regarding the array I have a condition so that it does not exceed the maximum in create rooftop command