PDA

View Full Version : Placing an object in front of pickup


PaulDinam
27/02/2013, 10:02 AM
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:


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:

http://i56.tinypic.com/166m4vq.png

[MG]Dimi
27/02/2013, 10:09 AM
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:

x += (2.0 * floatsin((-rz-90), degrees));
y -= (1.0 * floatcos((-rz-90), degrees));

If it doesn't work, try with +90.

PaulDinam
27/02/2013, 10:24 AM
I changed to +90 and made some changes, now it works perfectly :D
if the RZ is like lower than -70 or more than 80
the Y has to be changed.


if(rz > 80.0 || rz < -70.0)
{
y += (1.5 * floatcos((-rz+90), degrees));
}
else
{
x += (1.5 * floatsin((-rz+90), degrees));
}