Ayuda por el amor de dios... bucle...
#1

Buenas a todos, alguien me podria ayudar a solucionar este problema porfavor.

ya he verificado de todo y he encontrado ke el problema esta en la funcion GetObjectPosAndRot e algo con el buble.

me deberia guardar la posicion de los 5 objetos y me guarda la del ultimo objeto osea el ObjectID[4], y al crearlos a los objetos de nuevo con la funcion CreateObjectNEW, actua creandolos en la posicion ya mensionada osea todos juntos.

por favor necesito ayudar con urgencia. :S

pawn Код:
new Float:position[5][3],
    Float:rotation[5][3],
    ObjectID[5];

public OnFilterScriptInit() {
    ObjectID[0]=CreateObject(1697, 306.45633, 1850.32690, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID[1]=CreateObject(1697, 306.50189, 1857.30835, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID[2]=CreateObject(1697, 306.52655, 1864.34985, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID[3]=CreateObject(1697, 306.54568, 1871.73120, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID[4]=CreateObject(1697, 306.56506, 1879.09216, 16.61320,   0.00000, 0.00000, -90.00000);
    return true;
}

COMMAND:test1(playerid, params[]) {
    GetObjectPosAndRot(0,5,ObjectID,position,rotation);
    GetObjectPosAndRot(1,5,ObjectID,position,rotation);
    GetObjectPosAndRot(2,5,ObjectID,position,rotation);
    GetObjectPosAndRot(3,5,ObjectID,position,rotation);
    GetObjectPosAndRot(4,5,ObjectID,position,rotation);
    return true;
}
COMMAND:test2(playerid, params[]) {
    DestroyObjectNEW(5,ObjectID);
    return true;
}
COMMAND:test3(playerid, params[]) {
    CreateObjectNEW(1697,5,ObjectID,0,position,rotation);
    CreateObjectNEW(1697,5,ObjectID,1,position,rotation);
    CreateObjectNEW(1697,5,ObjectID,2,position,rotation);
    CreateObjectNEW(1697,5,ObjectID,3,position,rotation);
    CreateObjectNEW(1697,5,ObjectID,4,position,rotation);
    return true;
}

stock DestroyObjectNEW(obj,var[]) { //FUNCIONA PERFECTO
    for(new index=0; index<obj; index++) {
        if(!IsValidObject(var[index])) continue;
        DestroyObject(var[index]);
        printf("[] DestroyObjectNEW %d", var[index]);
    }
}
stock CreateObjectNEW(id,obj,var[],array,Float:varpos[][],Float:varrot[][]) { //FUNCIONA PERFECTO
    for(new index=0; index<obj; index++) {
        if(IsValidObject(var[index])) continue;
        var[index]=CreateObject(id, varpos[array][0], varpos[array][1], varpos[array][2],   varrot[array][0], varrot[array][1], varrot[array][2]);
        printf("[] CreateObjectNEW %f %f %f %f %f %f", varpos[array][0], varpos[array][1], varpos[array][2], varrot[array][0], varrot[array][1], varrot[array][2]);
        printf("[] CreateObjectNEW %d", var[index]);
    }
}
stock GetObjectPosAndRot(array,obj,var[],Float:varpos[][],Float:varrot[][]) {//PROBLEMAS... :rolleyes:
    for(new index=0; index<obj; index++) {
        if(!IsValidObject(var[index])) continue;
        GetObjectPos(var[index], varpos[array][0], varpos[array][1], varpos[array][2]);
        GetObjectRot(var[index], varrot[array][0], varrot[array][1], varrot[array][2]);
        printf("[] GetObjectPosAndRot %d", var[index]);
        printf("[] GetObjectPosAndRot %f %f %f %f %f %f", varpos[array][0], varpos[array][1], varpos[array][2], varrot[array][0], varrot[array][1], varrot[array][2]);
    }
}
Desde ya muchas Gracias.
Reply
#2

Si queres guardar 5 objetos tenes que hacer una array de 6 celdas.
Reply
#3

Quote:
Originally Posted by JustBored
Посмотреть сообщение
Si queres guardar 5 objetos tenes que hacer una array de 6 celdas.
si lo hago, pero coloke 5 por le utilizo el 0 .
Reply
#4

Si en el comando creas una linea por cada objeto a borrar, entonces para quй usas un bucle en la funciуn.
Reply
#5

Intenta con:
pawn Код:
GetObjectPosAndRot(0,5,ObjectID[0],position,rotation);
    GetObjectPosAndRot(1,5,ObjectID[1],position,rotation);
    GetObjectPosAndRot(2,5,ObjectID[2],position,rotation);
    GetObjectPosAndRot(3,5,ObjectID[3],position,rotation);
    GetObjectPosAndRot(4,5,ObjectID[4],position,rotation);
Reply
#6

Quote:
Originally Posted by Daniel-92
Посмотреть сообщение
Si en el comando creas una linea por cada objeto a borrar, entonces para quй usas un bucle en la funciуn.
es ke en realidad es asi, con mucho mas objetos.
y lo hago asi por ke los objetos los elinimo en la funcion del script correspondiente y tambien utilizo la posicion de los objetos esos para crear labels y checkpoint en su posicion cuando son elininados..

pawn Код:
new Float:position[5][3],
    Float:rotation[5][3],
    ObjectID_1[5],
    ObjectID_2[5],
    ObjectID_3[5],
    ObjectID_4[5],
    ObjectID_5[5];

public OnFilterScriptInit() {
    //MAPA 1
    ObjectID_1[0]=CreateObject(1697, 306.45633, 1850.32690, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_1[1]=CreateObject(1697, 306.50189, 1857.30835, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_1[2]=CreateObject(1697, 306.52655, 1864.34985, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_1[3]=CreateObject(1697, 306.54568, 1871.73120, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_1[4]=CreateObject(1697, 306.56506, 1879.09216, 16.61320,   0.00000, 0.00000, -90.00000);
    //MAPA 2
    ObjectID_2[0]=CreateObject(1697, 306.45633, 1850.32690, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_2[1]=CreateObject(1697, 306.50189, 1857.30835, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_2[2]=CreateObject(1697, 306.52655, 1864.34985, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_2[3]=CreateObject(1697, 306.54568, 1871.73120, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_2[4]=CreateObject(1697, 306.56506, 1879.09216, 16.61320,   0.00000, 0.00000, -90.00000);
    //MAPA 3
    ObjectID_3[0]=CreateObject(1697, 306.45633, 1850.32690, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_3[1]=CreateObject(1697, 306.50189, 1857.30835, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_3[2]=CreateObject(1697, 306.52655, 1864.34985, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_3[3]=CreateObject(1697, 306.54568, 1871.73120, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_3[4]=CreateObject(1697, 306.56506, 1879.09216, 16.61320,   0.00000, 0.00000, -90.00000);
    //MAPA 4
    ObjectID_4[0]=CreateObject(1697, 306.45633, 1850.32690, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_4[1]=CreateObject(1697, 306.50189, 1857.30835, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_4[2]=CreateObject(1697, 306.52655, 1864.34985, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_4[3]=CreateObject(1697, 306.54568, 1871.73120, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_4[4]=CreateObject(1697, 306.56506, 1879.09216, 16.61320,   0.00000, 0.00000, -90.00000);
    //MAPA 5
    ObjectID_5[0]=CreateObject(1697, 306.45633, 1850.32690, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_5[1]=CreateObject(1697, 306.50189, 1857.30835, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_5[2]=CreateObject(1697, 306.52655, 1864.34985, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_5[3]=CreateObject(1697, 306.54568, 1871.73120, 16.61320,   0.00000, 0.00000, -90.00000);
    ObjectID_5[4]=CreateObject(1697, 306.56506, 1879.09216, 16.61320,   0.00000, 0.00000, -90.00000);
    return true;
}

COMMAND:test1(playerid, params[]) {
    GetObjectPosAndRot(0,5,ObjectID_1,position,rotation);
    GetObjectPosAndRot(1,5,ObjectID_2,position,rotation);
    GetObjectPosAndRot(2,5,ObjectID_3,position,rotation);
    GetObjectPosAndRot(3,5,ObjectID_4,position,rotation);
    GetObjectPosAndRot(4,5,ObjectID_5,position,rotation);
    return true;
}
COMMAND:test2(playerid, params[]) {
    DestroyObjectNEW(5,ObjectID_1);
    DestroyObjectNEW(5,ObjectID_2);
    DestroyObjectNEW(5,ObjectID_3);
    DestroyObjectNEW(5,ObjectID_4);
    DestroyObjectNEW(5,ObjectID_5);
    return true;
}
COMMAND:test3(playerid, params[]) {
    CreateObjectNEW(1697,5,ObjectID_1,0,position,rotation);
    CreateObjectNEW(1697,5,ObjectID_2,1,position,rotation);
    CreateObjectNEW(1697,5,ObjectID_3,2,position,rotation);
    CreateObjectNEW(1697,5,ObjectID_4,3,position,rotation);
    CreateObjectNEW(1697,5,ObjectID_5,4,position,rotation);
    return true;
}

stock DestroyObjectNEW(obj,var[]) { //FUNCIONA PERFECTO
    for(new index=0; index<obj; index++) {
        if(!IsValidObject(var[index])) continue;
        DestroyObject(var[index]);
        printf("[] DestroyObjectNEW %d", var[index]);
    }
}
stock CreateObjectNEW(id,obj,var[],array,Float:varpos[][],Float:varrot[][]) { //FUNCIONA PERFECTO
    for(new index=0; index<obj; index++) {
        if(IsValidObject(var[index])) continue;
        var[index]=CreateObject(id, varpos[array][0], varpos[array][1], varpos[array][2],   varrot[array][0], varrot[array][1], varrot[array][2]);
        printf("[] CreateObjectNEW %f %f %f %f %f %f", varpos[array][0], varpos[array][1], varpos[array][2], varrot[array][0], varrot[array][1], varrot[array][2]);
        printf("[] CreateObjectNEW %d", var[index]);
    }
}
stock GetObjectPosAndRot(array,obj,var[],Float:varpos[][],Float:varrot[][]) {//PROBLEMAS... :rolleyes:
    for(new index=0; index<obj; index++) {
        if(!IsValidObject(var[index])) continue;
        GetObjectPos(var[index], varpos[array][0], varpos[array][1], varpos[array][2]);
        GetObjectRot(var[index], varrot[array][0], varrot[array][1], varrot[array][2]);
        printf("[] GetObjectPosAndRot %d", var[index]);
        printf("[] GetObjectPosAndRot %f %f %f %f %f %f", varpos[array][0], varpos[array][1], varpos[array][2], varrot[array][0], varrot[array][1], varrot[array][2]);
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)