stock GetPlayerCameraObject(playerid)return Streamer_GetItemStreamerID(playerid, STREAMER_TYPE_OBJECT, GetPlayerCameraTargetObject(playerid));
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;
}
}
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 |
stock GetPlayerCameraObject(playerid)return Streamer_GetItemStreamerID(playerid, STREAMER_TYPE_OBJECT, GetPlayerCameraTargetObject(playerid));
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; }
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; } |
15065, tljoels_backpack, tljoels_backpack, 299, 0