Whats wrong in my code?
#1

Hello. i was using a dynamic trees system for my server. i want to use MySQL as storing location. but some prob. is there.

i use streamer. so under OnPlayerEditDynamicObject, i added Insert into..... query to insert the created/edited object inside my DB. but after i press Save button, instead of saving it, it still shows me in Editing phase and it does not get saved.

here is my code:
pawn Код:
public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
{
    if(EditingTreeID[playerid] != -1 && Iter_Contains(Trees, EditingTreeID[playerid]))
    {
        if(response == EDIT_RESPONSE_FINAL)
        {
            new id = EditingTreeID[playerid];
            TreeData[id][treeX] = x;
            TreeData[id][treeY] = y;
            TreeData[id][treeZ] = z;
            TreeData[id][treeRX] = rx;
            TreeData[id][treeRY] = ry;
            TreeData[id][treeRZ] = rz;

            SetDynamicObjectPos(objectid, TreeData[id][treeX], TreeData[id][treeY], TreeData[id][treeZ]);
            SetDynamicObjectRot(objectid, TreeData[id][treeRX], TreeData[id][treeRY], TreeData[id][treeRZ]);

            Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, TreeData[id][treeLabel], E_STREAMER_X, TreeData[id][treeX]);
            Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, TreeData[id][treeLabel], E_STREAMER_Y, TreeData[id][treeY]);
            Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, TreeData[id][treeLabel], E_STREAMER_Z, TreeData[id][treeZ] + 1.5);

            new q[256];
           
            mysql_format(mysql_connection, q,sizeof(q), "INSERT INTO 'trees'('ObjID','PosX','PosY','PosZ','RotX','RotY','RotZ') values(%d,%f,%f,%f,%f,%f,%f)",objectid, TreeData[id][treeX],TreeData[id][treeY],TreeData[id][treeZ],TreeData[id][treeRX],TreeData[id][treeRY],TreeData[id][treeRZ]);
             mysql_query(mysql_connection, q);
            EditingTreeID[playerid] = -1;
        }

        if(response == EDIT_RESPONSE_CANCEL)
        {
            new id = EditingTreeID[playerid];
            SetDynamicObjectPos(objectid, TreeData[id][treeX], TreeData[id][treeY], TreeData[id][treeZ]);
            SetDynamicObjectRot(objectid, TreeData[id][treeRX], TreeData[id][treeRY], TreeData[id][treeRZ]);
            EditingTreeID[playerid] = -1;
        }
    }

    return 1;
}
What am i doing wrong? or is there any better way to do this?
Reply
#2

Always check the logs first! The query is wrong. Quotes (') are completely different from backticks (`). Quotes are used to denote literal strings, backticks are used to denote a table or column name.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)