I have seem to run into a problem it does not close the GUI object editor when doing this here some code that might help it quite a lot if you need to see the rest of my code you can see it here
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if((edittype[playerid])== 1)
{
if (PRESSED(KEY_SECONDARY_ATTACK))
{
new objectid = objects[editobjnum[playerid]];
CallLocalFunction("OnPlayerEditDynamicObject","iiiffffff",playerid,objectid,EDIT_RESPONSE_FINAL,objx[editobjnum[playerid]],objy[editobjnum[playerid]],objz[editobjnum[playerid]],objxrot[editobjnum[playerid]],objyrot[editobjnum[playerid]],objzrot[editobjnum[playerid]]);
}
}
if((edittype[playerid])== 2)
{
if (PRESSED(KEY_SECONDARY_ATTACK))
{
new slotid = mapplayerslotid[playerid];
new objectid = mapobject[slotid][editobjnum[playerid]];
CallLocalFunction("OnPlayerEditDynamicObject","iiiffffff",playerid,objectid,EDIT_RESPONSE_FINAL,playermapx[slotid][editobjnum[playerid]],playermapy[slotid][editobjnum[playerid]],playermapz[slotid][editobjnum[playerid]],playermapxrot[slotid][editobjnum[playerid]],playermapyrot[slotid][editobjnum[playerid]],playermapzrot[slotid][editobjnum[playerid]]);
}
}
return 1;
}
public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
{
if((edittype[playerid])==2)
{
new string[128],savestringname[128],playerfilename[128];
new slotid = mapplayerslotid[playerid];
format(playerfilename,sizeof(playerfilename),"%s",mapname[slotid]);
if((editfirstcheck[playerid])==0)
{
editfirstcheck[playerid] = 1;
oldx[playerid] = x;
oldy[playerid] = y;
oldz[playerid] = z;
oldxrot[playerid] = rx;
oldyrot[playerid] = ry;
oldzrot[playerid] = rz;
}
if(response == EDIT_RESPONSE_UPDATE)
{
format(savestringname,sizeof(savestringname),"mapobjectstring[%i]",editobjnum[playerid]);
new mapstring[128];
format(mapstring,sizeof(mapstring),"%s",dini_Get(playerfilename,savestringname));
format(string,sizeof(string),"object:%s--ID:Objectid-%i-%i-Mid:%i-mapname:%s",mapstring,editobjnum[playerid],slotid,mapobjectmid[slotid][editobjnum[playerid]],mapname[slotid]);
playermapx[slotid][editobjnum[playerid]] = x;
playermapy[slotid][editobjnum[playerid]] = y;
playermapz[slotid][editobjnum[playerid]] = z;
playermapxrot[slotid][editobjnum[playerid]] = rx;
playermapyrot[slotid][editobjnum[playerid]] = ry;
playermapzrot[slotid][editobjnum[playerid]] = rz;
MoveDynamicObject(mapobject[slotid][editobjnum[playerid]],playermapx[slotid][editobjnum[playerid]],playermapy[slotid][editobjnum[playerid]],playermapz[slotid][editobjnum[playerid]],100.0,playermapxrot[slotid][editobjnum[playerid]],playermapyrot[slotid][editobjnum[playerid]],playermapzrot[slotid][editobjnum[playerid]]);
for(new i;i < MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if((showlabel[i])==1)
{
DeletePlayer3DTextLabel(playerid,mapobjectlabel[slotid][editobjnum[playerid]]);
mapobjectlabel[slotid][editobjnum[playerid]] = CreatePlayer3DTextLabel(i,string,COLOR,playermapx[slotid][editobjnum[playerid]],playermapy[slotid][editobjnum[playerid]],playermapz[slotid][editobjnum[playerid]],DISTANCELABEL,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0);
}
}
}
}
if(response == EDIT_RESPONSE_FINAL)
{
edittype[playerid] = 0;
editfirstcheck[playerid] = 0;
new Float:xpos,Float:ypos,Float:zpos,Float:xposrot,Float:yposrot,Float:zposrot;
GetDynamicObjectPos(mapobject[slotid][editobjnum[playerid]],xpos,ypos,zpos);
GetDynamicObjectRot(mapobject[slotid][editobjnum[playerid]],xposrot,yposrot,zposrot);
playermapx[slotid][editobjnum[playerid]] = xpos;
playermapy[slotid][editobjnum[playerid]] = ypos;
playermapz[slotid][editobjnum[playerid]] = zpos;
playermapxrot[slotid][editobjnum[playerid]] = xposrot;
playermapyrot[slotid][editobjnum[playerid]] = yposrot;
playermapzrot[slotid][editobjnum[playerid]] = zposrot;
SendClientMessage(playerid, LIGHTBLUE, "You have moved the object");
format(savestringname,sizeof(savestringname),"playermapx[%i]",editobjnum[playerid]);
dini_IntSet(playerfilename,savestringname,floatround(playermapx[slotid][editobjnum[playerid]]));
format(savestringname,sizeof(savestringname),"playermapy[%i]",editobjnum[playerid]);
dini_IntSet(playerfilename,savestringname,floatround(playermapy[slotid][editobjnum[playerid]]));
format(savestringname,sizeof(savestringname),"playermapz[%i]",editobjnum[playerid]);
dini_IntSet(playerfilename,savestringname,floatround(playermapz[slotid][editobjnum[playerid]]));
format(savestringname,sizeof(savestringname),"playermapxrot[%i]",editobjnum[playerid]);
dini_IntSet(playerfilename,savestringname,floatround(playermapxrot[slotid][editobjnum[playerid]]));
format(savestringname,sizeof(savestringname),"playermapyrot[%i]",editobjnum[playerid]);
dini_IntSet(playerfilename,savestringname,floatround(playermapyrot[slotid][editobjnum[playerid]]));
format(savestringname,sizeof(savestringname),"playermapzrot[%i]",editobjnum[playerid]);
dini_IntSet(playerfilename,savestringname,floatround(playermapzrot[slotid][editobjnum[playerid]]));
format(savestringname,sizeof(savestringname),"mapobjectstring[%i]",editobjnum[playerid]);
new mapstring[128];
format(mapstring,sizeof(mapstring),"%s",dini_Get(playerfilename,savestringname));
format(string,sizeof(string),"object:%s--ID:Objectid-%i-%i-Mid:%i-mapname:%s",mapstring,editobjnum[playerid],slotid,mapobjectmid[slotid][editobjnum[playerid]],mapname[slotid]);
for(new i;i < MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if((showlabel[i])==1)
{
DeletePlayer3DTextLabel(playerid,mapobjectlabel[slotid][editobjnum[playerid]]);
mapobjectlabel[slotid][editobjnum[playerid]] = CreatePlayer3DTextLabel(i,string,COLOR,playermapx[slotid][editobjnum[playerid]],playermapy[slotid][editobjnum[playerid]],playermapz[slotid][editobjnum[playerid]],DISTANCELABEL,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0);
}
}
}
if((allowence[1][playerid])==1)
{
if((playersinput)==1)
{
for(new count=0;count < MAX_PLAYERS;count++)
{
if(IsPlayerAdmince(count,3))
{
new name[128];
GetPlayerName(playerid,name,sizeof(name));
format(string,sizeof(string),"%s has moved object id:%i",name,editobjnum[playerid]);
SendClientMessage(count,DARKBLUE,string);
format(string,sizeof(string),"[from] [%f - %f -%f -angle- %f - %f - %f]",oldx[playerid],oldy[playerid],oldz[playerid],oldxrot[playerid],oldyrot[playerid],oldzrot[playerid]);
SendClientMessage(count,DARKBLUE,string);
format(string,128,"[To] [%f - %f -%f -angle- %f - %f - %f]",playermapx[slotid][editobjnum[playerid]],playermapy[slotid][editobjnum[playerid]],playermapz[slotid][editobjnum[playerid]],playermapxrot[slotid][editobjnum[playerid]],playermapyrot[slotid][editobjnum[playerid]],playermapzrot[slotid][editobjnum[playerid]]);
SendClientMessage(count,DARKBLUE,string);
}
}
}
}
return 1;
}
if(response == EDIT_RESPONSE_CANCEL)
{
edittype[playerid] = 0;
editfirstcheck[playerid] = 0;
MoveDynamicObject(mapobject[slotid][editobjnum[playerid]],oldx[playerid],oldy[playerid],oldz[playerid],100.0,oldxrot[playerid],oldyrot[playerid],oldzrot[playerid]);
playermapx[slotid][editobjnum[playerid]] = oldx[playerid];
playermapy[slotid][editobjnum[playerid]] = oldy[playerid];
playermapz[slotid][editobjnum[playerid]] = oldz[playerid];
playermapxrot[slotid][editobjnum[playerid]] = oldxrot[playerid];
playermapyrot[slotid][editobjnum[playerid]] = oldyrot[playerid];
playermapzrot[slotid][editobjnum[playerid]] = oldzrot[playerid];
format(savestringname,sizeof(savestringname),"playermapx[%i]",editobjnum[playerid]);
dini_IntSet(playerfilename,savestringname,floatround(playermapx[slotid][editobjnum[playerid]]));
format(savestringname,sizeof(savestringname),"playermapy[%i]",editobjnum[playerid]);
dini_IntSet(playerfilename,savestringname,floatround(playermapy[slotid][editobjnum[playerid]]));
format(savestringname,sizeof(savestringname),"playermapz[%i]",editobjnum[playerid]);
dini_IntSet(playerfilename,savestringname,floatround(playermapz[slotid][editobjnum[playerid]]));
format(savestringname,sizeof(savestringname),"playermapxrot[%i]",editobjnum[playerid]);
dini_IntSet(playerfilename,savestringname,floatround(playermapxrot[slotid][editobjnum[playerid]]));
format(savestringname,sizeof(savestringname),"playermapyrot[%i]",editobjnum[playerid]);
dini_IntSet(playerfilename,savestringname,floatround(playermapyrot[slotid][editobjnum[playerid]]));
format(savestringname,sizeof(savestringname),"playermapzrot[%i]",editobjnum[playerid]);
dini_IntSet(playerfilename,savestringname,floatround(playermapzrot[slotid][editobjnum[playerid]]));
format(savestringname,sizeof(savestringname),"mapobjectstring[%i]",editobjnum[playerid]);
new mapstring[128];
format(mapstring,sizeof(mapstring),"%s",dini_Get(playerfilename,savestringname));
format(string,sizeof(string),"object:%s--ID:Objectid-%i-%i-Mid:%i-mapname:%s",mapstring,editobjnum[playerid],slotid,mapobjectmid[editobjnum[playerid]],mapname[slotid]);
for(new i;i < MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if((showlabel[i])==1)
{
DeletePlayer3DTextLabel(playerid,mapobjectlabel[slotid][editobjnum[playerid]]);
mapobjectlabel[slotid][editobjnum[playerid]] = CreatePlayer3DTextLabel(i,string,COLOR,playermapx[slotid][editobjnum[playerid]],playermapy[slotid][editobjnum[playerid]],playermapz[slotid][editobjnum[playerid]],DISTANCELABEL,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0);
}
}
}
if((allowence[1][playerid])==1)
{
if((playersinput)==1)
{
for(new count=0;count < MAX_PLAYERS;count++)
{
if(IsPlayerAdmince(count,3))
{
new name[128];
GetPlayerName(playerid,name,sizeof(name));
format(string,sizeof(string),"%s has canceled moveing object id:%i",name,editobjnum[playerid]);
SendClientMessage(count,DARKBLUE,string);
format(string,sizeof(string),"[from] [%f - %f -%f -angle- %f - %f - %f]",oldx[playerid],oldy[playerid],oldz[playerid],oldxrot[playerid],oldyrot[playerid],oldzrot[playerid]);
SendClientMessage(count,DARKBLUE,string);
}
}
}
}
}
}
else if((edittype[playerid])==1)
{
if((editfirstcheck[playerid])==0)
{
editfirstcheck[playerid] = 1;
oldx[playerid] = x;
oldy[playerid] = y;
oldz[playerid] = z;
oldxrot[playerid] = rx;
oldyrot[playerid] = ry;
oldzrot[playerid] = rz;
if((allowence[1][playerid])==1)
{
if((playersinput)==1)
{
for(new count=0;count < MAX_PLAYERS;count++)
{
if(IsPlayerAdmince(count,3))
{
new name[128],string[128];
GetPlayerName(playerid,name,sizeof(name));
format(string,sizeof(string),"%s has started moveing object id:%i",name,editobjnum[playerid]);
SendClientMessage(count,DARKBLUE,string);
}
}
}
}
}
if(response == EDIT_RESPONSE_UPDATE)
{
new string[128];
format(string,128,"object:%s--ID:%i-Objectid-%i",objectstring[editobjnum[playerid]],editobjnum[playerid],jbobjectid[editobjnum[playerid]]);
objx[editobjnum[playerid]] =x;
objy[editobjnum[playerid]] =y;
objz[editobjnum[playerid]] =z;
objxrot[editobjnum[playerid]] = rx;
objyrot[editobjnum[playerid]] = ry;
objzrot[editobjnum[playerid]] = rz;
for(new i=0;i < MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if((showlabel[i])==1)
{
DeletePlayer3DTextLabel(i,objectlabel[editobjnum[playerid]]);
objectlabel[editobjnum[playerid]] = CreatePlayer3DTextLabel(i,string,COLOR,objx[editobjnum[playerid]],objy[editobjnum[playerid]],objz[editobjnum[playerid]],DISTANCELABEL,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0);
}
}
}
MoveDynamicObject(objects[editobjnum[playerid]],objx[editobjnum[playerid]],objy[editobjnum[playerid]],objz[editobjnum[playerid]],10,objxrot[editobjnum[playerid]],objyrot[editobjnum[playerid]],objzrot[editobjnum[playerid]]);
}
if(response == EDIT_RESPONSE_FINAL)
{
new savestringname[128];
new Float:xpos,Float:ypos,Float:zpos,Float:xposrot,Float:yposrot,Float:zposrot;
GetDynamicObjectPos(objects[editobjnum[playerid]],xpos,ypos,zpos);
GetDynamicObjectRot(objects[editobjnum[playerid]],xposrot,yposrot,zposrot);
objx[editobjnum[playerid]] = xpos;
objy[editobjnum[playerid]] = ypos;
objz[editobjnum[playerid]] = zpos;
objxrot[editobjnum[playerid]] = xposrot;
objyrot[editobjnum[playerid]] = yposrot;
objzrot[editobjnum[playerid]] = zposrot;
SendClientMessage(playerid, LIGHTBLUE, "You have moved this object");
format(savestringname,sizeof(savestringname),"objx[%i]",editobjnum[playerid]);
dini_IntSet(objectsfilename,savestringname,floatround(objx[editobjnum[playerid]]));
format(savestringname,sizeof(savestringname),"objy[%i]",editobjnum[playerid]);
dini_IntSet(objectsfilename,savestringname,floatround(objy[editobjnum[playerid]]));
format(savestringname,sizeof(savestringname),"objz[%i]",editobjnum[playerid]);
dini_IntSet(objectsfilename,savestringname,floatround(objz[editobjnum[playerid]]));
format(savestringname,sizeof(savestringname),"objxrot[%i]",editobjnum[playerid]);
dini_IntSet(objectsfilename,savestringname,floatround(objxrot[editobjnum[playerid]]));
format(savestringname,sizeof(savestringname),"objyrot[%i]",editobjnum[playerid]);
dini_IntSet(objectsfilename,savestringname,floatround(objyrot[editobjnum[playerid]]));
format(savestringname,sizeof(savestringname),"objzrot[%i]",editobjnum[playerid]);
dini_IntSet(objectsfilename,savestringname,floatround(objzrot[editobjnum[playerid]]));
editfirstcheck[playerid] = 0;
edittype[playerid] = 0;
if((allowence[1][playerid])==1)
{
if((playersinput)==1)
{
for(new count=0;count < MAX_PLAYERS;count++)
{
if(IsPlayerAdmince(count,3))
{
new name[128],string[128];
GetPlayerName(playerid,name,sizeof(name));
format(string,sizeof(string),"%s has moved object id:%i",name,editobjnum[playerid]);
SendClientMessage(count,DARKBLUE,string);
format(string,sizeof(string),"[from] [%f - %f -%f -angle- %f - %f - %f]",oldx[playerid],oldy[playerid],oldz[playerid],oldxrot[playerid],oldyrot[playerid],oldzrot[playerid]);
SendClientMessage(count,DARKBLUE,string);
format(string,128,"[To] [%f - %f -%f -angle- %f - %f - %f]",objx[editobjnum[playerid]],objy[editobjnum[playerid]],objz[editobjnum[playerid]],objxrot[editobjnum[playerid]],objyrot[editobjnum[playerid]],objzrot[editobjnum[playerid]]);
SendClientMessage(count,DARKBLUE,string);
}
}
}
}
return 1;
}
if(response == EDIT_RESPONSE_CANCEL)
{
new string[128], savestringname[128];
format(savestringname,sizeof(savestringname),"objectlabel[%i]",editobjnum[playerid]);
editfirstcheck[playerid] = 0;
MoveDynamicObject(objectid,oldx[playerid],oldy[playerid],oldz[playerid],10,oldxrot[playerid],oldyrot[playerid],oldzrot[playerid]);
editobjnum[playerid] = -1;
objx[editobjnum[playerid]] = oldx[playerid];
objy[editobjnum[playerid]] = oldy[playerid];
objz[editobjnum[playerid]] = oldz[playerid];
objxrot[editobjnum[playerid]] = oldxrot[playerid];
objyrot[editobjnum[playerid]] = oldyrot[playerid];
objzrot[editobjnum[playerid]] = oldzrot[playerid];
format(savestringname,sizeof(savestringname),"objx[%i]",editobjnum[playerid]);
dini_IntSet(objectsfilename,savestringname,floatround(oldx[playerid]));
format(savestringname,sizeof(savestringname),"objy[%i]",editobjnum[playerid]);
dini_IntSet(objectsfilename,savestringname,floatround(oldy[playerid]));
format(savestringname,sizeof(savestringname),"objz[%i]",editobjnum[playerid]);
dini_IntSet(objectsfilename,savestringname,floatround(oldz[playerid]));
format(savestringname,sizeof(savestringname),"objxrot[%i]",editobjnum[playerid]);
dini_IntSet(objectsfilename,savestringname,floatround(oldxrot[playerid]));
format(savestringname,sizeof(savestringname),"objyrot[%i]",editobjnum[playerid]);
dini_IntSet(objectsfilename,savestringname,floatround(oldyrot[playerid]));
format(savestringname,sizeof(savestringname),"objzrot[%i]",editobjnum[playerid]);
dini_IntSet(objectsfilename,savestringname,floatround(oldzrot[playerid]));
edittype[playerid] = 0;
format(string,128,"object:%s--ID:%i-Objectid-%i",objectstring[editobjnum[playerid]],editobjnum[playerid],jbobjectid[editobjnum[playerid]]);
for(new i=0;i < MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if((showlabel[i])==1)
{
DeletePlayer3DTextLabel(i,objectlabel[editobjnum[playerid]]);
objectlabel[editobjnum[playerid]] = CreatePlayer3DTextLabel(i,string,COLOR,objx[editobjnum[playerid]],objy[editobjnum[playerid]],objz[editobjnum[playerid]],DISTANCELABEL,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0);
}
}
}
if((allowence[1][playerid])==1)
{
if((playersinput)==1)
{
for(new count=0;count < MAX_PLAYERS;count++)
{
if(IsPlayerAdmince(count,3))
{
new name[128];
GetPlayerName(playerid,name,sizeof(name));
format(string,sizeof(string),"%s has canceled moveing object id:%i",name,editobjnum[playerid]);
SendClientMessage(count,DARKBLUE,string);
format(string,sizeof(string),"[from] [%f - %f -%f -angle- %f - %f - %f]",oldx[playerid],oldy[playerid],oldz[playerid],oldxrot[playerid],oldyrot[playerid],oldzrot[playerid]);
SendClientMessage(count,DARKBLUE,string);
}
}
}
}
}
}
return 1;
}