Look-at functionality
#1

Hello,

Once you create a custom object and insert its data to custom.IDE and model with texture into custom.img - your functionality regarding "looking at" things isn't working.

I can receive positive data when looking at default created model ids from GTA:SA but not my custom created ones.

Function I have used for streamer objects:
pawn Код:
stock GetPlayerCameraObject(playerid)return Streamer_GetItemStreamerID(playerid, STREAMER_TYPE_OBJECT, GetPlayerCameraTargetObject(playerid));
It isn't working on the default SA-MPs function as well (CreateObject)!

Code in my callback timer:
pawn Код:
new objectid = GetPlayerCameraObject(playerid);

    if(IsValidDynamicObject(objectid))
    {
        if(PlayerData[playerid][E_PLAYER_LOOKING_AT_ITEMID] == INVALID_OBJECT_ID)
        {
            new object_data[7];
            Streamer_GetArrayData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, object_data, sizeof(object_data));

            new itemid = object_data[0];
            if(ItemData[itemid][E_ITEM_TYPE] != ITEM_TYPE_NONE)
            {
                printf("Looking at the object of type: %d", ItemData[itemid][E_ITEM_TYPE]);
                if(Streamer_IsInArrayData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, INVALID_3DTEXT_ID))
                {
                    PlayerData[playerid][E_PLAYER_LOOKING_AT_ITEMID] = objectid;

                    object_data[1] = _:CreateDynamic3DTextLabel(ItemData[itemid][E_ITEM_NAME], COLOR_NICK, Float:object_data[2], Float:object_data[3], Float:object_data[4], 2.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, STREAMER_VEHICLE_TYPE_DYNAMIC, false, object_data[5], object_data[6], playerid, 5.0);
                    Streamer_SetArrayData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, object_data, sizeof(object_data));

                    Streamer_Update(playerid, STREAMER_TYPE_3D_TEXT_LABEL);
                }
            }

            else
            {
                SendClientMessagef(playerid, -1, "Looking at the standard object (%d)!", objectid);
            }
        }
    }

    else
    {
        if(PlayerData[playerid][E_PLAYER_LOOKING_AT_ITEMID] != INVALID_OBJECT_ID)
        {
            new object_data[7];
            Streamer_GetArrayData(STREAMER_TYPE_OBJECT, PlayerData[playerid][E_PLAYER_LOOKING_AT_ITEMID], E_STREAMER_EXTRA_ID, object_data, sizeof(object_data));

            if(Streamer_IsInArrayData(STREAMER_TYPE_OBJECT, PlayerData[playerid][E_PLAYER_LOOKING_AT_ITEMID], E_STREAMER_EXTRA_ID, object_data[1]))
            {
                printf("Found created 3DText Label: %d | DESTROYING", object_data[1]);
                DestroyDynamic3DTextLabel(Text3D:object_data[1]);
                Streamer_Update(playerid, STREAMER_TYPE_3D_TEXT_LABEL);

                object_data[1] = INVALID_3DTEXT_ID;
                Streamer_SetArrayData(STREAMER_TYPE_OBJECT, PlayerData[playerid][E_PLAYER_LOOKING_AT_ITEMID], E_STREAMER_EXTRA_ID, object_data, sizeof(object_data));
            }
            PlayerData[playerid][E_PLAYER_LOOKING_AT_ITEMID] = INVALID_OBJECT_ID;
        }
    }
Reply
#2

Did you create a Collision file for your object?
Reply
#3

Quote:
Originally Posted by Gigi-The-Beast
Посмотреть сообщение
Did you create a Collision file for your object?
Collision is there, yes. Does it matter if it's a mesh or normal collision?

edit://
Without collision file I wouldnt' be able to create custom object in game.
Reply
#4

I will try now with my custom objects and let you know if the same thing happens.
Also you could add an empty collision file with the name of object, that is what I meant with "Did you create a Collision file for your object?"

EDIT: also the function is GetPlayerCameraTargetObject, if I am not mistaken?
https://sampwiki.blast.hk/wiki/GetPlayerCameraTargetObject
Reply
#5

Quote:
Originally Posted by Gigi-The-Beast
Посмотреть сообщение
I will try now with my custom objects and let you know if the same thing happens.
Also you could add an empty collision file with the name of object, that is what I meant with "Did you create a Collision file for your object?"

EDIT: also the function is GetPlayerCameraTargetObject, if I am not mistaken?
https://sampwiki.blast.hk/wiki/GetPlayerCameraTargetObject
Yeah, it's right here:
pawn Код:
stock GetPlayerCameraObject(playerid)return Streamer_GetItemStreamerID(playerid, STREAMER_TYPE_OBJECT, GetPlayerCameraTargetObject(playerid));
I will try to play around with collisions soon. Thanks.
Reply
#6

Just to inform you, I've tried now with a custom object with this code:
Код:
CMD:camera(playerid,params[])
{
    EnablePlayerCameraTarget(playerid, 1);
    new objid = GetPlayerCameraTargetObject(playerid);
    
    new string[128];
    format(string,sizeof(string),"ObjID:%d",objid);
    SendClientMessage(playerid,-1,string);
	return 1;
}

CMD:pobjdestroy(playerid,params[])
{
	DestroyPlayerObject(playerid,strval(params));
	SendClientMessage(playerid,-1,"Obj unisten");
	return 1;
}
It returns the ID as it should and the destroy function deletes it, so the ID is correct.
Reply
#7

Quote:
Originally Posted by Gigi-The-Beast
Посмотреть сообщение
Just to inform you, I've tried now with a custom object with this code:
Код:
CMD:camera(playerid,params[])
{
    EnablePlayerCameraTarget(playerid, 1);
    new objid = GetPlayerCameraTargetObject(playerid);
    
    new string[128];
    format(string,sizeof(string),"ObjID:%d",objid);
    SendClientMessage(playerid,-1,string);
	return 1;
}

CMD:pobjdestroy(playerid,params[])
{
	DestroyPlayerObject(playerid,strval(params));
	SendClientMessage(playerid,-1,"Obj unisten");
	return 1;
}
It returns the ID as it should and the destroy function deletes it, so the ID is correct.
Okay hold on. My IDs are starting from:
Код:
15065, tljoels_backpack, tljoels_backpack, 299, 0
Could you also try this? Thanks.
Reply
#8

My objects start from ID 15100 all the way up to 15999, so that shouldn't be an issue.
If you want, I could send you a CUSTOM object, so you can try with it if you want.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)