error 035: argument type mismatch (argument 2)
#1

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)
Reply
#2

https://sampwiki.blast.hk/wiki/Db_get_field_assoc_int
https://sampwiki.blast.hk/wiki/Db_get_field_assoc_float
Reply
#3

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=0x<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.50, -1, -150.0);
            
Rooftop[id][checkpointidx][1] =  CreateDynamicCP(Rooftop[id][TelePos][0], Rooftop[id][TelePos][1], Rooftop[id][TelePos][2], 1.50, -1, -150.0);
            
Rooftop[id][textid][0] = CreateDynamic3DTextLabel("[ROOFTOP]"COLOR_VIPRooftop[id][EnterPos][0], Rooftop[id][EnterPos][1], Rooftop[id][EnterPos][2], 15.0);
            
Rooftop[id][textid][1] = CreateDynamic3DTextLabel("[Exit]"COLOR_VIPRooftop[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
Reply
#4

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.
Reply
#5

PHP код:
forward LoadRooftop();
public 
LoadRooftop()
{
    
queryresult db_query(Database"SELECT * FROM `ROOFTOP`");
    new 
count db_num_rows(queryresult);
    if(
count 0)
    {
        new 
idftd[30];
        for (new 
x=0x<countx++)
        {
               
db_get_field_assoc(queryresult"RID"ftd26);
            
id strval(ftd);
            
db_get_field_assoc(queryresult"EnterX"ftd30);
            
Rooftop[id][EnterPos][0] = floatstr(ftd);
            
db_get_field_assoc(queryresult"EnterY"ftd30);
            
Rooftop[id][EnterPos][1] = floatstr(ftd);
            
db_get_field_assoc(queryresult"EnterZ"ftd30);
            
Rooftop[id][EnterPos][2] = floatstr(ftd);
            
db_get_field_assoc(queryresult"ExitX"ftd30);
              
Rooftop[id][TelePos][0] = floatstr(ftd);
            
db_get_field_assoc(queryresult"ExitY"ftd30);
            
Rooftop[id][TelePos][1] = floatstr(ftd);
            
db_get_field_assoc(queryresult"ExitZ"ftd30);
            
Rooftop[id][TelePos][2] = floatstr(ftd);

            
Rooftop[id][checkpointidx][0] =  CreateDynamicCP(Rooftop[id][EnterPos][0], Rooftop[id][EnterPos][1], Rooftop[id][EnterPos][2], 1.50, -1, -150.0);
            
Rooftop[id][checkpointidx][1] =  CreateDynamicCP(Rooftop[id][TelePos][0], Rooftop[id][TelePos][1], Rooftop[id][TelePos][2], 1.50, -1, -150.0);
            
Rooftop[id][textid][0] = CreateDynamic3DTextLabel("[ROOFTOP]"COLOR_VIPRooftop[id][EnterPos][0], Rooftop[id][EnterPos][1], Rooftop[id][EnterPos][2], 15.0);
            
Rooftop[id][textid][1] = CreateDynamic3DTextLabel("[Exit]"COLOR_VIPRooftop[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?
Reply
#6

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.
Reply
#7

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)