Advertisement
Guest User

Untitled

a guest
Dec 10th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1. new AttachingObjects[MAX_PLAYERS];
  2. new AttachedObjects[MAX_VEHICLES][MAX_OBJ_PER_VEHICLE];
  3.  
  4. #define MAX_OBJ_PER_VEHICLE 6
  5.  
  6. public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
  7. {
  8. if(!IsValidObject(objectid)) return 0;
  9. MoveObject(objectid, fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ);
  10. new strout[150];
  11.  
  12.  
  13. new car = GetPVarInt(playerid, "CarToyando");
  14. if(car != 0)
  15. {
  16. if(response == EDIT_RESPONSE_FINAL)
  17. {
  18. SendClientMessage(playerid, 0xfce80cFF, "Edición de objeto finalziada.");
  19. new carslot = FindFreeObjectSlotInCar(car); //Encuentra un slot automáticamente.
  20. new vehicleid = GetPlayerVehicleID(playerid);
  21. if(carslot == -1)
  22. {
  23. SendClientMessage(playerid, 0xfce80cFF, "No hay slots disponibles para crear objetos.");
  24. DestroyObject(AttachingObjects[playerid]);
  25. DeletePVar(playerid, "CarToyando");
  26. return 1;
  27. }
  28. // new vehicleid = GetPlayerVehicleID(playerid);
  29. new Float:ofx, Float:ofy, Float:ofz, Float:ofaz;
  30. new Float:finalx, Float:finaly;
  31. new Float:px, Float:py, Float:pz, Float:roz;
  32. GetVehiclePos(car, px, py, pz);
  33. GetVehicleZAngle(car, roz);
  34. ofx = fX-px;
  35. ofy = fY-py;
  36. ofz = fZ-pz;
  37. ofaz = fRotZ-roz;
  38. finalx = ofx*floatcos(roz, degrees)+ofy*floatsin(roz, degrees);
  39. finaly = -ofx*floatsin(roz, degrees)+ofy*floatcos(roz, degrees);
  40. AttachObjectToVehicle(AttachingObjects[playerid], car, finalx, finaly, ofz, fRotX, fRotY, ofaz);
  41. InfoVehiculo[vehicleid][carToy][carslot] = AttachingObjects[playerid];
  42. InfoVehiculo[vehicleid][TCT1X][carslot] = finalx;
  43. InfoVehiculo[vehicleid][TCT1Y][carslot] = finaly;
  44. InfoVehiculo[vehicleid][TCT1Z][carslot] = ofz;
  45. InfoVehiculo[vehicleid][TCTRX][carslot] = fRotX;
  46. InfoVehiculo[vehicleid][TCTRY][carslot] = fRotY;
  47. InfoVehiculo[vehicleid][TCTRZ][carslot] = ofaz;
  48. AttachedObjects[car][carslot] = AttachingObjects[playerid];
  49. format(strout, sizeof(strout), "Se creó un objeto en el slot %d del vehículo id %d", carslot, car);
  50. SendClientMessage(playerid, 0xfce80cFF, strout);
  51. DeletePVar(playerid, "CarToyando");
  52. return 1;
  53. }
  54. if(response == EDIT_RESPONSE_CANCEL)
  55. {
  56. DestroyObject(AttachingObjects[playerid]);
  57. DeletePVar(playerid, "CarToyando");
  58. return 1;
  59. }
  60. }
  61. return 0;
  62. }
  63.  
  64. CMD:ponertoy(playerid,params[]){
  65. new modelid;
  66. new vehicleid = GetPlayerVehicleID(playerid);
  67. if (sscanf(params, "d", modelid)) return _Mensaje(playerid, 3, "0", "/ponertoy [id toy]");
  68. new Float:px, Float:py, Float:pz;
  69. GetPlayerPos(playerid, px, py, pz);
  70. AttachingObjects[playerid] = CreateObject(modelid, px, py, pz, 0.0, 0.0, 0.0);
  71. EditObject(playerid, AttachingObjects[playerid]);
  72. SetPVarInt(playerid, "CarToyando", vehicleid);
  73. return 1;
  74. }
  75.  
  76. stock FindFreeObjectSlotInCar(vehid)
  77. {
  78. for(new i=0; i<MAX_OBJ_PER_VEHICLE; i++)
  79. {
  80. if(!IsValidObject(AttachedObjects[vehid][i])) return i;
  81. }
  82. return -1;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement