DarkIceX
07-05-2008, 03:54 PM
I'm trying to create a system which allows you to copy a level to your current level so that your level becomes a near exact replica (no NPCs)..
It's been done before, but It's good practice.
Anyways, I'm having a problem with the tiles resetting back to the normal tiles after a few minutes. The level is by default a level of all grass. When I copy a level, It'll update the board for a few minutes then pop back to all grass.
Wondering what's causing this.
function onCreated()
{
setshape(1,32,32);
}
function onActionspy()
{
temp.levelname = params[0];
temp.y = 0;
for (temp.x = -1; temp.x < 65; temp.x++)
{
tiles[temp.x,temp.y] = findlevel(temp.levelname).tiles[temp.x,temp.y];
if (temp.x == 64 && temp.y < 64)
{
temp.x = -1;
temp.y++;
}
}
updateboard(0,0,64,64);
for (a: allplayers)
{
if (a.level.name == temp.levelname)
{
if (a.level.name == "") continue;
temp.players.add(a.account);
}
}
echo(temp.players.size() SPC "players in" SPC temp.levelname);
echo(temp.players);
echo("Getting player attributes");
for (p: temp.players)
{
if (findplayer(p).communityname == "")
{
temp.account = findplayer(p).account;
}
else temp.account = findplayer(p).communityname;
temp.x = findplayer(p).x;
temp.y = findplayer(p).y;
temp.head = findplayer(p).headimg;
temp.body = findplayer(p).bodyimg;
temp.shield = findplayer(p).shieldimg;
temp.colors_0 = findplayer(p).colors[0];
temp.colors_1 = findplayer(p).colors[1];
temp.colors_2 = findplayer(p).colors[2];
temp.colors_3 = findplayer(p).colors[3];
temp.colors_4 = findplayer(p).colors[4];
temp.colors_5 = findplayer(p).colors[5];
echo(temp.account @ ": (" @ temp.x @ "," @ temp.y @ ")" SPC temp.head @ "," SPC temp.body @ "," SPC temp.shield @ "," SPC temp.colors_0 @ "," SPC temp.colors_1 @ "," SPC temp.colors_2 @ "," SPC temp.colors_3 @ "," SPC temp.colors_4 @ "," SPC temp.colors_5);
}
echo("Attribute fetching completed for" SPC temp.levelname);
}
//#CLIENTSIDE
function onPlayerChats()
{
if (player.chat.starts("/spy"))
{
temp.level = player.chat.tokenize()[1];
player.chat = temp.level;
triggeraction(x,y,"spy",temp.level);
}
}
This may not be the best or most efficient way of doing it, but I'm still learning, so if you know a better way It'd also be appreiciated if you could point me in the right direction.
Thanks :D
It's been done before, but It's good practice.
Anyways, I'm having a problem with the tiles resetting back to the normal tiles after a few minutes. The level is by default a level of all grass. When I copy a level, It'll update the board for a few minutes then pop back to all grass.
Wondering what's causing this.
function onCreated()
{
setshape(1,32,32);
}
function onActionspy()
{
temp.levelname = params[0];
temp.y = 0;
for (temp.x = -1; temp.x < 65; temp.x++)
{
tiles[temp.x,temp.y] = findlevel(temp.levelname).tiles[temp.x,temp.y];
if (temp.x == 64 && temp.y < 64)
{
temp.x = -1;
temp.y++;
}
}
updateboard(0,0,64,64);
for (a: allplayers)
{
if (a.level.name == temp.levelname)
{
if (a.level.name == "") continue;
temp.players.add(a.account);
}
}
echo(temp.players.size() SPC "players in" SPC temp.levelname);
echo(temp.players);
echo("Getting player attributes");
for (p: temp.players)
{
if (findplayer(p).communityname == "")
{
temp.account = findplayer(p).account;
}
else temp.account = findplayer(p).communityname;
temp.x = findplayer(p).x;
temp.y = findplayer(p).y;
temp.head = findplayer(p).headimg;
temp.body = findplayer(p).bodyimg;
temp.shield = findplayer(p).shieldimg;
temp.colors_0 = findplayer(p).colors[0];
temp.colors_1 = findplayer(p).colors[1];
temp.colors_2 = findplayer(p).colors[2];
temp.colors_3 = findplayer(p).colors[3];
temp.colors_4 = findplayer(p).colors[4];
temp.colors_5 = findplayer(p).colors[5];
echo(temp.account @ ": (" @ temp.x @ "," @ temp.y @ ")" SPC temp.head @ "," SPC temp.body @ "," SPC temp.shield @ "," SPC temp.colors_0 @ "," SPC temp.colors_1 @ "," SPC temp.colors_2 @ "," SPC temp.colors_3 @ "," SPC temp.colors_4 @ "," SPC temp.colors_5);
}
echo("Attribute fetching completed for" SPC temp.levelname);
}
//#CLIENTSIDE
function onPlayerChats()
{
if (player.chat.starts("/spy"))
{
temp.level = player.chat.tokenize()[1];
player.chat = temp.level;
triggeraction(x,y,"spy",temp.level);
}
}
This may not be the best or most efficient way of doing it, but I'm still learning, so if you know a better way It'd also be appreiciated if you could point me in the right direction.
Thanks :D