You buffer and randomize.
Code:
new x[16], y[16], z[16], szDesc[32], szData[charsmax(x) + charsmax(y) + charsmax(z) + charsmax(szDesc)]
new Float:vOrigin[3]
while(!feof(iFile))
{
fgets(iFile, szData, charsmax(szData))
trim(szData)
if(!szData[0]) continue;
parse(szData, x, 15, y, 15, z, 15, szDesc, 31)
vOrigin[0] = str_to_float(x)
vOrigin[1] = str_to_float(y)
vOrigin[2] = str_to_float(z)
spawn_testing(vOrigin, szDesc)
}
->
Code:
new x[16], y[16], z[16], szDesc[32][32], szData[charsmax(x) + charsmax(y) + charsmax(z) + charsmax(szDesc[])];
new Float:vOrigin[32][3], count;
while(!feof(iFile))
{
fgets(iFile, szData, charsmax(szData));
trim(szData);
if(!szData[0]) continue;
parse(szData, x, 15, y, 15, z, 15, szDesc[count], 31);
vOrigin[count][0] = str_to_float(x);
vOrigin[count][1] = str_to_float(y);
vOrigin[count][2] = str_to_float(z);
count++;
}
for ( new i, rand1, rand2 ; i < 100 ; i++ ) {
rand1 = random(count);
rand2 = random(count);
vOrigin[count][0] = vOrigin[rand2][0];
vOrigin[count][1] = vOrigin[rand2][1];
vOrigin[count][2] = vOrigin[rand2][2];
copy(szDesc[count], charsmax(szDesc[]), szDesc[rand2]);
vOrigin[rand2][0] = vOrigin[rand1][0];
vOrigin[rand2][1] = vOrigin[rand1][1];
vOrigin[rand2][2] = vOrigin[rand1][2];
copy(szDesc[rand2], charsmax(szDesc[]), szDesc[rand1]);
vOrigin[rand1][0] = vOrigin[count][0];
vOrigin[rand1][1] = vOrigin[count][1];
vOrigin[rand1][2] = vOrigin[count][2];
copy(szDesc[rand1], charsmax(szDesc[]), szDesc[count]);
}
for ( new i ; i < 6 /* or pcvar */ ; i++ )
spawn_testing(vOrigin[i], szDesc)
or
Code:
new x[16], y[16], z[16], szDesc[32][32], szData[charsmax(x) + charsmax(y) + charsmax(z) + charsmax(szDesc[])];
new Float:vOrigin[32][3], count;
while(!feof(iFile))
{
fgets(iFile, szData, charsmax(szData));
trim(szData);
if(!szData[0]) continue;
parse(szData, x, 15, y, 15, z, 15, szDesc[count], 31);
vOrigin[count][0] = str_to_float(x);
vOrigin[count][1] = str_to_float(y);
vOrigin[count][2] = str_to_float(z);
count++;
}
new vOriginUsed;
for ( new i, temp ; i < 6 /* or pcvar */ ; i++ ) {
do {
temp = random(count);
}
while ( vOriginUsed & (1<<temp) )
spawn_testing(vOrigin[temp], szDesc[temp])
vOriginUsed |= (1<<temp);
}
If you want it dynamic and editable by the end user don't forget to check that there are more locations than requested spawns.
Code:
new pcvar = get_pcvar_num(...);
if ( pcvar > count )
pcvar = count;
//...
__________________