Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-05-2008, 03:54 PM
DarkIceX DarkIceX is offline
(Developer)
Join Date: May 2002
Location: Canada
Posts: 125
DarkIceX is on a distinguished road
Trouble updating level tiles using script..

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.

NPC Code:

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
__________________

Bloodvayne
Reply With Quote
  #2  
Old 07-05-2008, 05:13 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
technically, your best bet is to do it all clientside. the only purpose to you doing it all serverside is so that others see it, if you're creating a spy level make it clientside.
I made one serverside for Era, I'll post the script when I find it
Reply With Quote
  #3  
Old 07-05-2008, 06:31 PM
DarkIceX DarkIceX is offline
(Developer)
Join Date: May 2002
Location: Canada
Posts: 125
DarkIceX is on a distinguished road
Quote:
Originally Posted by [email protected] View Post
technically, your best bet is to do it all clientside. the only purpose to you doing it all serverside is so that others see it, if you're creating a spy level make it clientside.
I made one serverside for Era, I'll post the script when I find it
Actually, I'd would do it clientside, but one of the points is for other people to be able to see it aswell.

Much more useful to have it serverside from the beginning instead of needing each person to set it to the right level or such.
__________________

Bloodvayne
Reply With Quote
  #4  
Old 07-05-2008, 06:50 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by DarkIceX View Post
Actually, I'd would do it clientside, but one of the points is for other people to be able to see it aswell.
If you do it clientsided all players in the level will see the same thing if the data is the same for everyone.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #5  
Old 07-05-2008, 06:56 PM
DarkIceX DarkIceX is offline
(Developer)
Join Date: May 2002
Location: Canada
Posts: 125
DarkIceX is on a distinguished road
Quote:
Originally Posted by xXziroXx View Post
If you do it clientsided all players in the level will see the same thing if the data is the same for everyone.
I'll try it...

Edit: Tried it clientside, it still does the same thing. I also tried using updateboard2 and it STILL changes back to grass.
__________________

Bloodvayne
Reply With Quote
  #6  
Old 07-06-2008, 12:38 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
try level.tilelayers[0].tiles[x,y] instead of just tiles[x,y].

I don't know if it will help but it seemed to help me.
__________________
Do it with a DON!
Reply With Quote
  #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
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:17 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.