OnPlayerEditObject issues.
#1

I've been trying to use the EditObject() and MoveObject() functions when a player edits and object so that in-game object editing is possible. It works fine, but only for the player who edited the object. For other players the object is still in the first position.

I have search around the forums for a possible answer but each time they all seem to do the same thing. It works for the player but not other players. What I have below should in fact work according to the wiki and other threads. Any help is appreciated.

Код:
PlayerObject = CreateObject(967, x, y, z, 0.0, 0.0, 0.0);
EditObject(playerid, PlayerObject);

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(PlayerObject, oldX, oldY, oldZ);
	if(response == EDIT_RESPONSE_FINAL) //If they press the save button, it should move the object.
	{
	    //MoveObject(PlayerObject, fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ); //I tried both moving and destroying+re-creating the object
	    DestroyObject(PlayerObject);
	    CreateObject(PlayerObject, fX, fY, fZ, fRotX, fRotY, fRotZ);
	}
	
	if(response == EDIT_RESPONSE_UPDATE) //Once the player unclicks an edit button it should move the object
	{
	    MoveObject(PlayerObject, fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ);
	}

	if(response == EDIT_RESPONSE_CANCEL) //Canceling the edit, this doesn't move the object back to the original position either.
	{
		SetObjectPos(PlayerObject, oldX, oldY, oldZ);
		SetObjectRot(PlayerObject, oldRotX, oldRotY, oldRotZ);
	}
}
Reply
#2

I have no experience with those functions, but maybe you need to save the OBJECT's position after the player finishs editing?
Reply
#3

Bump. Still having issues with this and really could use some help.
Reply
#4

Dude, didn't I explain this twice already this will be the third time MoveObject(); will cause problems don't use it.
Reply
#5

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Dude, didn't I explain this twice already this will be the third time MoveObject(); will cause problems don't use it.
No you didn't explain anything. At all. Please read what it says in the first post.
Reply
#6

He's right. MoveObject can cause problems because the user's input is 'fighting' with the interpolation of the object's position. He mentioned it before in other topics (not this one). Use SetObjectPos, or create a more complex system where the object is created for every player (with player-objects) and MovePlayerObject is used on all EXCEPT the one the player is editing.
Reply
#7

Quote:
Originally Posted by MP2
Посмотреть сообщение
He's right. MoveObject can cause problems because the user's input is 'fighting' with the interpolation of the object's position. He mentioned it before in other topics (not this one). Use SetObjectPos, or create a more complex system where the object is created for every player (with player-objects) and MovePlayerObject is used on all EXCEPT the one the player is editing.
I've tried SetObjectPos, it only works for the player who moved it still. I also had CreatePlayerObject/MovePlayerObject but this means that the object doesn't show up at all for other users. I've tried destroying and re-creating the object, I've tried storing the object postions and rotations to PVars but it still only changes for the player who started editing the object in the first place. Heck, I've even tried using Incognitos streamer to do the same thing but it causes similar issues.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)