[Plugin] S-ART [place any picture on the map like an object!]
#50

Idk if this code works (actually it should) because i wasnt able to test it, it removes the "arts" limit by using a vector and a map; try it out:

pawn Код:
struct a_vectors
{
    std::map<int, int> arts_array;
};
std::vector<a_vectors*> vectors;

cell AMX_NATIVE_CALL DestroyArt(AMX* amx, cell* params)
{
    for (auto& i : vectors.at(params[1])->arts_array)
    {
        if (i.second != -1)
        {
            g_Invoke->callNative(&PAWN::DestroyObject, i.second);
        }
    }
    vectors.erase((vectors.begin() + params[1])-1);
    return 1;
}

//CreateArt(path, sX, sY, sZ, aX, aY, aZ, dist, type)
cell AMX_NATIVE_CALL CreateArt(AMX* amx, cell* params)
{
    int cre_f = 0;

    PNG_Struct picture;
    char *text = new char;
    amx_StrParam(amx, params[1],text);

    int open_result = picture.Init(text);
    free(text);

    if(open_result == 1)
    {
        logprintf("FAILED to create art: can't load PNG picture");
        return -1;
    }
    if(open_result == -1)
    {
        logprintf("FAILED to create art: PNG isn't 24-bit type");
        return -1;
    }
    float pos[3] = {amx_ctof(params[2]), amx_ctof(params[3]), amx_ctof(params[4])};
    float ang[3] = {amx_ctof(params[5]), amx_ctof(params[6]), amx_ctof(params[7])};
    double ra[3] = {atr(ang[0]), atr(ang[1]), atr(ang[2])};
    float dist = amx_ctof(params[8]);
    //just few simple formulas ^_^
    double up[3] = {sin(ra[1])*cos(ra[2]) + sin(ra[0])*sin(ra[2])*cos(ra[1]), sin(ra[2])*sin(ra[1]) - sin(ra[0])*cos(ra[1])*cos(ra[2]), -cos(ra[0])*cos(ra[1])};
    double right[3] = {-sin(ra[2])*cos(ra[0]), cos(ra[0])*cos(ra[2]), -sin(ra[0])};
    float ws, hs; cell oid; cell type = params[9];
    switch (type)
    {
        case  0: oid = 19464; ws = 5.875f; hs = 5.075f; break;
        case  2: oid = 2814; ws = 0.51f; hs = 0.51f; break;
        default: oid = 19372; ws = 3.18f; hs = 3.48f; break;
    }

    int blockx = (int)floor(float(picture.width()) / 15 + 0.999);
    int blocky = (int)floor(float(picture.height()) / 15 + 0.999);
   
    if(blockx*blocky > 1000)
    {
        logprintf("FAILED to create art: too large image");
        return 10;
    }

    unsigned int *temp_block = (unsigned int*)malloc(15*15*sizeof(unsigned int));
   
    a_vectors* vectores = new a_vectors();

    for (int i = 0; i < blockx; i++)
    {
        for(int j = 0; j < blocky; j++)
        {
            memset(temp_block, 0, sizeof(unsigned int)*15*15);
            CutBlock15(picture, temp_block, i, j);
            int index= i+j*blockx;
            float start[3] = {  (i - blockx/2.0)*ws*right[0] + (j - blocky/2.0)*(hs)*up[0] + pos[0],
                                (i - blockx/2.0)*ws*right[1] + (j - blocky/2.0)*(hs)*up[1] + pos[1],
                                (i - blockx/2.0)*ws*right[2] + (j - blocky/2.0)*(hs)*up[2] + pos[2]};

            int cur_w = CLIP(picture.width() - i*15,0,15);
            int cur_h = CLIP(picture.height() - j*15,0,15);
            char colors[4096] = {0};
            BuildString(colors, temp_block, cur_w, cur_h);
            cell cobid = 0;
            //let's create an object! [format: oid, sX, sY, sZ, aX, aY, aZ, dist]
            float add_rot = 0;
            if (oid == 2814)
            {
                add_rot = -94.65;
                cobid = g_Invoke->callNative(&PAWN::CreateObject, oid, start[0], start[1], start[2], ang[0], ang[1] + add_rot, 180 + ang[2], dist);

                vectores->arts_array.emplace(1, cobid);
                g_Invoke->callNative(&PAWN::SetObjectMaterialText, cobid, colors, 0, 140, "Webdings", 35, 0, 0, 0, 0);
                g_Invoke->callNative(&PAWN::SetObjectMaterial, cobid, 1, -1, "none", "none", 1);
            }
        }
    }
    free(temp_block);
    vectors.push_back(vectores);
    delete vectores;
    return vectors.size()-1;
}
Reply


Messages In This Thread
S-ART [place any picture on the map like an object!] - by DialUp - 01.01.2015, 23:24
Re: S-ART [place any picture on the map like an object!] - by Abagail - 01.01.2015, 23:31
Re: S-ART [place any picture on the map like an object!] - by Madzior_ - 01.01.2015, 23:32
Respuesta: S-ART [place any picture on the map like an object!] - by The_Scope - 02.01.2015, 00:18
Re: S-ART [place any picture on the map like an object!] - by Diabloa - 02.01.2015, 01:01
Re: S-ART [place any picture on the map like an object!] - by $$inSane - 02.01.2015, 05:25
Re: S-ART [place any picture on the map like an object!] - by DialUp - 02.01.2015, 05:32
Re: S-ART [place any picture on the map like an object!] - by $$inSane - 02.01.2015, 05:42
Re: S-ART [place any picture on the map like an object!] - by DialUp - 02.01.2015, 05:54
Re: S-ART [place any picture on the map like an object!] - by Tamer - 02.01.2015, 09:25
Re: S-ART [place any picture on the map like an object!] - by muzammilfreeman - 02.01.2015, 09:31
Re: S-ART [place any picture on the map like an object!] - by Lordzy - 02.01.2015, 09:52
Re: S-ART [place any picture on the map like an object!] - by Daewoo - 02.01.2015, 09:55
Re: S-ART [place any picture on the map like an object!] - by N.K.Stallone - 02.01.2015, 10:22
Re: S-ART [place any picture on the map like an object!] - by RaeF - 02.01.2015, 10:36
Respuesta: S-ART [place any picture on the map like an object!] - by Zume - 02.01.2015, 11:16
Re: S-ART [place any picture on the map like an object!] - by iWhite - 02.01.2015, 12:36
Re: S-ART [place any picture on the map like an object!] - by n0minal - 02.01.2015, 12:52
Re: S-ART [place any picture on the map like an object!] - by iWhite - 02.01.2015, 13:59
Re: S-ART [place any picture on the map like an object!] - by n0minal - 02.01.2015, 14:06
Re: S-ART [place any picture on the map like an object!] - by DialUp - 02.01.2015, 14:07
Re: S-ART [place any picture on the map like an object!] - by n0minal - 02.01.2015, 14:15
Re: S-ART [place any picture on the map like an object!] - by DialUp - 02.01.2015, 14:17
Re: S-ART [place any picture on the map like an object!] - by DialUp - 02.01.2015, 15:31
Re: S-ART [place any picture on the map like an object!] - by n0minal - 02.01.2015, 16:35
Re: S-ART [place any picture on the map like an object!] - by DialUp - 02.01.2015, 16:44
Re: S-ART [place any picture on the map like an object!] - by Dampyr - 02.01.2015, 17:06
Re: S-ART [place any picture on the map like an object!] - by DialUp - 02.01.2015, 17:09
Re: S-ART [place any picture on the map like an object!] - by iWhite - 03.01.2015, 09:50
Re: S-ART [place any picture on the map like an object!] - by DialUp - 03.01.2015, 14:40
Re: S-ART [place any picture on the map like an object!] - by Pottus - 04.01.2015, 18:12
Re: S-ART [place any picture on the map like an object!] - by DialUp - 04.01.2015, 18:25
Re: S-ART [place any picture on the map like an object!] - by Pottus - 04.01.2015, 18:32
Re: S-ART [place any picture on the map like an object!] - by DialUp - 04.01.2015, 18:40
Re: S-ART [place any picture on the map like an object!] - by Pottus - 04.01.2015, 18:50
Re: S-ART [place any picture on the map like an object!] - by DialUp - 04.01.2015, 18:59
Respuesta: S-ART [place any picture on the map like an object!] - by JustBored - 04.01.2015, 19:04
Re: S-ART [place any picture on the map like an object!] - by Pottus - 04.01.2015, 19:06
Re: Respuesta: S-ART [place any picture on the map like an object!] - by DialUp - 04.01.2015, 19:22
Respuesta: S-ART [place any picture on the map like an object!] - by JustBored - 04.01.2015, 19:33
Re: S-ART [place any picture on the map like an object!] - by Crayder - 04.01.2015, 19:47
Re: Respuesta: S-ART [place any picture on the map like an object!] - by DialUp - 04.01.2015, 19:57
Re: S-ART [place any picture on the map like an object!] - by Pottus - 04.01.2015, 20:08
Re: S-ART [place any picture on the map like an object!] - by DialUp - 04.01.2015, 20:20
Re: S-ART [place any picture on the map like an object!] - by Pottus - 04.01.2015, 23:25
Re: S-ART [place any picture on the map like an object!] - by DialUp - 04.01.2015, 23:36
Re: S-ART [place any picture on the map like an object!] - by Pottus - 04.01.2015, 23:45
Respuesta: S-ART [place any picture on the map like an object!] - by JustBored - 05.01.2015, 00:22
Re: Respuesta: S-ART [place any picture on the map like an object!] - by DialUp - 05.01.2015, 00:25
Respuesta: S-ART [place any picture on the map like an object!] - by JustBored - 05.01.2015, 03:03
Re: S-ART [place any picture on the map like an object!] - by Maximun - 10.01.2015, 12:25
Re: S-ART [place any picture on the map like an object!] - by SDraw - 10.01.2015, 18:20
Re: S-ART [place any picture on the map like an object!] - by DialUp - 11.01.2015, 18:25
Re: S-ART [place any picture on the map like an object!] - by Redirect Left - 11.01.2015, 18:31
Re: S-ART [place any picture on the map like an object!] - by TiW - 12.01.2015, 13:11
Re: S-ART [place any picture on the map like an object!] - by SDraw - 12.01.2015, 15:44
Re: S-ART [place any picture on the map like an object!] - by bigboy81 - 13.01.2015, 00:50
Re: S-ART [place any picture on the map like an object!] - by Vinnyy - 13.01.2015, 04:29
Re: S-ART [place any picture on the map like an object!] - by DialUp - 13.01.2015, 19:48
Respuesta: S-ART [place any picture on the map like an object!] - by kgbayala528 - 17.01.2015, 00:47
Re: S-ART [place any picture on the map like an object!] - by MP_Spec - 23.01.2015, 22:00
Re: S-ART [place any picture on the map like an object!] - by hideintherain - 05.02.2015, 11:19
Re: S-ART [place any picture on the map like an object!] - by Crayder - 05.02.2015, 11:49
Re: S-ART [place any picture on the map like an object!] - by hideintherain - 05.02.2015, 17:27
Re: S-ART [place any picture on the map like an object!] - by hideintherain - 06.02.2015, 15:20
Re: S-ART [place any picture on the map like an object!] - by Greaper - 09.05.2015, 12:05
Re: S-ART [place any picture on the map like an object!] - by KrYpToDeN - 10.07.2015, 05:48
Re: S-ART [place any picture on the map like an object!] - by dusk - 10.07.2015, 09:30
Re: S-ART [place any picture on the map like an object!] - by McOwens - 13.07.2015, 21:03
Re: S-ART [place any picture on the map like an object!] - by Stanford - 19.07.2015, 13:58
Re: S-ART [place any picture on the map like an object!] - by mirzakovacic - 23.03.2016, 21:53
Re: S-ART [place any picture on the map like an object!] - by Mowgli - 27.02.2017, 09:48
Re: S-ART [place any picture on the map like an object!] - by iLearner - 27.02.2017, 10:03

Forum Jump:


Users browsing this thread: 1 Guest(s)