Edit attached vehicle object.
#1

Hey. I'm trying to edit an attached vehicle object. But I couldn't.

pawn Код:
CMD:vo(playerid,params[])
{
    new Float:x,Float:y,Float:z, model;
    GetVehiclePos(GetPlayerVehicleID(playerid),x,y,z);
    if(sscanf(params,"i",model)) return SendClientMessage(playerid,-1,"no");
    obj = CreateObject(model,x,y,z,0,0,0,100);
    AttachObjectToVehicle(obj,GetPlayerVehicleID(playerid),x,y,z,0,0,0);
    EditObject(playerid,obj);
    return 1;
}
I can see the GUI and mouse cursor, but I can't move or rotate it. Does anyone know how to edit an attached vehicle object?

Oh and, can anyone solve this problem?
https://sampforum.blast.hk/showthread.php?tid=423580&page=2
Reply
#2

Just use SetObjectPos instead of AttachObjectToVehicle, and after you're done editing, simply subtract the vehicle's position from the object's position and you get the offsets.
Reply
#3

Quote:
Originally Posted by YJIET
Посмотреть сообщение
Just use SetObjectPos instead of AttachObjectToVehicle,
Then how am I supposed to attach the object to vehicle if I don't use AttachObjectToVehicle?
Reply
#4

Quote:
Originally Posted by newbienoob
Посмотреть сообщение
Then how am I supposed to attach the object to vehicle if I don't use AttachObjectToVehicle?
By using the offsets?

EDIT: It looks like you're misusing the function anyway.
Reply
#5

What? Sorry, I don't understand. Can you show me an example?
Reply
#6

Basically, he's saying that you can create the object, edit the object and put this code underneath OnPlayerEditObject. In the code below, it basically takes the XYZ position of the object and subtracts the vehicle's position FROM the object's coordinates.

I didn't even know that was possible until I saw this... the only issue with the code below is that it doesn't set the proper rotation when attaching the object to the vehicle. I'm not sure how I'd accomplish that.

pawn Код:
new
            Float:fPos[3]
        ;
       
        GetVehiclePos(GetPlayerVehicleID(playerid), fPos[0], fPos[1], fPos[2]);    
        printf("\n\nOBJECT OFFSETS: %f, %f, %f, %f, %f, %f\n\n", x-fPos[0], y-fPos[1], z-fPos[2], rx, ry, rz);
       
        AttachDynamicObjectToVehicle(objectid, GetPlayerVehicleID(playerid), x-fPos[0], y-fPos[1], z-fPos[2], rx, ry, rz);
Reply
#7

I think the vehicle needs to be facing north the get the correct rotation offsets.
Reply
#8

If you're facing East, West, SE, or SW, this code seems to work just fine. It's only when you're facing North/South that it won't work properly. I'm working on a fix, though!

pawn Код:
if(response == EDIT_RESPONSE_FINAL)
    {
        new
            Float:fPos[6],
            Float:temp
        ;
       
        GetVehiclePos(GetPlayerVehicleID(playerid), fPos[0], fPos[1], fPos[2]);
        GetVehicleRotationQuat(GetPlayerVehicleID(playerid), temp, fPos[3], fPos[4], fPos[5]);
        printf("\n\nOBJECT OFFSETS: %f, %f, %f, %f, %f, %f\n\n", x-fPos[0], y-fPos[1], z-fPos[2], fPos[3], fPos[4], fPos[5]);
       
        AttachDynamicObjectToVehicle(objectid, GetPlayerVehicleID(playerid), x-fPos[0], y-fPos[1], z-fPos[2], fPos[3], fPos[4], fPos[5]);      
        SendClientMessage(playerid, COLOR_GREEN, "Results printed to server log.");
    }
Reply
#9

Hmm.. so I need to;
- Create object
- Edit object
#OnPlayerEdit(Dynamic)Object (EDIT_RESPONSE_FINAL)
- Attach it to vehicle.

?
Reply
#10

Yes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)