Guest User

Untitled

a guest
Jun 5th, 2016
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. CMD:objedit(playerid,params[])
  2. {
  3. new engine, lights, alarm, doors, bonnet, boot, objective;
  4. GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
  5. SetVehicleParamsEx(GetPlayerVehicleID(playerid), VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
  6. EditObj = CreateObject(1000, 2044.7817,1338.6364,12.1922,0,0,0);
  7. EditObject(playerid,EditObj);
  8. return 1;
  9. }
  10.  
  11. public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
  12. {
  13. if(response == EDIT_RESPONSE_FINAL)
  14. {
  15. DestroyObject(EditObj);
  16. EditObj = CreateObject(1000, fX, fY, fZ, fRotX, fRotY, fRotZ);
  17. ReattachObject(EditObj,GetPlayerVehicleID(playerid));
  18. }
  19. return 1;
  20. }
  21.  
  22. stock ReattachObject(objId, veh) //Reattachs the object to a vehicle
  23. {
  24. new Float:q[4];
  25. GetVehicleRotationQuat(veh, q[0], q[1], q[2], q[3]);
  26. if(!IsValidQuaternion(q)) return INVALID_VEHICLE_ID;
  27.  
  28. new Float:a[3], Float:ar[3];
  29. GetObjectPos(objId, a[0], a[1], a[2]);
  30. GetObjectRot(objId, ar[0], ar[1], ar[2]);
  31.  
  32. new Float:x, Float:y, Float:z;
  33. GetVehiclePos(veh, x, y, z);
  34. a[0] -= x;
  35. a[1] -= y;
  36. a[2] -= z;
  37.  
  38. VectorAbsToRelQuat(q, a, a); //a is now a vehicle-relative vector
  39. RotationAbsToRelQuat(q, ar, ar); //a is now a vehicle-relative rotation
  40.  
  41. AttachObjectToVehicle(objId, veh, a[0], a[1], a[2], ar[0], ar[1], ar[2]);
  42. printf("Attach Successful");
  43. return 1;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment