Objects Not Saving in MySQL Database
#1

Hey, so I made a MySQL database driven object system a few months back, but after I have added a dynamic object plugin, the objects have not been saving correctly.

Sometimes if you get lucky the object will save, but that is hardly ever the case. I have tried to pin point the error by print()'ing in every function and if statement, but it never seems to get to this part below.

pawn Код:
forward OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
{
    print("#Custom OnPlayerEditDynamicObject was called.");

    new objquery[300], pname[MAX_PLAYER_NAME], resp[MAX_PLAYERS];//[200];

    format(resp, sizeof(resp), "%i", response);
    SendClientMessage(playerid, -1, resp);

    if(!IsValidDynamicObject(objectid))
    {
        print("/object invalid");

        return SendClientMessage(playerid, -1, "You've selected an invalid object.");
    }

    if(response == 0)
    {
        print("#5 The player has cancelled the object insertation.");

        PlayerInformation[playerid][Obj] = objectid;
        ShowPlayerDialog(playerid, 6, DIALOG_STYLE_MSGBOX,"Delete Selected Object", "Would you like to delete this object from the server?\n\nYou can un-do this in the admin control panel if needed.", "YES", "NO");
    }
    else if(response == 1)
    {
        MoveDynamicObject(objectid, x, y, z, 10.0, rx, ry, rz);
        IGObj[objectid][OBJX] = x;
        IGObj[objectid][OBJY] = y;
        IGObj[objectid][OBJZ] = z;
        IGObj[objectid][OBJRX] = rx;
        IGObj[objectid][OBJRY] = ry;
        IGObj[objectid][OBJRZ] = rz;

        GetPlayerName(playerid, pname, sizeof(pname));

        print("#6 The player has clicked on the save icon in the object editor.");

        if(IGObj[objectid][ID] == 0)
        {
            mysql_format(gMySQLConnect, objquery, sizeof(objquery), "INSERT INTO `Objects` (ObjectID, fX, fY, fZ, rX, rY, rZ) VALUES (%d, %f, %f, %f, %f, %f, %f)", IGObj[objectid][ObjID], x, y, z, rx, ry, rz);
            mysql_function_query(gMySQLConnect, objquery, true, "createObject", "d", objectid);

            PlayerInformation[playerid][NewOBJ] = 0;
            SendClientMessage(playerid, -1, "dialog should be shown asking for a description");
            ShowPlayerDialog(playerid, 5, DIALOG_STYLE_INPUT, "Object Description", "Enter the object description below.\n\nFor example: 'Map Name + Purpose' = 'Blueberry Fence'", "Save", "Cancel");
        }
        else
        {
            mysql_format(gMySQLConnect, objquery, sizeof(objquery), "UPDATE `Objects` SET ObjectID = %d, fX = %f, fY = %f, fZ = %f, rX = %f, rY = %f, rZ = %f, utime = %i, uname = %s WHERE ID = %d", IGObj[objectid][ObjID], x, y, z, rx, ry, rz, gettime(), pname, IGObj[objectid][ID]);
            mysql_function_query(gMySQLConnect, objquery, true, "EndThread", "");

            print("#7 The object position will be updated.");
        }
    }
    return 1;
}
It does not show the dialog asking for the object description or the SendClientMessage just above ShowPlayerDialog. It doesn't even print #6, so it must be something to do with the if(response == 1)?

No errors are outputted in the server_log.txt either.

If anything else is needed to solve this, please let me know.

Thanks,
CM707
Reply
#2

Bump, I have kind of found out what may be causing it.

I am assuming that it is the if(response == 1), can't really go into much more detail though as that is all I know.
Reply
#3

The fact it save's on rare occasions sounds weird to me. As you've said before on the IRC it could be the streamer. Try changing the streamer or updating your mysql plugin. Tell me if it worked or not.
Reply
#4

Try printing this too at start of callback
pawn Код:
print("#Custom OnPlayerEditDynamicObject was called.");
printf(">> Response : %i", response);
And which line doesn't print usually?
Reply
#5

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
Try printing this too at start of callback
pawn Код:
print("#Custom OnPlayerEditDynamicObject was called.");
printf(">> Response : %i", response);
And which line doesn't print usually?
Quote:

[10:30:50] #Custom OnPlayerEditDynamicObject was called.
[10:30:50] >> Response : 2
[10:30:50] #Custom OnPlayerEditDynamicObject was called.
[10:30:50] >> Response : 2
[10:30:50] #Custom OnPlayerEditDynamicObject was called.
[10:30:50] >> Response : 2
[10:30:51] #Custom OnPlayerEditDynamicObject was called.
[10:30:51] >> Response : 2
[10:30:52] #Custom OnPlayerEditDynamicObject was called.
[10:30:52] >> Response : 1

They both print. But it doesn't go into the if statement.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)