Hide/Show Objects with Command.
#1

Hi everyone, i was wondering if its possible to make toggable objects. What I mean, if you type /hideobjects all objects are going to get Destroyed (hide) and when you type /showobjects objects are going to Created (show)

I made some test but it will take me a lot of time to make it by this way due to i have lots of maps:

pawn Код:
forward ShowObject(playerid);
public ShowObject(playerid)
{
    Object1[playerid] = CreateObject(16430,-975.29998779,528.00000000,169.60000610,0.00000000,328.00000000,46.00000000, 300.0);//object(des_ebrigroad02) (4)
    Object2[playerid] = CreateObject(16430,-881.40002441,625.20001221,254.10000610,0.00000000,327.99682617,45.99975586, 300.0);//object(des_ebrigroad02) (5)
    Object3[playerid] = CreateObject(16430,-776.09997559,733.59997559,378.79998779,0.00000000,327.99682617,45.99975586, 300.0);//object(des_ebrigroad02) (6)
    Object4[playerid] = CreateObject(16430,-683.90002441,828.50000000,502.29998779,0.00000000,327.99682617,45.99975586, 300.0);//object(des_ebrigroad02) (7)
    Object5[playerid] = CreateObject(16430,-590.40002441,925.40002441,586.59997559,0.00000000,327.99682617,45.99975586, 300.0);//object(des_ebrigroad02) (8)
    Object6[playerid] = CreateObject(16430,-503.00000000,1016.40002441,695.50000000,0.00000000,327.99682617,45.99975586, 300.0);//object(des_ebrigroad02) (9)
    Object7[playerid] = CreateObject(16430,-410.60000610,1112.19995117,807.50000000,0.00000000,327.99682617,45.99975586, 300.0);//object(airprtcrprk02_lvs) (1)
    Object8[playerid] = CreateObject(8040,-242.00000000,1286.90002441,935.50000000,0.00000000,0.00000000,226.00000000, 300.0);//object(des_ebrigroad02) (9)
    Object9[playerid] = CreateObject(16430,-316.70001221,1209.50000000,892.00000000,0.00000000,327.99682617,45.99975586, 300.0);//object(landjump2) (12)
    Object10[playerid] = CreateObject(1634,-1017.90002441,478.29998779,130.50000000,330.00000000,0.00000000,136.00000000, 300.0);//object(landjump2) (15)
    Object11[playerid] = CreateObject(1634,-1020.79998779,481.10000610,130.50000000,330.00000000,0.00000000,136.00003052, 300.0);//object(landjump2) (17)
    Object12[playerid] = CreateObject(1634,-1023.59997559,483.89999390,130.50000000,329.99633789,0.00000000,135.99975586, 300.0);
    return 1;
}

forward HideObject(playerid);
public HideObject(playerid)
{
    DestroyObject(Object1[playerid]);
    DestroyObject(Object2[playerid]);
    DestroyObject(Object3[playerid]);
    DestroyObject(Object4[playerid]);
    DestroyObject(Object5[playerid]);
    DestroyObject(Object6[playerid]);
    DestroyObject(Object7[playerid]);
    DestroyObject(Object8[playerid]);
    DestroyObject(Object9[playerid]);
    DestroyObject(Object10[playerid]);
    DestroyObject(Object11[playerid]);
    DestroyObject(Object12[playerid]);
    return 1;
}
Is there any way to create it with 1 variable?

Thanks in advanced
Reply
#2

yes there is learn what is an array
you will only need 1 variable
and you can loop to deleat them
pawn Код:
new Object[12][playerid];
Reply
#3

Yes but with this, i think i have to do:

pawn Код:
Object[1][playerid] = CreateObject(16430,-975.29998779,528.00000000,169.60000610,0.00000000,328.00000000,46.00000000, 300.0);//object(des_ebrigroad02) (4)
Object[2][playerid] = CreateObject(16430,-881.40002441,625.20001221,254.10000610,0.00000000,327.99682617,45.99975586, 300.0);//object(des_ebrigroad02) (5)
Object[3][playerid] = CreateObject(16430,-776.09997559,733.59997559,378.79998779,0.00000000,327.99682617,45.99975586, 300.0);//object(des_ebrigroad02) (6)
Object[4][playerid] = CreateObject(16430,-683.90002441,828.50000000,502.29998779,0.00000000,327.99682617,45.99975586, 300.0);//object(des_ebrigroad02) (7)
Object[5][playerid] = CreateObject(16430,-590.40002441,925.40002441,586.59997559,0.00000000,327.99682617,45.99975586, 300.0);//object(des_ebrigroad02) (8)
Object[6][playerid] = CreateObject(16430,-503.00000000,1016.40002441,695.50000000,0.00000000,327.99682617,45.99975586, 300.0);//object(des_ebrigroad02) (9)
Object[7][playerid] = CreateObject(16430,-410.60000610,1112.19995117,807.50000000,0.00000000,327.99682617,45.99975586, 300.0);//object(airprtcrprk02_lvs) (1)
Object[8][playerid] = CreateObject(8040,-242.00000000,1286.90002441,935.50000000,0.00000000,0.00000000,226.00000000, 300.0);//object(des_ebrigroad02) (9)
Object[9][playerid] = CreateObject(16430,-316.70001221,1209.50000000,892.00000000,0.00000000,327.99682617,45.99975586, 300.0);//object(landjump2) (12)
Object[10][playerid] = CreateObject(1634,-1017.90002441,478.29998779,130.50000000,330.00000000,0.00000000,136.00000000, 300.0);//object(landjump2) (15)
Object[11][playerid] = CreateObject(1634,-1020.79998779,481.10000610,130.50000000,330.00000000,0.00000000,136.00003052, 300.0);//object(landjump2) (17)
Object[12][playerid] = CreateObject(1634,-1023.59997559,483.89999390,130.50000000,329.99633789,0.00000000,135.99975586, 300.0);
Which is not helpful either.

I need something like this:

pawn Код:
Object[playerid] = CreateObject(16430,-975.29998779,528.00000000,169.60000610,0.00000000,328.00000000,46.00000000, 300.0);//object(des_ebrigroad02) (4)
    CreateObject(16430,-881.40002441,625.20001221,254.10000610,0.00000000,327.99682617,45.99975586, 300.0);//object(des_ebrigroad02) (5)
    CreateObject(16430,-776.09997559,733.59997559,378.79998779,0.00000000,327.99682617,45.99975586, 300.0);//object(des_ebrigroad02) (6)
    CreateObject(16430,-683.90002441,828.50000000,502.29998779,0.00000000,327.99682617,45.99975586, 300.0);//object(des_ebrigroad02) (7)
    CreateObject(16430,-590.40002441,925.40002441,586.59997559,0.00000000,327.99682617,45.99975586, 300.0);//object(des_ebrigroad02) (8)
    CreateObject(16430,-503.00000000,1016.40002441,695.50000000,0.00000000,327.99682617,45.99975586, 300.0);//object(des_ebrigroad02) (9)
    CreateObject(16430,-410.60000610,1112.19995117,807.50000000,0.00000000,327.99682617,45.99975586, 300.0);//object(airprtcrprk02_lvs) (1)
    CreateObject(8040,-242.00000000,1286.90002441,935.50000000,0.00000000,0.00000000,226.00000000, 300.0);//object(des_ebrigroad02) (9)
    CreateObject(16430,-316.70001221,1209.50000000,892.00000000,0.00000000,327.99682617,45.99975586, 300.0);//object(landjump2) (12)
    CreateObject(1634,-1017.90002441,478.29998779,130.50000000,330.00000000,0.00000000,136.00000000, 300.0);//object(landjump2) (15)
    CreateObject(1634,-1020.79998779,481.10000610,130.50000000,330.00000000,0.00000000,136.00003052, 300.0);//object(landjump2) (17)
    CreateObject(1634,-1023.59997559,483.89999390,130.50000000,329.99633789,0.00000000,135.99975586, 300.0);
Reply
#4

Create a map loader it's not too hard

pawn Код:
new gMapObjects[MAX_OBJECTS] = { INVALID_OBJECT_ID, ... };

stock AddObject(modelid, ox, oy, oz, rx, ry, rz, distance)
{
    for(new i = 0; i < MAX_OBJECTS; i++)
    {
        if(gMapObjects[i] == INVALID_OBJECT_ID)
        {
            gMapObjects[i] = CreateObject(modelid, ox, oy, oz, rx, ry, rz, distance);
            return i;
        }
    }
    return INVALID_OBJECT_ID;
}

stock DeleteObject(index)
{
    if(gMapObjects[index] != INVALID_OBJECT_ID)
    {
         DestroyObject(gMapObjects[index]);
         gMapObjects[index] = INVALID_OBJECT_ID;
         return 1;
     }
     return 0;
}

stock DeleteAllObjects()
{
    new count;
    for(new i = 0; i < MAX_OBJECTS; i++)
    {
         if(gMapObjects[i] != INVALID_OBJECT_ID)
         {
             DestroyObject(gMapObjects[i]);
             gMapObjects[i] = INVALID_OBJECT_ID;
             count++;
         }
    }
    if(count) return 1;
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)