Thread: [Plugin] Streamer Plugin
View Single Post
Old 07/05/2017, 03:55 PM   #5622
IstuntmanI's Avatar
Join Date: Mar 2009
Location: Romania
Posts: 1,862
Reputation: 373
Default Re: Streamer Plugin

Originally Posted by AbyssMorgan View Post
E_STREAMER_EXTRA_ID is integer not array
E_STREAMER_EXTRA_ID internally is a "std::vector< int >" . So, technically, it is an array (1D/vector, of integers), not an integer, but it can be used as both because Incognito added the possibility to use it with the natives manipulating just an integer (Streamer_SetIntData and Streamer_GetIntData) by actually setting/getting only the first value in that vector of extra integers (you can check getFirstValueInContainer and setFirstValueInContainer in the source code).


Originally Posted by Riddick94 View Post
Ok, so here's my try to help you. In your first post you didn't post everything. The first "if" line and the whole code block looks ok ( you are even checking first if it is valid, but this means that PlayerData[playerid][E_PLAYER_LOOKING_AT_ITEMID] will NEVER be set to INVALID_OBJECT_ID (actually, it would be 0, because Streamer_GetItemStreamerID returns 0 if it isn't a dynamic object ID, here is your error: invalid default ID set) there because lookingat_objectid is not a "ValidDynamicObject" [ in the "if" check before checking for PlayerData[playerid][E_PLAYER_LOOKING_AT_ITEMID] ] ), which means that the problem is from the second block of code ("else"), which is called if he isn't looking at any dynamic object.
Did you set PlayerData[playerid][E_PLAYER_LOOKING_AT_ITEMID] to INVALID_OBJECT_ID when the player connects ? If it isn't INVALID_OBJECT_ID (0xFFFF/65535) that check will be true which means that it will go to this ( assuming that variable is set to 0 (or, well, any other invalid dynamic object ID, if not set as INVALID_OBJECT_ID) ):
PHP Code:

hence your warnings, exactly in that order:
*** Streamer Plugin: Streamer_GetArrayData: Invalid ID specified.
*** Streamer Plugin: Streamer_IsInArrayData: Invalid ID specified.
By the way, INVALID_OBJECT_ID is actually a really valid object ID in Streamer Plugin (Dynamic Object ID 65535), so you'd better initialize it with 0 (or INVALID_STREAMER_ID), as object IDs are starting from 1, just in case. Also, you should really use the latest Streamer Plugin, in v2.9.0 the function GetPlayerCameraTargetDynObject was added, which returns 0 (INVALID_STREAMER_ID) when he isn't targeting any dynamic object.

To simply check if my theory is correct, you should add IsValidDynamicObject(PlayerData[playerid][E_PLAYER_LOOKING_AT_ITEMID]) after the first check:
if(PlayerData[playerid][E_PLAYER_LOOKING_AT_ITEMID] != INVALID_OBJECT_ID && IsValidDynamicObject(PlayerData[playerid][E_PLAYER_LOOKING_AT_ITEMID]))
I don't see anything else which could cause that in the code you posted, so this should really be the problem. Always keep in mind the possible functions return values. Sorry if you didn't understand, but I think that I explained as much as possible (maybe too much, so this might rise problems in understanding what I said xD).


When requesting help you have post the whole code blocks, not only just a part, maybe the problem isn't really from where you think it is from, just like in this case.

IstuntmanI is offline   Reply With Quote