while(fread(camFile, line, 128))
{
if (idx == MAX_CAMNODE)
{
print("ERROR: Camera node limit reached");
break;
}
if (!sscanf(line, "p<,>ffffffD(-1)D(-1)D(-1)", // Too much for one line
camData[id][idx][cam_cPosX], camData[id][idx][cam_cPosY], camData[id][idx][cam_cPosZ],
camData[id][idx][cam_lPosX], camData[id][idx][cam_lPosY], camData[id][idx][cam_lPosZ],
tmpData[TMP_LOAD][0], tmpData[TMP_LOAD][1], tmpData[TMP_LOAD][2] ))
{
for(new c;c<TMP_DATA_COUNT;c++) // c = cell reference
{
if (tmpData[TMP_LOAD][c] == -1) tmpData[TMP_LOAD][c] = tmpData[TMP_KEEP][c]; // If it an optional param has -1 set it's detault value
else tmpData[TMP_KEEP][c] = tmpData[TMP_LOAD][c]; // Otherwise set the default value to the value just read
// This method means that you can define timings for a set of coordinates
// simply by defining the top one as what you want and leaving the rest blank
// These settings will be default until the next line is found with optional params
}
camData[id][idx][cam_moveTime] = tmpData[TMP_LOAD][0]; // Set the values to the global array cell of this camera
camData[id][idx][cam_waitTime] = tmpData[TMP_LOAD][1];
camData[id][idx][cam_moveType] = tmpData[TMP_LOAD][2];
}
idx++;
}
if (!sscanf(line, "p<,>ffffffD(-1)D(-1)D(-1)", // Too much for one line
camData[id][idx][cam_cPosX], camData[id][idx][cam_cPosY], camData[id][idx][cam_cPosZ],
camData[id][idx][cam_lPosX], camData[id][idx][cam_lPosY], camData[id][idx][cam_lPosZ],
tmpData[TMP_LOAD][0], tmpData[TMP_LOAD][1], tmpData[TMP_LOAD][2] ))
p<,>ffffffD(-1)D(-1)D(-1)
1.0,1.0,1.0,1.0,1.0,1.0,0,0,0
But it uses sscanf2, I didn't like it because I already have too many plugins and I don't use it for my gamemode.
|
Oh boy, you're doing something which no one would EVER advice you... You should use sscanf because it's the best (C++, speed and reliability) and better than strtok.
PHP код:
f is float and d is for integer. You can enter the float value (and the integer value) with the 'comma' (,) separator between them. PHP код:
|