08.06.2014, 23:55
Hello fellow scripters,
I've posted in the past about these two functions and that topic had views enough but no reply at all, the issues are more simple now but I still know most of the people won't even take effort to read all and possibly help me. Anyhow, if you (attempt to) help me it will be much appreciated!
To start with, I have two screenshots here, click them to get linked to the original (bigger) image!
As you can see in both screenshots the 'USAGE' line says the last two values are TColor (Text Color) and BColor (Background Color), TColor is white and BColor should be transparant (Alpha is 00), I know in the past it worked (I started working on this today after a long time again) but now the code is fucking up the colors (As you can see, the background is yellow instead of transparant, here's the code:
If anyone could tell me/explain to me what's causing the hex values to fuck up you would really help me because I have no clue!
Second issue is, as you can see in the first image I put the object just so the bonnet wouldn't penetrate the object but when I press the save icon to finish object editting it seems it puts it down a little bit as you can see in the second image. I thought to remember the fX, fY, fZ, fRotX, fRotY and fRotZ from OnPlayerEditObject are from the last adjustment you did so would put it a step back so as you can see in the code underneath I already put GetObjectPos & GetObjectRot in there.
And yes I have debugged everything and the 'vehicleid', the 'slot' and everything is perfectly fine, if someone could also explain to me why the object position is bugging I would be really happy because this 'bug' has been irritating me like crazy!
Best regards,
Jesse
I've posted in the past about these two functions and that topic had views enough but no reply at all, the issues are more simple now but I still know most of the people won't even take effort to read all and possibly help me. Anyhow, if you (attempt to) help me it will be much appreciated!
To start with, I have two screenshots here, click them to get linked to the original (bigger) image!
As you can see in both screenshots the 'USAGE' line says the last two values are TColor (Text Color) and BColor (Background Color), TColor is white and BColor should be transparant (Alpha is 00), I know in the past it worked (I started working on this today after a long time again) but now the code is fucking up the colors (As you can see, the background is yellow instead of transparant, here's the code:
pawn Код:
new vehicleid, set[10], model, tekst[128], res, fsize, side[10], textcolor, backcolor;
if(!sscanf(params, "ds[10]s[10]ds[128]ddhh", vehicleid, set, side, model, tekst, res, fsize, textcolor, backcolor))
Second issue is, as you can see in the first image I put the object just so the bonnet wouldn't penetrate the object but when I press the save icon to finish object editting it seems it puts it down a little bit as you can see in the second image. I thought to remember the fX, fY, fZ, fRotX, fRotY and fRotZ from OnPlayerEditObject are from the last adjustment you did so would put it a step back so as you can see in the code underneath I already put GetObjectPos & GetObjectRot in there.
pawn Код:
if(response == EDIT_RESPONSE_FINAL)
{
if(GetPVarInt(playerid, "vTextSlot") > 0)
{
new Float:vR, vehicleid = GetPVarInt(playerid, "vTextID"), slot = (GetPVarInt(playerid, "vTextSlot")-1);
GetObjectPos(vText[vehicleid][slot][Object], fX, fY, fZ);
GetObjectRot(vText[vehicleid][slot][Object], fRotX, fRotY, fRotZ);
OffsetFromVehiclePosition(vehicleid, fX, fY, fZ, vText[vehicleid][slot][tX], vText[vehicleid][slot][tY], vText[vehicleid][slot][tZ]);
GetVehicleZAngle(vehicleid, vR);
vText[vehicleid][slot][tRX] = fRotX;
vText[vehicleid][slot][tRY] = fRotY;
vText[vehicleid][slot][tRZ] = (fRotZ-vR);
vText[vehicleid][slot][Set] = 1;
AttachObjectToVehicle(vText[vehicleid][slot][Object], vehicleid, vText[vehicleid][slot][tX], vText[vehicleid][slot][tY], vText[vehicleid][slot][tZ], vText[vehicleid][slot][tRX], vText[vehicleid][slot][tRY], vText[vehicleid][slot][tRZ]);
vText[vehicleid][slot][Created] = 1;
SetPVarInt(playerid, "vTextSlot", 0);
if(GetPVarInt(playerid, "vTextEdit")) SetPVarInt(playerid, "vTextEdit", 0);
return 1;
}
}
// OffsetFromVehiclePosition & Det3x3 functions, both not made by me.
stock Float: Det3x3({ Float, _ }: mat[][])
{
return (mat[0][0] * mat[1][1] * mat[2][2] + mat[0][1] * mat[1][2] * mat[2][0] + mat[0][2] * mat[1][0] * mat[2][1]) -
(mat[2][0] * mat[1][1] * mat[0][2] + mat[2][1] * mat[1][2] * mat[0][0] + mat[2][2] * mat[1][0] * mat[0][1]);
}
stock OffsetFromVehiclePosition(vehicle, Float: x, Float: y, Float: z, & Float: offX, & Float: offY, & Float: offZ)
{
new Mat4x3[MatrixParts][MatrixIndicator];
GetVehicleMatrix(vehicle, Mat4x3);
x -= Mat4x3[mp_POS][mi_X];
y -= Mat4x3[mp_POS][mi_Y];
z -= Mat4x3[mp_POS][mi_Z];
#if 1
new Float: Mat3x3_1[3][3], Float: Mat3x3_2[3][3], Float: Mat3x3_3[3][3];
Mat3x3_1[0][0] = Mat4x3[mp_PITCH][mi_X];
Mat3x3_1[1][0] = Mat4x3[mp_PITCH][mi_Y];
Mat3x3_1[2][0] = Mat4x3[mp_PITCH][mi_Z];
Mat3x3_1[0][1] = Mat4x3[mp_ROLL][mi_X];
Mat3x3_1[1][1] = Mat4x3[mp_ROLL][mi_Y];
Mat3x3_1[2][1] = Mat4x3[mp_ROLL][mi_Z];
Mat3x3_1[0][2] = Mat4x3[mp_YAW][mi_X];
Mat3x3_1[1][2] = Mat4x3[mp_YAW][mi_Y];
Mat3x3_1[2][2] = Mat4x3[mp_YAW][mi_Z];
offZ = Det3x3(Mat3x3_1);
if(offZ != 0.0)
{
Mat3x3_2 = Mat3x3_1;
Mat3x3_3 = Mat3x3_1;
Mat3x3_1[0][0] = Mat3x3_2[0][1] = Mat3x3_3[0][2] = x;
Mat3x3_1[1][0] = Mat3x3_2[1][1] = Mat3x3_3[1][2] = y;
Mat3x3_1[2][0] = Mat3x3_2[2][1] = Mat3x3_3[2][2] = z;
offX = Det3x3(Mat3x3_1) / offZ;
offY = Det3x3(Mat3x3_2) / offZ;
offZ = Det3x3(Mat3x3_3) / offZ;
}
#else
new Float: pX = Mat4x3[mp_PITCH][mi_X], Float: pY = Mat4x3[mp_PITCH][mi_Y], Float: pZ = Mat4x3[mp_PITCH][mi_Z],
Float: rX = Mat4x3[mp_ROLL][mi_X], Float: rY = Mat4x3[mp_ROLL][mi_Y], Float: rZ = Mat4x3[mp_ROLL][mi_Z],
Float: yX = Mat4x3[mp_YAW][mi_X], Float: yY = Mat4x3[mp_YAW][mi_Y], Float: yZ = Mat4x3[mp_YAW][mi_Z];
offZ = ((z * pX - pZ * x) * rX - (rZ * pX - pZ * rX) * x) / ((yZ * pX - pZ * yX) * rX - (rZ * pX - pZ * rX) * yX);
offY = (y * pX - pY * x - offZ * (yY * pX - pY * yX)) / (rY * pX - pY * rX);
offX = (x - offZ * yX - offY * rX) / pX;
#endif
}
Best regards,
Jesse