I can not edit the car's object
#1

Hello, I need some help, I'm using a system to attach objects to cars that someone contributed here, which, only has two commands, add object (adapt it) and delete it, I wanted to make a command to edit object, but when trying to move the object, it blocks, that is, a red box appears in the edition and does not allow me to move it or anything, here I leave the code, I hope you can help me

This cmd is for attach object to car
Код:
CMD:atar(playerid, params[])
{
        new objectmodel, car;
        if(sscanf(params, "ii", objectmodel, car))
        {
                SendClientMessage(playerid, -1, "Modo de uso: /atar [id de objeto] [id de vehнculo]");
                return 1;
        }
        if(0 < car < MAX_VEHICLES)
        {
                new Float:px, Float:py, Float:pz;
                GetPlayerPos(playerid, px, py, pz);
                AttachingObjects[playerid] = CreateObject(objectmodel, px, py, pz, 0.0, 0.0, 0.0);
                SendClientMessage(playerid, -1, "Objeto aсadido, ahora procede a editarlo.");
                EditObject(playerid, AttachingObjects[playerid]); // empezar a editar objeto
                SetPVarInt(playerid, "AttachingTo", car); // dar permiso para empezar a editar
        }
        else
        {
                SendClientMessage(playerid, -1, "Vehнculo ID invбlido.");
        }
        return 1;
}
This is the code to "edit" that I made

Код:
CMD:ev(playerid, params[]){
        new objeto, autoseditar;
        if(sscanf(params, "ii", objeto, autoseditar))
        {
                SendClientMessage(playerid, -1, "Modo de uso: /ev [ID DE SLOT] [ID DE VEHНCULO]");
                return 1;
        }
        if(0 <= objeto < 20)
        {
                if(0 < autoseditar < MAX_VEHICLES)
                {
                        if(!IsValidObject(AttachedObjects[autoseditar][objeto]))
                        {
                                SendClientMessage(playerid, -1, "No hay objetos en esa ID.");
                                return 1;
                        }
                        EditObject(playerid, AttachedObjects[autoseditar][objeto]);
		        SetPVarInt(playerid, "AttachingTo", autoseditar); 
                        SendClientMessage(playerid, -1, "Ahora estбs editando la posiciуn del objeto.");
                        return 1;
                }
                else
                {
                        SendClientMessage(playerid, -1, "Vehнculo invбlido.");
                }
        }
        else
        {
                SendClientMessage(playerid, -1, "No hay objetos en esa posiciуn.");
        }
        return 1;
}
Aquн la variable "AttachingTo"

Код:
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 car = GetPVarInt(playerid, "AttachingTo");
        if(car != 0)
        {
                		if(response == EDIT_RESPONSE_FINAL)
                		{
                        SendClientMessage(playerid, -1, "Ediciуn finalizada. Recuerda que el objeto no debe estar en una posiciуn irreal.");
                        new carslot = FindFreeObjectSlotInCar(car);
                        if(carslot == -1)
                        {
                                SendClientMessage(playerid, -1, "No se pueden aсadir mбs objetos al auto. Mбximo: 10.");
                                DestroyObject(AttachingObjects[playerid]);
                                DeletePVar(playerid, "AttachingTo");
                                return 1;
                        }
                        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);
                        AttachedObjects[car][carslot] = AttachingObjects[playerid];
                        format(strout, sizeof(strout), "Objeto creado en el slot: %d del vehнculo ID: %d", carslot, car);
                        SendClientMessage(playerid, -1, strout);
                        DeletePVar(playerid, "AttachingTo");
                        return 1;
                		}
		                if(response == EDIT_RESPONSE_CANCEL)
		                {
               			DestroyObject(AttachingObjects[playerid]);
                  		DeletePVar(playerid, "AttachingTo");
                    	return 1;
		                }
        }
        return 1;
}
I wish they could help me, thank you very much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)