GetAttachedObjectPos
#1

Hello everyone. Well i need a bit of help,Get Attached Object Pos this actually confused me.
I created an player object [Prop] and attached it to a player, i want to Get the attached object position and whenever a player joins or when ever the object is attached, i want to create the same object [Prop] for the specific player who joined and only he can see it. Like when i attach an object, create the same object for every other player that is connected/ or connects later and Get the object[ prop] position and set the new object position (which i created for every other player) to the Prop object position.

It really confused me, Can this in anyway help me?

pawn Код:
stock GetAttachedObjectPos(objectid, Float:offset_x, Float:offset_y, Float:offset_z, &Float:x, &Float:y, &Float:z)
{
    new Float:object_px,
        Float:object_py,
        Float:object_pz,
        Float:object_rx,
        Float:object_ry,
        Float:object_rz;
    GetObjectPos(objectid, object_px, object_py, object_pz);
    GetObjectRot(objectid, object_rx, object_ry, object_rz);
    new Float:cos_x = floatcos(object_rx, degrees),
        Float:cos_y = floatcos(object_ry, degrees),
        Float:cos_z = floatcos(object_rz, degrees),
        Float:sin_x = floatsin(object_rx, degrees),
        Float:sin_y = floatsin(object_ry, degrees),
        Float:sin_z = floatsin(object_rz, degrees);
    x = object_px + offset_x * cos_y * cos_z - offset_x * sin_x * sin_y * sin_z - offset_y * cos_x * sin_z + offset_z * sin_y * cos_z + offset_z * sin_x * cos_y * sin_z;
    y = object_py + offset_x * cos_y * sin_z + offset_x * sin_x * sin_y * cos_z + offset_y * cos_x * cos_z + offset_z * sin_y * sin_z - offset_z * sin_x * cos_y * cos_z;
    z = object_pz - offset_x * cos_x * sin_y + offset_y * sin_x + offset_z * cos_x * cos_y;
}
Reply
#2

can you not just attach a new object to the player with the same offset?
Reply
#3

I don't want to attach, I want to CreateObject and set it position to the attachedobject.
As OnPlayerWeaponShot, dosen't detects attachedobjects.
Reply
#4

more like this then?
Код:
new Float:ox,Float:oy,Float:oz,Float:orx,Float:ory,Float:orz;
GetObjectPos(firstobjectid,ox,oy,oz);
GetObjectRot(firstobjectid,orx,ory,orz);
secondobjectid = CreateObject(modelid,ox,oy,oz,orx,ory,orz);
//AttachObjectToObject(secondobjectid,firstobjectid,0.0,0.0,0.0,orx,ory.orz); //attach if you want to
Reply
#5

No, i want to get the position of attached object
pawn Код:
Prop[playerid] = CreatePlayerObject(playerid, PropPositions[ii][ModelID], PropPositions[ii][Offset][0], PropPositions[ii][Offset][1], PropPositions[ii][Offset][2], PropPositions[ii][Rot][0], PropPositions[ii][Rot][1], PropPositions[ii][Rot][2]);
                AttachObjectToPlayer(Prop[playerid], playerid , PropPositions[ii][Offset][0], PropPositions[ii][Offset][1], PropPositions[ii][Offset][2], PropPositions[ii][Rot][0], PropPositions[ii][Rot][1], PropPositions[ii][Rot][2]);
The object above is invisible only the player it's attached to can see it.

I want it's position as it's attached to a player, it'll change as the player moves, so i want to create an object for every other player other than the one to whom it's attached to and want that object to move with the player object [Prop] ....


EDIT: I hope you understand now

I created an player object [Prop] and attached it to a player, i want to Get the attached object position and whenever a player joins or when ever the object is attached, i want to create the same object [Prop] for the specific player who joined and only he can see it. Like when i attach an object, create the same object for every other player that is connected/ or connects later and Get the object[ prop] position and set the new object position (which i created for every other player) to the Prop object position.
Reply
#6

this should add it to everyone else on the server
Код:
Prop[playerid] = CreatePlayerObject(playerid, PropPositions[ii][ModelID], PropPositions[ii][Offset][0], PropPositions[ii][Offset][1], PropPositions[ii][Offset][2], PropPositions[ii][Rot][0], PropPositions[ii][Rot][1], PropPositions[ii][Rot][2]);
                AttachObjectToPlayer(Prop[playerid], playerid , PropPositions[ii][Offset][0], PropPositions[ii][Offset][1], PropPositions[ii][Offset][2], PropPositions[ii][Rot][0], PropPositions[ii][Rot][1], PropPositions[ii][Rot][2]);
                new Float:ox,Float:oy,Float:oz,Float:orx,Float:ory,Float:orz;
				GetObjectPos(Prop[playerid],ox,oy,oz);
				GetObjectRot(Prop[playerid],orx,ory,orz);
				for(new i = 0; i < MAX_PLAYERS; i++){
				    if(!IsPlayerConnected(i))continue;
				    if(i == playerid)continue;
				    Prop[i] = CreatePlayerObject(i, PropPositions[ii][ModelID], ox,oy,oz,orx,ory,orz);
				    AttachObjectToPlayer(Prop[playerid], playerid ,ox,oy,oz,orx,ory,orz);

				}
uncompiled
Reply
#7

And What will be the new created object position?
Reply
#8

Quote:
Originally Posted by (SF)Noobanatior
Посмотреть сообщение
this should add it to everyone else on the server
Код:
Prop[playerid] = CreatePlayerObject(playerid, PropPositions[ii][ModelID], PropPositions[ii][Offset][0], PropPositions[ii][Offset][1], PropPositions[ii][Offset][2], PropPositions[ii][Rot][0], PropPositions[ii][Rot][1], PropPositions[ii][Rot][2]);
                AttachObjectToPlayer(Prop[playerid], playerid , PropPositions[ii][Offset][0], PropPositions[ii][Offset][1], PropPositions[ii][Offset][2], PropPositions[ii][Rot][0], PropPositions[ii][Rot][1], PropPositions[ii][Rot][2]);
                new Float:ox,Float:oy,Float:oz,Float:orx,Float:ory,Float:orz;
				GetObjectPos(Prop[playerid],ox,oy,oz);      //<-----------get pos of first obj
				GetObjectRot(Prop[playerid],orx,ory,orz);   //<-----------get rotation of first obj
				for(new i = 0; i < MAX_PLAYERS; i++){
				    if(!IsPlayerConnected(i))continue;
				    if(i == playerid)continue;
				    Prop[i] = CreatePlayerObject(i, PropPositions[ii][ModelID], ox,oy,oz,orx,ory,orz);  //<create object for all other players where 1st obj was
				    AttachObjectToPlayer(Prop[playerid], playerid ,ox,oy,oz,orx,ory,orz);               //<-----fix that object to the orignal player for the new player

				}
uncompiled
should be attached to the same player that had it but displayed for the other players on the server
Reply
#9

Oh attached, I don't want to attach it. I want to CreatePlayerObject ( For every other player) and then update it position to (Get the position of AttachedObject) .
Reply
#10

Bump? :S
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)