14.08.2016, 17:36
Hi,
I'm making a "safe" system where the safe's object can be movable via EditDynamicObject
Command which creates the safe:
This command works, the part which doesn't work is the OnPlayerEditDynamicObject
This part doesn't work, like it is not called - But I have the GUI and everything in game, but there is no error messages or things like that, I don't understand
When I did this with normal Object (and not Dynamic Objects) it works fine, now I've translated it into Dynamic Object and nothing works anymore.
Is it my code with the safe or am I using the DynamicObject callback wrong ?
Thanks and sorry for english mistakes / bad code indentation
I'm making a "safe" system where the safe's object can be movable via EditDynamicObject
PHP код:
new pSafe[MAX_PLAYERS];
PHP код:
Total_Safes_Created++;
new Float:pos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
Safes[Total_Safes_Created][Owner] = Character[playerid][ID];
Safes[Total_Safes_Created][PosX] = pos[0];
Safes[Total_Safes_Created][PosY] = pos[1];
Safes[Total_Safes_Created][PosZ] = pos[2];
Safes[Total_Safes_Created][rX] = 0;
Safes[Total_Safes_Created][rY] = 0;
Safes[Total_Safes_Created][rZ] = 0;
pSafe[playerid] = Total_Safes_Created;
CreateSafe(Total_Safes_Created);
Safes[Total_Safes_Created][saObject] = CreateDynamicObject(2332, Safes[Total_Safes_Created][PosX],Safes[Total_Safes_Created][PosY],Safes[Total_Safes_Created][PosZ], Safes[Total_Safes_Created][rX], Safes[Total_Safes_Created][rY],Safes[Total_Safes_Created][rZ], Safes[Total_Safes_Created][World],Safes[Total_Safes_Created][Interior],-1, 200.0, 0.0);
SendClientMessage(playerid,-1,"/editsafe to edit safe's position");
EditDynamicObject(playerid, Safes[Total_Safes_Created][saObject]); // The player can now edit the safe's position
PHP код:
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)
{
new Float:oldX, Float:oldY, Float:oldZ, Float:oldRotX, Float:oldRotY, Float:oldRotZ;
GetObjectPos(objectid, oldX, oldY, oldZ);
GetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
if(!IsValidObject(objectid)) return 1;
SetDynamicObjectPos(objectid, x, y, z);
SetDynamicObjectRot(objectid, rx, ry, rz);
if(response == EDIT_RESPONSE_FINAL)
{
new str[256];
format(str,sizeof(str),"pSafe[playerid] (2) = %d",pSafe[playerid]);
SendClientMessage(playerid,-1,str);
if(pSafe[playerid] != 0)
{
SetDynamicObjectPos(pSafe[playerid], x, y, z);
SetDynamicObjectRot(pSafe[playerid], rx, ry, rz);
SendClientMessage(playerid,-1,"Position saved");
Safes[pSafe[playerid]][PosX] = x;
Safes[pSafe[playerid]][PosY] = y;
Safes[pSafe[playerid]][PosZ] = z;
Safes[pSafe[playerid]][rX] = rx;
Safes[pSafe[playerid]][rY] = ry;
Safes[pSafe[playerid]][rZ] = rz;
format(str,sizeof(str),"pX: %f - pY: %f - pZ: %f - rX: %f - rY: %f - rZ: %f",Safes[pSafe[playerid]][PosX],Safes[pSafe[playerid]][PosY],Safes[pSafe[playerid]][PosZ],Safes[pSafe[playerid]][rX],Safes[pSafe[playerid]][rY],Safes[pSafe[playerid]][rZ]);
SendClientMessage(playerid,-1,str);
new query[512];
format(query, sizeof(query), "UPDATE `Safes` SET PosX = %f, PosY = %f, PosZ = %f, rX = %f, rY = %f, rZ = %f WHERE SQLID = %d",Safes[pSafe[playerid]][PosX],Safes[pSafe[playerid]][PosY],Safes[pSafe[playerid]][PosZ],Safes[pSafe[playerid]][rX],Safes[pSafe[playerid]][rY],Safes[pSafe[playerid]][rZ],Safes[pSafe[playerid]][SQLID]);
mysql_tquery(SQL_CONNECTION, query); // UPDATE Safe
}
else
{
SendClientMessage(playerid,-1,"pSafe is equal to zero ");
}
}
else
{
SendClientMessage(playerid,-1,"Error (Reponse != Edit_Response_Final)");
}
return 1;
}
When I did this with normal Object (and not Dynamic Objects) it works fine, now I've translated it into Dynamic Object and nothing works anymore.
Is it my code with the safe or am I using the DynamicObject callback wrong ?
Thanks and sorry for english mistakes / bad code indentation