updating object scale and offsets in attached objects
#1

Hello all just to learn out some stuff i made a clothing system which works perfectly, EXCEPT for when i edit the object i can see it in new positions but my friend cant see it in the position i lastly set. I ******d for it, looked upon wiki i dont know how to solve this.

So for more explanation when you buy a clothing eg glasses it gets saved with offsets 0 which means inside the players head. So I have to edit it which i do too and when i edit it its new position is right place but if my friend is around me when i edit it, when im done with editing, he sees my glasses still inside my head. Any possible fix for this? I also use edit for duffelbag and i didnt actually give it a save system as it only comes with a command and i need to keep it without a save system so i cant just removeattached then attach again
Reply
#2

Maybe post your OnPlayerEditAttachedObject codes? From all running scripts.
Reply
#3

I was thinking about something like moveattachedobject or something for this but sure lol
Код:
public OnPlayerEditAttachedObject(playerid, response, index, modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ)
{
	if(response)
	{
	    if(USER[playerid][ADMIN]>30)
		{
			if(index==8)
	    	{
				new text[100];
				format(text,sizeof(text),"%f,%f,%f,%f,%f,%f,%f,%f,%f",fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
				SCM(playerid,COLOR_RED,text);
	    	}
		}
		new query[700],objectid,itemdb;
	    objectid=GetPVarInt(playerid,"EDITSLOT");
	    if(objectid==0)
	    {
	        itemdb=GetPVarInt(playerid,"OBJ1");
	    }
	    if(objectid==1)
	    {
	        itemdb=GetPVarInt(playerid,"OBJ2");
	    }
	    if(objectid==2)
	    {
	        itemdb=GetPVarInt(playerid,"OBJ3");
	    }
	    if(objectid==3)
	    {
	        itemdb=GetPVarInt(playerid,"OBJ4");
	    }
	    if(objectid==4)
	    {
	        itemdb=GetPVarInt(playerid,"OBJ5");
	    }
	    if(objectid==5)
	    {
	        itemdb=GetPVarInt(playerid,"OBJ6");
	    }
		mysql_format(mysql,query,sizeof(query),"UPDATE *cencored:)* SET offx=%f, offy=%f, offz=%f, rotx=%f, roty=%f, rotz=%f, sizex=%f, sizey=%f, sizez=%f WHERE itemid=%d",fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ,itemdb);
	    mysql_query(mysql,query);
	    return 1;
	}
	return 1;
}
NOTE: I run this block only in my gamemode, i dont like running filterscripts as they always feel messier. I just see a code block and just develop more on it then implement it or just make some lines up from my mind then directly implement to my game mode so i don't have to use many enums on different files. Easier to remember and feels more stable
Reply
#4

Are the values saved correctly or is the only problem that other players around you do not see the updated position?

It seems like you don't really re-attach the object in OnPlayerEditObject. You only update the values in the database.
That may explain why the actually attached object is still the same as before, but only you can see the updated position since you moved it there.
Reply
#5

You can try one thing. Once a player saves the position, remove that object and re-attach it taking data from saved files.
Reply
#6

Wait what? Are you using AttachObjectToPlayer or SetPlayerAttachedObject?

Which function you use to edit? EditPlayerObject or EditAttachedObject?

I doubt so, because people would use SetPlayerAttachedObject + EditAttachedObject for glasses, as these attach on player's skin bone, and is not solid.


But this is common that people mistaken the usage between Player Object functions and Player Attached Object, just like NaS, he mentioned the callback for EditPlayerObject, since you are mentioning MoveAttachedObject (what is that?) which is different thing.


Why do you use GetPVarInt to find out which object is being edited? The index variable from the callback already tells you which slot was being edited with EditAttachedObject?


So can you post a code where you create the glasses and the command to edit it?


EDIT: So i'm expecting you would do it by using SetPlayerAttachedObject, using EditAttachedObject, then OnPlayerEditAttachedObject with response = 1 you just return 1; after you store it to database.
Reply
#7

Quote:
Originally Posted by RoboN1X
Посмотреть сообщение
Wait what? Are you using AttachObjectToPlayer or SetPlayerAttachedObject?

Which function you use to edit? EditPlayerObject or EditAttachedObject?

I doubt so, because people would use SetPlayerAttachedObject + EditAttachedObject for glasses, as these attach on player's skin bone, and is not solid.


But this is common that people mistaken the usage between Player Object functions and Player Attached Object, just like NaS, he mentioned the callback for EditPlayerObject, since you are mentioning MoveAttachedObject (what is that?) which is different thing.


Why do you use GetPVarInt to find out which object is being edited? The index variable from the callback already tells you which slot was being edited with EditAttachedObject?


So can you post a code where you create the glasses and the command to edit it?


EDIT: So i'm expecting you would do it by using SetPlayerAttachedObject, using EditAttachedObject, then OnPlayerEditAttachedObject with response = 1 you just return 1; after you store it to database.
I forgot the word "Attached", just a typo. Obviously he is using SetPlayerAttachedObject, otherwise OnPlayerEditAttachedObject wouldn't be called (which is the case since the values in the DB were updated).

But you probably gave away the proper fix. Returning 1.
Reply
#8

Quote:
Originally Posted by NaS
Посмотреть сообщение
I forgot the word "Attached", just a typo. Obviously he is using SetPlayerAttachedObject, otherwise OnPlayerEditAttachedObject wouldn't be called (which is the case since the values in the DB were updated).

But you probably gave away the proper fix. Returning 1.
Well although he already returned 1 in his code, he also said that he only runs gamemode... Since returning 0 from filterscripts or another codes in filtescripts might prevent that.

What still weird for me is why he used objectid from GetPVarInt "slot" instead of index variable. That's why i want to know first wether he mistaken the function or not.

The mysql query might be also the problem if it had failure/crash (returning 0 and exit the callback from runtime error, like how commands turned to "SERVER: Unknown command") and then canceling any edit from being synced to others. If you believe it is, just comment off the mysql lines and try to edit the glasses again.
Reply
#9

mysql query isnt crashing or anything i can save it perfectly. Because removing the clothing and re wearing it fixes. Sorry for late answer.

By the way i limit the clothing to 6 items so i use pvars to see if index 1 or 2 or to the number i limited is set already.

Yes i switched to removing the object and reattaching.

Also I use SetPlayerAttachedObject to set these.

Lastly that bag i decided to use some default variables that are set by me and i won't let players edit the bag size and location. Bag is supposed to be carried for only two minutes anyways as people will unload some stuff from vehicle to bag and unpack it in house again

But still its weird why i can't update the new location without removing and re attaching.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)