MySQL command problem
#1

Hi, I have create my in game mapping editor and I try to switch to MySQL R41
My problem is when I type /ocreate <modelid>, their is no object spawn like nothing happens

their is the commande
pawn Код:
COMMAND:ocreate(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return 0;
    new model,Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,x,y,z);
    if(sscanf(params, "i", model)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /ocreate [model ID]");
    //format(dquery, sizeof(dquery), "INSERT INTO objects (ModelID, oX, oY, oZ, roX, roY, roZ) VALUES (%d, %f, %f, %f, %f, %f, %f)", model, x+2, y, z, 0, 0, 0);
    //mysql_query(dquery,0,0,1);
    format(sql, sizeof(sql), "INSERT INTO objects SET (ModelID, oX, oY, oZ, roX, roY, roZ) VALUES (%d, %f, %f, %f, %f, %f, %f)", model, x+2, y, z, 0, 0, 0);
    mysql_pquery(MYSQL,sql);
   
    //mysql_function_query(1, "SELECT MAX(ScriptID) FROM objects", true, "LoadSingleObject", "iiffffffi", playerid, sizeof(object),x +2,y,z,0,0,0,model);
    mysql_tquery(MYSQL,"SELECT MAX(ScriptID) * FROM objects","LoadSingleObject","iiffffffi", playerid, sizeof(object),x +2,y,z,0,0,0,model);
    return 1;
}
is it good ?
Reply
#2

Their is the LoadObject

pawn Код:
public LoadObjects(limit)
{
    // new count, rows, fields, data[50];
//  cache_get_data(rows, fields);
   
    new count, rows, fields, data[50];
    cache_get_row_count(rows);
    cache_get_field_count(fields);
    for(new i; i < rows; i++)
    {
        if(count > limit)
        {
            printf("Number of objects exceeded limit!");
            break;
        }      
        for(new h; h < sizeof(object); h++)
        {
            if(object[h][oScriptID] == 0)
            {
                cache_get_value_name(i, "ScriptID", data); object[h][oScriptID] = strval(data);
                cache_get_value_name(i, "ModelID", data); object[h][oModelID] = strval(data);
                cache_get_value_name(i, "ObjectID", data); object[h][oObjectID] = strval(data);
                cache_get_value_name(i, "oX", data); object[h][oX] = floatstr(data);
                cache_get_value_name(i, "oY", data); object[h][oY] = floatstr(data);
                cache_get_value_name(i, "oZ", data); object[h][oZ] = floatstr(data);
                cache_get_value_name(i, "roX", data); object[h][roX] = floatstr(data);
                cache_get_value_name(i, "roY", data); object[h][roY] = floatstr(data);
                cache_get_value_name(i, "roZ", data); object[h][roZ] = floatstr(data);
                object[h][oObjectID] = CreateDynamicObject(object[h][oModelID], object[h][oX], object[h][oY], object[h][oZ], object[h][roX], object[h][roY], object[h][roZ]);
                printf("Object ID %d loaded. Objects Memory slot: %d",object[h][oScriptID],h);
                count++;
                break;
            }
        }
    }
    printf("Current objects on the server: %d",CountDynamicObjects());
    return 1;      
}
idk what's wrong
Reply
#3

What's wrong? Is there an error while compiling? Show your MySQL logs.
Reply
#4

Their is no errors, just nothing happens when I type the command
Reply
#5

I saw in the samp-server this error:

1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '=1746.454467, oY=-1856.680175, oZ=13.414062, roX=0.000000, roY=0.000000, roZ=0.0' at line 1 INSERT INTO objects SET ModelID=1400, oX==1746.454467, oY=-1856.680175, oZ=13.414062, roX=0.000000, roY=0.000000, roZ=0.000000
Reply
#6

Problem solve when I use this format

pawn Код:
format(sql, sizeof(sql), "INSERT INTO objects (ModelID, oX, oY, oZ, roX, roY, roZ) VALUES (%d, %f, %f, %f, %f, %f, %f)",model, x+2, y, z, 0, 0, 0);
    mysql_pquery(MYSQL,sql);
But their ID don't work :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)