Hallo Community.
Wenn eine Random map geladen wird und der Ordner Name zu Groß ist dann wird die Map nicht geladen.
Grund ist, der Ordner Name ist zu groß und bei ca 40 Zeichen ist Schluss.
Aber die Ordner Namen haben Durchschnittlich 50-60 Zeichen.
Jeffry:
Ist aus dem Include
stock LoadRandomMap(Float:offZ = 5.0)
{
new rand;
do {
rand = random(LoadData[lMaxMaps]-10000000)+10000000;
}
while(LoadData[lLastMap] == rand);
LoadData[lLastMap] = rand;
new loadstr[256];
if(!existproperty(0, "", rand))return print("Es konnte keine Map geladen werden!"),0;
getproperty(0, "", rand, loadstr);
strunpack(loadstr, loadstr, 256);
strins(loadstr,"/Racemaps/",0);
strcat(loadstr,"/objects.map");
print(loadstr);
return LoadMap(loadstr,offZ);
}
stock LoadMap(path[], Float:offZ = 5.0)
{
if(UnloadMap()){
new loadstr[400],mapValues[mapData],count;
if(!fexist(path))return 0;
new length = strfind(path,"/",true,2), lstring[128];
strmid(lstring,path,length,strfind(path,"/",true,++length));
format(LoadData[lLastMapName],128,lstring);
// GetAuthorName
new file[256];
format(file, sizeof(file), "/Racemaps/%s/meta.xml", LoadData[lLastMapName]);
new XML:xml = xml_open(file);
new buf[128];
xml_get_string(xml, "meta/info/@author", buf);
format(LoadData[Author], sizeof(LoadData[Author]), buf);
format(file, sizeof(file), "/Racemaps/%s/meta.xml", LoadData[lLastMapName]);
new item[128];
new File:thandle = fopen(file, io_read);
while (fread(thandle, item))
{
if(strfind(item, "#time") != -1)
{
strmid(item, item, strfind(item, "value=")+7, strfind(item,":"));
SetWorldTime(strval(item));
}
}
fclose(thandle);
new File:fhandle = fopen(path,io_read);
while(fread(fhandle, loadstr))
{
if(!loadstr[0])continue;
if(!sscanf(loadstr, "p<">'object''model='d'posX='f'posY='f'posZ='f'rotX='f'rotY='f'rotZ='f",mapValues[pMmodelid], mapValues[pMX], mapValues[pMY], mapValues[pMZ], mapValues[pMRX], mapValues[pMRY], mapValues[pMRZ]))
{
CreateDynamicObject(mapValues[pMmodelid], mapValues[pMX], mapValues[pMY], mapValues[pMZ]+offZ, mapValues[pMRX], mapValues[pMRY], mapValues[pMRZ],-1,-1,-1,300.0,300.0);
}
else if(!sscanf(loadstr, "p<">'racepickup''type='s[30]'vehicle='d'posX='f'posY='f'posZ='f'rotX='f'rotY='f'rotZ='f",mapValues[pMtype],mapValues[pMmodelid], mapValues[pMX], mapValues[pMY], mapValues[pMZ], mapValues[pMRX], mapValues[pMRY], mapValues[pMRZ]))
{
if(strcmp(mapValues[pMtype],"nitro") == 0)CreateRacePickup(mapValues[pMX], mapValues[pMY], mapValues[pMZ]+offZ,1);
else if(strcmp(mapValues[pMtype],"repair") == 0)CreateRacePickup(mapValues[pMX], mapValues[pMY], mapValues[pMZ]+offZ,2);
else if(strcmp(mapValues[pMtype],"vehiclechange") == 0)CreateRacePickup(mapValues[pMX], mapValues[pMY], mapValues[pMZ]+offZ,3,mapValues[pMmodelid]);
}
else if(!sscanf(loadstr, "p<">'spawnpoint''vehicle='d'posX='f'posY='f'posZ='f'rotX='f'rotY='f'rotZ='f",mapValues[pMmodelid], mapValues[pMX], mapValues[pMY], mapValues[pMZ], mapValues[pMRX], mapValues[pMRY], mapValues[pMRZ]))
{
++count;
CreateRaceSpawn(mapValues[pMmodelid], mapValues[pMX], mapValues[pMY], mapValues[pMZ]+offZ, mapValues[pMRZ],count);
}
else if(!sscanf(loadstr, "p<">'marker''color='s[10]'posX='f'posY='f'posZ='f",mapValues[pMtype],mapValues[pMX], mapValues[pMY], mapValues[pMZ]))
{
mapValues[pMmodelid] = CreateDynamicObject(1559,mapValues[pMX], mapValues[pMY], mapValues[pMZ]+offZ,0.0,0.0,0.0,-1,-1,-1,400.0,400.0);
mapValues[pMcolorID] = ConvertStringToHex(mapValues[pMtype]);
SetDynamicObjectMaterial(mapValues[pMmodelid], 0, 1231, "dynsigns", "white64", mapValues[pMcolorID]);
}
else if(!sscanf(loadstr, "p<">'speedboost''posX='f'posY='f'posZ='f'veloX='f'veloY='f'veloZ='f",mapValues[pMX], mapValues[pMY], mapValues[pMZ], mapValues[pMRX], mapValues[pMRY], mapValues[pMRZ]))
{
CreateRacePickup(mapValues[pMX], mapValues[pMY], mapValues[pMZ]+offZ,4, 0 ,mapValues[pMRX], mapValues[pMRY], mapValues[pMRZ]);
}
else if(!sscanf(loadstr, "p<">'teleport''posX='f'posY='f'posZ='f'nposX='f'nposY='f'nposZ='f'rotX='f'rotY='f'rotZ='f",mapValues[pMX], mapValues[pMY], mapValues[pMZ], mapValues[pMRX], mapValues[pMRY], mapValues[pMRZ],mapValues[pNMRZ],mapValues[pNMRZ],mapValues[pNMRZ]))
{
CreateRacePickup(mapValues[pMX], mapValues[pMY], mapValues[pMZ]+offZ,5 , 0 ,mapValues[pMRX], mapValues[pMRY], mapValues[pMRZ]+offZ,mapValues[pNMRZ]);
}
}
fclose(fhandle);
if(!count)return print("Map konnte nicht geladen werden"),0;
strdel(path,strfind(path,"objects.map"),strlen(path));
strdel(loadstr,0,sizeof(loadstr));
format(loadstr,128,"/Racemaps/%s/meta.xml",LoadData[lLastMapName]);
LoadFromMeta(loadstr);
}
return 1;
}
Debug:
/Racemaps/(DM) RaZoR ft. =Maty=! - Melancholic Pi/objects.map