Get map directory Method.
Posted: 27 Jun 2014, 01:41
Hey, I've decided to make a method that will give me the directory of a map that the player is currently inside.
This is handy for making changes to the level file, for example: moving, deleting, copying or uploading...
Method Code:
So now you can simply get the directory by using the following code:
I hope you find this useful!
PS: Took a while for me to understand how MyMaps were located
This is handy for making changes to the level file, for example: moving, deleting, copying or uploading...
Method Code:
- Code: Select all
private string GetMapDir(Player p)
{
string mapname = p.level.name;
string directory = "";
if (p.level.mapType == MapType.Home)
{
directory = Environment.CurrentDirectory + "/maps/home/" + mapname + ".lvl";
}
else if (p.level.mapType == MapType.MyMap)
{
string one = p.name.Substring(0, 1).ToLower();
string two = p.name.Substring(1, 1).ToLower();
string three = p.name.Substring(2, 1).ToLower();
directory = Environment.CurrentDirectory + "/maps/mymaps/" + one + "/" + two + "/" + three + "/" + p.name.ToLower() + "/" + mapname + ".lvl";
}
else if (p.level.mapType == MapType.Freebuild)
{
directory = Environment.CurrentDirectory + "/levels/" + mapname + ".lvl";
}
else if (p.level.mapType == MapType.Zombie)
{
directory = Environment.CurrentDirectory + "/infection/maps/" + mapname + ".lvl";
}
else if (p.level.mapType == MapType.Lava)
{
directory = Environment.CurrentDirectory + "/lava/maps/" + mapname + ".lvl";
}
return directory;
}
So now you can simply get the directory by using the following code:
- Code: Select all
GetMapDir(p);
//For Example:
string file = GetMapDir(p);
I hope you find this useful!
PS: Took a while for me to understand how MyMaps were located