EditObject, AttachObjectToVehicle
#1

Hello, I have a little problem, I can't resolove it, 2days non-stop trying everything, I'm not so good at math with sin/cos, so maybe... someone has solution for this? I searched all over the forum, ******... and no results, I found only script who wasn't finished, it only works perfect with X, Y, Z, RX, RY, RZ cord when vehicle rotation(RX, RY) is 0.0000. When vehicle rotation is not 0.00000, then it starts bugging, I'm 100% sure, that fRotX, fRotY needs to create with floatsin/floatcos functions, but how?

My code example:

Код:
CMD:object(playerid, params[])
{
	if(PlayerLogged[playerid] == 0) return 1;
	if(!IsPlayerInAnyVehicle(playerid)) return 1;

	new Float:x, Float:y, Float:z;
	GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
	new objectid = CreateObject(2706, x, y, z, 0.0, 0.0, 0.0);
	EditObject(playerid, objectid);
}

public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
    if(response == EDIT_RESPONSE_FINAL)
    {
		new Float:vX, Float:vY, Float:vZ, Float:vRX, Float:vRY, Float:vRZ, Float:oX, Float:oY, Float:oZ, Float:oRZ, Float:oAX, Float:oAY;
		GetVehiclePos(GetPlayerVehicleID(playerid), vX, vY, vZ);
		GetVehicleRotation(GetPlayerVehicleID(playerid),vRX,vRY,vRZ);	
			
		oX = fX-px;
		oY = fY-py;
		oZ = fZ-pz;
		oRZ = fRotZ-vRZ;
		oAX = oX*floatcos(vRZ, degrees)+oY*floatsin(vRZ, degrees);
		oAY = -oX*floatsin(vRZ, degrees)+oY*floatcos(vRZ, degrees);	
		AttachObjectToVehicle(objectid, GetPlayerVehicleID(playerid), oAX, oAY, oZ, fRotX, fRotY, oRZ);
    }
	
    if(response == EDIT_RESPONSE_CANCEL)
    {
		DestroyObject(objectid);
		SendClientMessage(playerid, COLOR_LIGHTRED, "Canceled!");
    }
}
Reply
#2

The vehicles needs to be always facing north 0.0 and should be on flat ground. You also need to use a editobject then translate your edit to another object. Look through here.

https://github.com/Pottus/Texture-St...o/vehicles.pwn
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)