fread need help
#1

Код:
    public OnGameModeInit()
    {
    new string[256]; // Create the string to store the read text in
    new File:example = fopen("cars.cfg", io_read); // Open the file
    while(fread(example, string)) //reads the file line-by-line
    {
    AddStaticVehicle(string);
    printf("%s", string);
    }
    fclose(example);
    return 1; 
    }
and he say error 035: argument type mismatch (argument 1)
Reply
#2

What is the line?
Reply
#3

You can't pass a string in place of arguments, you'll have to use sscanf to split up the read line and put it in to variables, then pass each variable in AddStaticVehicle.
Reply
#4

Quote:
Originally Posted by MP2
Посмотреть сообщение
You can't pass a string in place of arguments, you'll have to use sscanf to split up the read line and put it in to variables, then pass each variable in AddStaticVehicle.
i don't know how
can you show me once?
Reply
#5

https://sampwiki.blast.hk/wiki/AddStaticVehicle
this is an exemple,but you need sscanf an variable
Reply
#6

Quote:
Originally Posted by Skaizo
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/AddStaticVehicle
this is an exemple,but you need sscanf an variable
how to use sscanf an variable
just include that inc?
Reply
#7

can somebody help me ?
i really don't know
Reply
#8

Show an example of what the file cars.cfg is. Post a couple of lines from it.
Reply
#9

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Show an example of what the file cars.cfg is. Post a couple of lines from it.
the cars.cfg is in the scriptfiles
Код:
411,2248.7592,-1653.7923,15.2370,77.8130
404,1057.8303,-1239.1422,15.8217,4.0920
421,1565.2381,-1713.0145,5.7960,240.0299
474,1588.3597,-1681.5926,5.7371,47.1082
482,1534.3208,-1664.0897,6.0624,11.2734
596,1366.6151,-1343.1114,13.2292,321.9594
596,1862.9022,-1624.7380,13.1891,221.4700
596,1905.9127,-1794.8537,13.2180,129.5675
492,2511.9128,-1675.5234,13.3339,265.8019
605,2265.0649,-1177.3547,25.4319,61.6267
554,2140.2673,-1478.6140,24.4899,269.1665
478,1131.4676,-1563.6695,13.2777,117.3684
470,767.0205,-1374.6064,13.5509,332.4468
470,770.9467,-1313.1103,13.4785,236.8058
470,1991.3922,-1622.7154,13.7376,179.8538
416,1276.8160,-1385.9272,13.5045,89.5615
433,2498.3972,-1656.8647,13.8934,102.7611
475,2341.4177,-1198.0008,27.7709,42.9351
543,1784.0069,-1929.7269,13.2089,96.5996
442,1010.9500,-1359.9200,13.1990,300.8020
475,974.1707,-1290.4687,13.3760,110.1266
400,819.5186,-1647.7154,13.5951,201.6994
426,620.8861,-1512.0080,14.6892,181.2187
410,1194.9298,-1292.6451,13.0600,196.6502
408,844.5678,-1414.5450,14.0298,106.0979
475,1707.2213,-1558.1346,13.8549,91.6050
420,1348.6770,-1756.9217,13.2559,139.1757
475,1707.2213,-1558.1346,13.8816,91.5464
574,1905.3166,-1388.3359,10.1812,69.5484
463,2086.8295,-1183.1477,25.2465,311.9219
400,1845.3863,-1883.7950,13.5226,269.0480
433,2734.5839,-1082.5194,69.8615,57.4272
409,2716.7912,-1065.5793,69.2321,87.7276
420,1775.4073,-1898.3763,13.2047,328.9674
405,744.2340,-1660.6319,4.1922,161.2539
540,2110.4135,-1342.1595,23.8444,238.4237
596,2662.4843,-1853.6599,10.6365,271.5252
470,367.8410,-2044.0714,7.6711,0.9243
470,372.8666,-2044.7147,7.6676,357.7654
470,2715.3715,-1117.0393,69.5149,111.3178
507,748.4389,-1340.9914,13.3072,154.5384
Reply
#10

pawn Код:
public OnGameModeInit()
{
    new string[150], vehicleModel, Float: vehicleSpawn[4], vehicleColors[2];
    new File:example = fopen("cars.cfg", io_read);

    while(fread(example, string))
    {
        sscanf(string, "p<,>dffffdd", vehicleModel, vehicleSpawn[0], vehicleSpawn[1], vehicleSpawn[2], vehicleSpawn[3], vehicleColors[0], vehiclesColors[1]);
        AddStaticVehicle(vehicleModel, vehicleSpawn[0], vehicleSpawn[1], vehicleSpawn[2], vehicleSpawn[3], vehicleColors[0], vehicleColors[1]);
    }

    fclose(example);
    return 1;
}
If each arguement is split by something other than ',' then change it inside of p<> at the beginning of sscanf. If it's split by spaces, just remove p<,>.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)