View Single Post
  #7  
Old 07-06-2008, 02:09 AM
DarkIceX DarkIceX is offline
(Developer)
Join Date: May 2002
Location: Canada
Posts: 125
DarkIceX is on a distinguished road
All fixed. The finished product is a level NPC that just copies the level and takes the attributes of the players in the level and echoes them to RC..
Probably not the most efficient or easy, but it works:

NPC Code:

function onCreated()
{
setTimer(0.5);
setshape(1,32,32);
this.levelname = null;
}

function onActionspy()
{
this.levelname = params[0];
this.spying = true;

for (a: allplayers)
{
if (a.level.name == this.levelname)
{
if (a.level.name == "") continue;
temp.players.add(a.account);
}
}
echo(temp.players.size() SPC "players in" SPC this.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 this.levelname);
}

function onTimeout()
{
if (this.spying == true && this.levelname != null)
{
temp.y = 0;
for (temp.x = -1; temp.x < 65; temp.x++)
{
level.tilelayers[0].tiles[temp.x,temp.y] = findlevel(this.levelname).tiles[temp.x,temp.y];
if (temp.x == 64 && temp.y < 64)
{
temp.x = -1;
temp.y++;
}
}
updateboard(0,0,64,64);
}
setTimer(0.5);
}

//#CLIENTSIDE

function onCreated()
{
setshape(1,32,32);
setTimer(0.05);
dontblock();
}

function onPlayerChats()
{
if (player.chat.starts("/spy"))
{
temp.levelname = player.chat.tokenize()[1];
player.chat = temp.levelname;
triggeraction(x,y,"spy",temp.levelname);
}
}



If there's anything I can improve on or so more easily than what I have here, It's appreiciated if you could shout it out so I know next time.
__________________

Bloodvayne

Last edited by DarkIceX; 07-06-2008 at 03:39 AM..
Reply With Quote