If you aim sniper rifle, RPG, heat seeker or camera, all of your attached objects will be shown in the center of the screen. It is GTA:SA bug and afaik it cannot be 'cleanly' fixed scriptwise. But there are a lot of workarounds. I had made this when playing with objects:
new aobjects[MAX_PLAYERS][MAX_PLAYER_ATTACHED_OBJECTS][4];
new Float: aobjects_floats[MAX_PLAYERS][MAX_PLAYER_ATTACHED_OBJECTS][9];
new bool: scope_objects[MAX_PLAYERS][MAX_PLAYER_ATTACHED_OBJECTS];
SetPlayerAttachedObjectEx(playerid, index, modelid, bone, Float: fOffsetX = 0.0, Float: fOffsetY = 0.0, Float: fOffsetZ = 0.0, Float: fRotX = 0.0,
Float: fRotY = 0.0, Float: fRotZ = 0.0, Float: fScaleX = 1.0, Float: fScaleY = 1.0, Float: fScaleZ = 1.0, materialcolor1 = 0, materialcolor2 = 0) {
aobjects[playerid][index][0] = modelid;
aobjects[playerid][index][1] = bone;
aobjects[playerid][index][2] = materialcolor1;
aobjects[playerid][index][3] = materialcolor2;
aobjects_floats[playerid][index][0] = fOffsetX;
aobjects_floats[playerid][index][1] = fOffsetY;
aobjects_floats[playerid][index][2] = fOffsetZ;
aobjects_floats[playerid][index][3] = fRotX;
aobjects_floats[playerid][index][4] = fRotY;
aobjects_floats[playerid][index][5] = fRotZ;
aobjects_floats[playerid][index][6] = fScaleX;
aobjects_floats[playerid][index][7] = fScaleY;
aobjects_floats[playerid][index][8] = fScaleZ;
SetPlayerAttachedObject(playerid, index, modelid, bone, fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ, fScaleX, fScaleY, fScaleZ, materialcolor1,
materialcolor2);
}
GetPlayerAttachedObjectEx(playerid, index, &modelid, &bone, &Float: fOffsetX, &Float: fOffsetY, &Float: fOffsetZ, &Float: fRotX, &Float: fRotY, &Float: fRotZ,
&Float: fScaleX, &Float: fScaleY, &Float: fScaleZ, &materialcolor1, &materialcolor2) {
modelid = aobjects[playerid][index][0];
bone = aobjects[playerid][index][1];
materialcolor1 = aobjects[playerid][index][2];
materialcolor2 = aobjects[playerid][index][3];
fOffsetX = aobjects_floats[playerid][index][0];
fOffsetY = aobjects_floats[playerid][index][1];
fOffsetZ = aobjects_floats[playerid][index][2];
fRotX = aobjects_floats[playerid][index][3];
fRotY = aobjects_floats[playerid][index][4];
fRotZ = aobjects_floats[playerid][index][5];
fScaleX = aobjects_floats[playerid][index][6];
fScaleY = aobjects_floats[playerid][index][7];
fScaleZ = aobjects_floats[playerid][index][8];
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
if ((newkeys & KEY_HANDBRAKE) ^ (oldkeys & KEY_HANDBRAKE)) {
new index = GetPlayerAnimationIndex(playerid);
new weapon = GetPlayerWeapon(playerid);
// Checking all possible animations while/before shooting. Looks kinda scary, but it doesn't affect performance at all
if (((weapon >= 34 && weapon <= 36) || weapon == 43) && ((index >= 1160 && index <= 1163) || index == 1167 || index == 1365 || index == 1069 ||
index == 1070 || index == 1158 || index == 1159 || index == 1196 || index == 1223 || index == 1183 || index == 1274 || index == 1256 ||
index == 1132 || index == 1133 || index == 1231 || index == 1266 || index == 1188 || index == 1189 || index == 1164 || index == 1188 ||
index == 1246 || index == 1233 || index == 1267)) {
if (newkeys & KEY_HANDBRAKE) {
for (new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++) {
if (IsPlayerAttachedObjectSlotUsed(playerid, i)) {
scope_objects[playerid][i] = true;
RemovePlayerAttachedObject(playerid, i);
}
else scope_objects[playerid][i] = false;
}
}
else {
new modelid, bone, Float: fOffsetX, Float: fOffsetY, Float: fOffsetZ, Float: fRotX, Float: fRotY, Float: fRotZ, Float: fScaleX,
Float: fScaleY, Float: fScaleZ, materialcolor1, materialcolor2;
for (new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++) if (scope_objects[playerid][i] == true) {
GetPlayerAttachedObjectEx(playerid, i, modelid, bone, fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ, fScaleX, fScaleY, fScaleZ,
materialcolor1, materialcolor2);
SetPlayerAttachedObjectEx(playerid, i, modelid, bone, fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ, fScaleX, fScaleY, fScaleZ,
materialcolor1, materialcolor2);
}
}
}
}
}