Placing an object in front of pickup -
PaulDinam - 27.02.2013
I made a dynamic food stand, but I can't figure out how to place the pickup and the textdraw in front of the food stall
Here is my code:
After editing the dynamic object:
pawn Код:
if(response == EDIT_RESPONSE_FINAL)
{
DestroyDynamic3DTextLabel(Text3D:FoodStand[GetIntVar(playerid, "FoodStandEditing")][fLabel]);
DestroyDynamicPickup(FoodStand[GetIntVar(playerid, "FoodStandEditing")][fPickUp]);
SetDynamicObjectPos(objectid, x, y, z);
SetDynamicObjectRot(objectid, rx, ry, rz);
x += (2.0 * floatsin(-rz, degrees));
y -= (1.0 * floatcos(-rz, degrees));
format(str, sizeof(str), ""EMBED_RED"["EMBED_WHITE"Food Stand - %d"EMBED_RED"]\n"EMBED_GRAY"%s\nPrice - %d.", GetIntVar(playerid, "FoodStandEditing"), FoodStand[GetIntVar(playerid, "FoodStandEditing")][fInfo], FoodStand[GetIntVar(playerid, "FoodStandEditing")][fFoodPrice]);
FoodStand[GetIntVar(playerid, "FoodStandEditing")][fLabel] = CreateDynamic3DTextLabel(str, -1, x, y, z, 5.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
FoodStand[GetIntVar(playerid, "FoodStandEditing")][fPickUp] = CreateDynamicPickup(1239, 1, x, y, z, -1, -1, -1, 100.0);
format(str, sizeof(str), "{FF8000}[SERVER]{FFFFFF}: Finished editing a dynamic object: Position, %f, %f, %f.", x, y, z);
SCM(playerid, -1, str);
SaveEditedFoodStand(GetIntVar(playerid, "FoodStandEditing"), x, y, z, rx, ry, rz);
RemoveVar(playerid, "EditingFoodStand");
RemoveVar(playerid, "FoodStandEditing");
}
Picture how it's done after editing:
Re: Placing an object in front of pickup -
[MG]Dimi - 27.02.2013
I also had that problem. Thing is referring to Trigonometric Circle 0 degrees are on left and in SA-MP 0 degrees in when facing south.
SO something that should work is:
pawn Код:
x += (2.0 * floatsin((-rz-90), degrees));
y -= (1.0 * floatcos((-rz-90), degrees));
If it doesn't work, try with +90.
Re: Placing an object in front of pickup -
PaulDinam - 27.02.2013
I changed to +90 and made some changes, now it works perfectly
if the RZ is like lower than -70 or more than 80
the Y has to be changed.
pawn Код:
if(rz > 80.0 || rz < -70.0)
{
y += (1.5 * floatcos((-rz+90), degrees));
}
else
{
x += (1.5 * floatsin((-rz+90), degrees));
}