Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new AttachingObjects[MAX_PLAYERS];
- new AttachedObjects[MAX_VEHICLES][MAX_OBJ_PER_VEHICLE];
- #define MAX_OBJ_PER_VEHICLE 6
- public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
- {
- if(!IsValidObject(objectid)) return 0;
- MoveObject(objectid, fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ);
- new strout[150];
- new car = GetPVarInt(playerid, "CarToyando");
- if(car != 0)
- {
- if(response == EDIT_RESPONSE_FINAL)
- {
- SendClientMessage(playerid, 0xfce80cFF, "Edición de objeto finalziada.");
- new carslot = FindFreeObjectSlotInCar(car); //Encuentra un slot automáticamente.
- new vehicleid = GetPlayerVehicleID(playerid);
- if(carslot == -1)
- {
- SendClientMessage(playerid, 0xfce80cFF, "No hay slots disponibles para crear objetos.");
- DestroyObject(AttachingObjects[playerid]);
- DeletePVar(playerid, "CarToyando");
- return 1;
- }
- // new vehicleid = GetPlayerVehicleID(playerid);
- new Float:ofx, Float:ofy, Float:ofz, Float:ofaz;
- new Float:finalx, Float:finaly;
- new Float:px, Float:py, Float:pz, Float:roz;
- GetVehiclePos(car, px, py, pz);
- GetVehicleZAngle(car, roz);
- ofx = fX-px;
- ofy = fY-py;
- ofz = fZ-pz;
- ofaz = fRotZ-roz;
- finalx = ofx*floatcos(roz, degrees)+ofy*floatsin(roz, degrees);
- finaly = -ofx*floatsin(roz, degrees)+ofy*floatcos(roz, degrees);
- AttachObjectToVehicle(AttachingObjects[playerid], car, finalx, finaly, ofz, fRotX, fRotY, ofaz);
- InfoVehiculo[vehicleid][carToy][carslot] = AttachingObjects[playerid];
- InfoVehiculo[vehicleid][TCT1X][carslot] = finalx;
- InfoVehiculo[vehicleid][TCT1Y][carslot] = finaly;
- InfoVehiculo[vehicleid][TCT1Z][carslot] = ofz;
- InfoVehiculo[vehicleid][TCTRX][carslot] = fRotX;
- InfoVehiculo[vehicleid][TCTRY][carslot] = fRotY;
- InfoVehiculo[vehicleid][TCTRZ][carslot] = ofaz;
- AttachedObjects[car][carslot] = AttachingObjects[playerid];
- format(strout, sizeof(strout), "Se creó un objeto en el slot %d del vehículo id %d", carslot, car);
- SendClientMessage(playerid, 0xfce80cFF, strout);
- DeletePVar(playerid, "CarToyando");
- return 1;
- }
- if(response == EDIT_RESPONSE_CANCEL)
- {
- DestroyObject(AttachingObjects[playerid]);
- DeletePVar(playerid, "CarToyando");
- return 1;
- }
- }
- return 0;
- }
- CMD:ponertoy(playerid,params[]){
- new modelid;
- new vehicleid = GetPlayerVehicleID(playerid);
- if (sscanf(params, "d", modelid)) return _Mensaje(playerid, 3, "0", "/ponertoy [id toy]");
- new Float:px, Float:py, Float:pz;
- GetPlayerPos(playerid, px, py, pz);
- AttachingObjects[playerid] = CreateObject(modelid, px, py, pz, 0.0, 0.0, 0.0);
- EditObject(playerid, AttachingObjects[playerid]);
- SetPVarInt(playerid, "CarToyando", vehicleid);
- return 1;
- }
- stock FindFreeObjectSlotInCar(vehid)
- {
- for(new i=0; i<MAX_OBJ_PER_VEHICLE; i++)
- {
- if(!IsValidObject(AttachedObjects[vehid][i])) return i;
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement