LoadMap Function made
#1

Hello,

I am making a function that create the objects from the current map.

pawn Код:
public LoadMap(MapID)
{
    printf("Trying to Load MapID: %d", MapID);
    new FileName[128],line[128];
    format(FileName, sizeof(FileName), "Maps/%d.ini", MapID);
    new letter[1], Float:rot, Float:X, Float:Y, Float:Z, File:map = fopen(FileName, io_read);
    new model =0,Float:rX, Float:rY, Float:rZ;
    if(fexist(FileName))
    {
        printf("Loading MapID: %d", MapID);
        while(fread(map, line))
        {
            if(strcmp(line, "H", false, 1) == 0){
                sscanf(line, "sf", letter, MapHeight);
            }
           
            if(strcmp(line, "P", false, 1) == 0){
                sscanf(line, "sd", letter, MapPrize);
            }
           
            if(strcmp(line, "C", false, 1) == 0){
                if (!sscanf(line, "sfff", letter, X, Y, Z)){
                    CameraX = X;
                    CameraY = Y;
                    CameraZ = Z;
                }
            }

            if(strcmp(line, "L", false, 1) == 0){
                if (!sscanf(line, "sfff", letter, X, Y, Z)){
                    LCameraX = X;
                    LCameraY = Y;
                    LCameraZ = Z;
                }
            }
            if(strcmp(line, "O", false, 1) == 0){
                if (!sscanf(line, "sdffffff", letter, model, X, Y, Z, rX, rY, rZ)){
                    MapObjects[MapObjectsCounter] = CreateDynamicObject(model, X, Y, Z, rX, rY, rZ);
                    MapObjectsCounter++;
                }
            }
            if(strcmp(line, "S", false, 1) == 0){
                if (!sscanf(line, "sffff", letter, X, Y, Z, rot)){
                    SpawnPoints[SpawnPointsCounter][SPAWN_X] = X;
                    SpawnPoints[SpawnPointsCounter][SPAWN_Y] = Y;
                    SpawnPoints[SpawnPointsCounter][SPAWN_Z] = Z;
                    SpawnPoints[SpawnPointsCounter][SPAWN_ROT] = rot;

                    SpawnPointsCounter++;
                }
            }
        }
       
        printf("%f MapHeight", MapHeight);
        printf("%d MapPrize", MapPrize);
        printf("%f %f %f Camera Pos", CameraX,CameraY,CameraZ);
        printf("%f %f %f Camera Lookat Pos", LCameraX,LCameraY,LCameraZ);
        printf("%d SpawnPoints Loaded", SpawnPointsCounter);
        printf("%d Objects Loaded", MapObjectsCounter);
        printf("Map Loaded (%d)", MapID);
       
    }
    else
    {
        printf("Map Failed To Load! (%d)", MapID);
    }
}
But as soon as I load a map the half of the objects are not made..

this is a template of one of the maps:

Код:
[settings]
H 62.5474
P 85000
C 3.9800 1439.2473 243.9866
L 4.3070 1440.1968 243.3465

[objects]
O 13607 85.54502 1725.07849 125.35680 0.00000 0.00000 297.96579
O 13607 189.83598 1710.39160 125.35380 0.00000 0.00000 202.00000
O 13607 151.07979 1805.05212 125.32825 0.00000 0.00000 0.00000
O 3458 175.36047 1761.38806 120.19199 0.00000 0.00000 307.87259
O 3458 172.50351 1757.57300 120.23685 0.00000 0.00000 307.44766
O 3458 139.21432 1710.88354 120.14730 0.00000 0.00000 356.04010
O 3458 139.51964 1715.88660 120.10246 0.00000 0.00000 356.09839
O 3458 120.47340 1762.58936 120.25302 0.00000 0.00000 50.41240
O 3458 117.83733 1766.70044 120.20421 0.00000 0.00000 50.56581
O 3458 43.68640 1691.17334 120.24850 0.00000 0.00000 41.13350
O 3458 47.45390 1686.71997 120.24840 0.00000 0.00000 41.09190
O 3458 17.62788 1660.62158 120.24802 0.00000 0.00000 41.26023
O 3458 13.85560 1665.14758 120.24800 0.00000 0.00000 41.12270
O 3458 -11.98040 1634.56714 120.24850 0.00000 0.00000 41.25330
O 3458 -15.92810 1639.10962 120.24850 0.00000 0.00000 41.22230
O 13607 -55.40858 1602.19922 125.70467 0.00000 0.00000 0.00000
O 3458 2.99245 1594.65234 120.62868 0.00000 0.00000 0.00000
O 3458 2.71669 1588.74268 120.62289 0.00000 0.00000 359.76376
O 3458 41.23360 1588.43530 125.69530 0.00000 -15.00000 359.00000
O 3458 41.31786 1594.26941 125.69530 0.00000 -15.00000 359.00000
O 13607 100.87070 1589.61292 135.96460 0.00000 0.00000 -0.97100
O 19005 97.35532 1616.81421 135.52162 0.00000 0.00000 5.93164
O 3458 107.06490 1531.71741 135.93240 0.00000 -15.00000 273.73511
O 3458 102.68360 1531.47754 135.93240 0.00000 -15.00000 273.99161
O 13607 148.84720 1750.23547 88.19859 0.00000 0.00000 0.00000
O 18980 146.31914 1601.56079 131.89290 0.00000 89.00000 20.47886
O 18980 148.50381 1600.27551 131.93102 0.00000 89.00000 20.68389
O 18980 157.84799 1605.88550 132.06033 0.00000 89.00000 20.47540
O 18980 158.57784 1604.08362 132.12820 0.00000 89.00000 20.68390
O 3062 171.22209 1609.79871 132.83920 89.00000 -149.00000 349.70508
O 18980 182.49171 1614.09094 132.55602 0.00000 89.00000 19.96632
O 18981 193.99303 1618.36108 132.75836 0.00000 89.00000 20.26204
O 18981 94.77540 1499.40015 142.14400 0.00000 90.00000 4.00000
O 18981 113.63710 1500.74219 142.14481 0.00000 90.00000 4.00000


[spawns]
S -54.4931 1573.2501 126.6633 0.0000
S -68.0999 1575.5052 126.6633 -33.0000
S -78.1750 1581.7255 126.6633 -55.0000
S -84.2283 1592.4836 126.6633 -76.0000
S -85.3277 1603.6918 126.6633 -97.0000
S -82.2148 1614.1085 126.6633 -120.0000
S -75.7512 1623.9702 126.6633 -137.0000
S -65.0343 1629.8164 126.6633 -164.0000
S -52.4063 1630.8657 126.6633 -185.0000
S -27.3872 1614.2804 126.6633 98.0000
S -32.9675 1587.4347 126.6633 55.0000
S -41.0119 1627.6978 126.6633 142.0000
S -43.4980 1577.8368 126.6633 32.0000
Reply


Messages In This Thread
LoadMap Function made - by Stefand - 11.08.2013, 09:52
Re: LoadMap Function made - by BullseyeHawk - 11.08.2013, 10:01
Re: LoadMap Function made - by Stefand - 11.08.2013, 10:05
Re: LoadMap Function made - by BullseyeHawk - 11.08.2013, 10:12
Re: LoadMap Function made - by Stefand - 11.08.2013, 10:35
Re: LoadMap Function made - by JaKe Elite - 11.08.2013, 10:43
Re: LoadMap Function made - by Stefand - 11.08.2013, 13:30

Forum Jump:


Users browsing this thread: 2 Guest(s)