I have a map loader in my gamemode and when i try to load my map from Game so it always show me this :
"-MapLoader- This file doesnt exist in maps folder!" instead there are many maps in scriptfiles. Located in scriptfiles then Maps.
Код:
CMD:loadmap(playerid,params[])
{
if(!IsAdmin(playerid,10)) return SendMsg(playerid, 5);
new NaMe[128];
if(sscanf(params,"s[50]",NaMe)) return SendClientMessage(playerid,RED,"Usage : /loadmap "GRAY_"<filename>");
format(NaMe,128,"../scriptfiles/Maps/%s.txt",NaMe);
LoadSAMPMap(playerid,NaMe,1);
return 1;
}
stock LoadSAMPMap(playerid,src[],create)
{
new fakkkstr[128];
if(!fexist(src))return SendClientMessage(playerid,0xFF8800FF," -MapLoader- {FFBB00} This file doesnt exist in maps folder!");
if(strfind(src, ".txt") == -1) return SendClientMessage(playerid,0xFF8800FF," -MapLoader- {FFBB00} Failed to load the map file , make sure that the map file is in (.txt) format!");
if(GetFreeMap() < 0)return printf(" Couldn't load the map %s (to many maps are loaded).", src); // Setting the map ID
new File:Handler = fopen(src, io_read), count[2];
if(!Handler) return SendClientMessage(playerid,0xFF8800FF," -MapLoader- {FFBB00} Objects failed to load from src!");
format(fakkkstr,sizeof(fakkkstr),"%s",src);
str_replace(".txt","",fakkkstr,true,0,-1,strlen(fakkkstr));
str_replace("../scriptfiles/Maps/","",fakkkstr,true,0,-1,strlen(fakkkstr));
if(GetMapByName(fakkkstr) >= 0) return SendClientMessage(playerid,0xFF8800FF," -MapLoader- {FFBB00} A map with this name already exist!");
new Line[256], Index = -1, Model, Float:PosX, Float:PosY, Float:PosZ, Float:RotX, Float:RotY, Float:RotZ,f_World,f_Interior,isCreate,f_p,Float:f_Dist;
while(fread(Handler, Line))
{
if(count[0] > 998)
{
SendClientMessage(playerid,0xFF8800FF," -MapLoader- {FFBB00}This map contains more than 1000 objects - Some objects has not been loaded!");
break;
}
Index++;
new EOL = strfind(Line, ";", false);
if(EOL != -1) strdel(Line, EOL - 1, sizeof Line - 1),count[1]++;
else
{
if(create == 1) printf("Error Reading object num %i from %s (; not found)", Index, src);
continue;
}
if(!sscanf(Line[20], "p<,>iffffffD(0)D(-1)D(-1)F(300.0)D(0)", Model, PosX, PosY, PosZ, RotX, RotY, RotZ, f_World,f_Interior,f_p,f_Dist,isCreate))
{
if(isCreate == 1) MI[curmap][objects][count[0]]=CreateObject(Model, PosX, PosY, PosZ, RotX, RotY, RotZ,f_Dist);
else MI[curmap][objects][count[0]]=CreateDynamicObject(Model, PosX, PosY, PosZ, RotX, RotY, RotZ, f_World,f_Interior,-1,f_Dist);
count[0]++;
if(Model == 18090|| Model == 14537|| Model == 16151)
{
AddBar(0,PosX, PosY, PosZ, RotX, RotY, RotZ,f_World,f_Interior);
}
if(f_World < 0) MI[curmap][m_world]=0;
else MI[curmap][m_world]=f_World;
if(f_Interior < 0) MI[curmap][m_int]=0;
else MI[curmap][m_int]=f_Interior;
}
else
{
if(create == 1) printf("Error Reading object num %i from %s (invalid line format)", Index, src);
}
}
fclose(Handler);
// MI[curmap][objects][0] = count[0]; // How many objects?
if(count[0] > 0)
{
format(MI[curmap][mapname], 64, fakkkstr); // Set the map title
if(create == 1)
{
new str[150];
format(str,sizeof(str),"INSERT INTO `maps` (`MapName`)VALUES ('%s');",MI[curmap][mapname]);
mysql_function_query(eXs,str,false,"","");
}
}
new str[128];
format(str,sizeof(str)," -MapLoader- {FFBB00}The Map \"%s (%d)\" has been loaded (Objects Loaded : %d || Lines : %d)!",MI[curmap][mapname],curmap,count[0],count[1]);
SendClientMessage(playerid,0xFF8800FF,str);
if(create == 1) printf("MAP: %s (%d) Loaded (Objects: %d) (Lines : %d)", MI[curmap][mapname],curmap,count[0],count[1]);
return 1;
}