31.07.2011, 05:03
Quote:
solo cambia todos tus class_loaded por Class_loaded el problema esta en el mayus de la primera letra loool!
|
PHP код:
stock LoadStaticClassFromFile(const filename[])
{
new File:file_ptr;
new line[256];
new var_from_line[64];
new Classtype;
new Float:SpawnX;
new Float:SpawnY;
new Float:SpawnZ;
new Float:SpawnRot;
new weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo;
new index;
new Class_loaded;
file_ptr = fopen(filename,filemode:io_read);
if(!file_ptr) return 0;
Class_loaded = 0;
while(fread(file_ptr,line,256) > 0)
{
index = 0;
// Read type
index = token_by_delim(line,var_from_line,',',index);
if(index == (-1)) continue;
Classtype = strval(var_from_line);
if(Classtype < 0 || Classtype > 299) continue;
// Read X, Y, Z, Rotation
index = token_by_delim(line,var_from_line,',',index+1);
if(index == (-1)) continue;
SpawnX = floatstr(var_from_line);
index = token_by_delim(line,var_from_line,',',index+1);
if(index == (-1)) continue;
SpawnY = floatstr(var_from_line);
index = token_by_delim(line,var_from_line,',',index+1);
if(index == (-1)) continue;
SpawnZ = floatstr(var_from_line);
index = token_by_delim(line,var_from_line,',',index+1);
if(index == (-1)) continue;
SpawnRot = floatstr(var_from_line);
// Read Color1, Color2
index = token_by_delim(line,var_from_line,',',index+1);
if(index == (-1)) continue;
weapon1 = strval(var_from_line);
index = token_by_delim(line,var_from_line,';',index+1);
weapon1_ammo = strval(var_from_line);
// Read Color1, Color2
index = token_by_delim(line,var_from_line,',',index+1);
if(index == (-1)) continue;
weapon2 = strval(var_from_line);
index = token_by_delim(line,var_from_line,';',index+1);
weapon2_ammo = strval(var_from_line);
// Read Color1, Color2
index = token_by_delim(line,var_from_line,',',index+1);
if(index == (-1)) continue;
weapon3 = strval(var_from_line);
index = token_by_delim(line,var_from_line,';',index+1);
weapon3_ammo = strval(var_from_line);
//printf("%d,%d,%f,%f,%f,%f,%d,%d",total_vehicles_from_files+vehicles_loaded+1,vehicletype,SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2);
AddPlayerClass(Classtype,SpawnX,SpawnY,SpawnZ,SpawnRot,weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
Class_loaded++;
}
fclose(file_ptr);
printf("Loaded %d Class from: %s",Class_loaded,filename);
return Class_loaded;
}