Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Look-at functionality

$
0
0
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:
Code:

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:
Code:

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;
                }
        }


Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>