15.11.2013, 16:59
Hey, i have a problem with OnPlayerEditObject. Idea is that, that the command need to create ATM object and forward me to editing this object. When i have finished editing, it should save cordinates to MySQL and Send me a message.
But there is some kind of problem, with OnPlayerEditObject callback. It doesnt to nothing, only move the object, but it doesnt save and send me a message. I apperciate, when somebody can help me.
Command
OnPlayerEditObject callback
But there is some kind of problem, with OnPlayerEditObject callback. It doesnt to nothing, only move the object, but it doesnt save and send me a message. I apperciate, when somebody can help me.
Command
pawn Код:
CMD:teeatm(playerid, params[])
{
new Float:ax, Float:ay, Float:az;
new query[500];
mysql_store_result();
new id = mysql_insert_id()+1;
mysql_free_result();
if(PlayerInfo[playerid][pAdmin] < 8) return SendClientMessage(playerid, V_PUNANE, NOTADMIN);
GetPlayerPos(playerid, ax, ay, az);
GetPlayerFacingAngle(playerid, aInfo[id][aAngle]);
format(query, sizeof(query), "INSERT INTO ATMID(ATMID, aX, aY, aZ) VALUES(%d, %f, %f, %f)", id, ax, ay, az);
mysql_query(query);
aInfo[id][aID] = id;
aInfo[id][aX] = ax;
aInfo[id][aY] = ay;
aInfo[id][aZ] = az;
aInfo[id][aModel] = CreateObject(2942, ax+0.5, ay, az, 0.0, 0.0, 0.0, 75.0);
oModel[playerid] = 2942;
EditObject(playerid, aInfo[id][aModel]);
return 1;
}
pawn Код:
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
new Float:oldX, Float:oldY, Float:oldZ,
Float:oldRotX, Float:oldRotY, Float:oldRotZ;
GetObjectPos(objectid, oldX, oldY, oldZ);
GetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
new Float:OX, Float:OY, Float:OZ, Float:ORX, Float:ORY, Float:ORZ;
if(!playerobject) // If this is a global object, move it for other players
{
if(!IsValidObject(objectid)) return;
MoveObject(objectid, fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ);
}
if(response == EDIT_RESPONSE_FINAL)
{
if(oModel[playerid] == 2942)
{
for(new i = 1; i < MAX_ATMS; i++)
{
new query[500];
DestroyObject(objectid);
GetObjectPos(objectid, OX, OY, OZ);
GetObjectRot(objectid, ORX, ORY, ORZ);
aInfo[i][aModel] = CreateObject(2942,OX, OY, OZ,ORX,ORY,ORZ,0);
format(query, sizeof(query), "UPDATE ATMID SET aX=%f, aY=%f, aZ=%f WHERE ATMID = %d", OX, OY, OZ, i);
mysql_query(query);
SendClientMessage(playerid, COLOR_GREEN, "ATM edukalt tehtud ning paigutatud");
print("ATM tehtud");
}
}
}
if(response == EDIT_RESPONSE_CANCEL)
{
//The player cancelled, so put the object back to it's old position
if(!playerobject) //Object is not a playerobject
{
SetObjectPos(objectid, oldX, oldY, oldZ);
SetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
}
else
{
SetPlayerObjectPos(playerid, objectid, oldX, oldY, oldZ);
SetPlayerObjectRot(playerid, objectid, oldRotX, oldRotY, oldRotZ);
}
}
}