Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CMD:objedit(playerid,params[])
- {
- new engine, lights, alarm, doors, bonnet, boot, objective;
- GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
- SetVehicleParamsEx(GetPlayerVehicleID(playerid), VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
- EditObj = CreateObject(1000, 2044.7817,1338.6364,12.1922,0,0,0);
- EditObject(playerid,EditObj);
- return 1;
- }
- public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
- {
- if(response == EDIT_RESPONSE_FINAL)
- {
- DestroyObject(EditObj);
- EditObj = CreateObject(1000, fX, fY, fZ, fRotX, fRotY, fRotZ);
- ReattachObject(EditObj,GetPlayerVehicleID(playerid));
- }
- return 1;
- }
- stock ReattachObject(objId, veh) //Reattachs the object to a vehicle
- {
- new Float:q[4];
- GetVehicleRotationQuat(veh, q[0], q[1], q[2], q[3]);
- if(!IsValidQuaternion(q)) return INVALID_VEHICLE_ID;
- new Float:a[3], Float:ar[3];
- GetObjectPos(objId, a[0], a[1], a[2]);
- GetObjectRot(objId, ar[0], ar[1], ar[2]);
- new Float:x, Float:y, Float:z;
- GetVehiclePos(veh, x, y, z);
- a[0] -= x;
- a[1] -= y;
- a[2] -= z;
- VectorAbsToRelQuat(q, a, a); //a is now a vehicle-relative vector
- RotationAbsToRelQuat(q, ar, ar); //a is now a vehicle-relative rotation
- AttachObjectToVehicle(objId, veh, a[0], a[1], a[2], ar[0], ar[1], ar[2]);
- printf("Attach Successful");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment