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-09-2011, 05:05 AM
pez307 pez307 is offline
ImThatGuy
pez307's Avatar
Join Date: Apr 2007
Posts: 58
pez307 is an unknown quantity at this point
Glow effect

Okay so, i took this script from chris posted on forums, and i've added it, yet when players log off the light remains on the ground, how would i prevent that?

Script:
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
onTimeOut();
}

function 
onTimeOut() {

  for (
temp.pl players) {
    
showimg(200 pl.id"light2.png"pl.2.5pl.2.0);
    
changeimgvis(200 pl.id0);
    
changeimgcolors(200 pl.id188.8);
  }

  
setTimer(0.05);

__________________
Cm*
Reply With Quote
  #2  
Old 07-09-2011, 05:34 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by pez307 View Post
Okay so, i took this script from chris posted on forums, and i've added it, yet when players log off the light remains on the ground, how would i prevent that?
1. Count the number of players. I.e: this.player_count = players.size();
2. Check if the number has changed from the last time you checked. I.e: if (players.size() != this.player_count)
3. If the number changed hide the images. I.e: hideimgs(200,1000);

It looks something like this:

PHP Code:
function checkPlayerCount() {
  
// Get current playercount
  
temp.current_count players.size();
  
// Compare to the last playercount
  
if (this.player_count != temp.current_count) {
    
// Playercount has changed.
    
doSomething();
    
// Update last playercount
    
this.player_count temp.current_count;
  }

Hint: You'll have to do this in your timeout loop.
__________________
Quote:
Reply With Quote
  #3  
Old 07-09-2011, 05:37 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
It would probably be better to use a GANI with light2.png and set it as a player attribute (player.attr[10] = "myglow.gani"). Use COLOREFFECT in the GANI file to change the colors. Probably much less CPU-intensive this way.
__________________
Reply With Quote
  #4  
Old 07-09-2011, 12:41 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 cbk1994 View Post
Probably much less CPU-intensive this way.
Stefan stated somewhere many years ago (5+) that running a loop through all players to show chat/nick etc. is less CPU extensive than having gani's attached to achieve the same effect.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #5  
Old 07-09-2011, 12:53 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by xXziroXx View Post
Stefan stated somewhere many years ago (5+) that running a loop through all players to show chat/nick etc. is less CPU extensive than having gani's attached to achieve the same effect.
Since this is about a simple glow effect though, which can be achieved without using GS2 in a gani, I believe it'd be better.
Reply With Quote
  #6  
Old 07-09-2011, 12:59 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by xXziroXx View Post
Stefan stated somewhere many years ago (5+) that running a loop through all players to show chat/nick etc. is less CPU extensive than having gani's attached to achieve the same effect.
That was for timeouts in GANIs for each player, not for an image in a GANI without any GANI script.
__________________
Reply With Quote
  #7  
Old 07-09-2011, 01:19 PM
pez307 pez307 is offline
ImThatGuy
pez307's Avatar
Join Date: Apr 2007
Posts: 58
pez307 is an unknown quantity at this point
Fixed it, thanks for the comments, i used the player.attr[10] thanks Chris
__________________
Cm*
Reply With Quote
  #8  
Old 07-09-2011, 01:28 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
What I tend to do with this type of thing (Classic nicks/ratings/hp/map display etc) is store each display object as a dynamically named variable according to the players account, store each account to an array on the display being created, add each player to a hash each frame while updating the coordinates of the already existing display objects, then simply loop through the array of stored accounts and remove the display objects for where the hash of the account isn't true.

Basic example:

PHP Code:
//#CLIENTSIDE
function onCreated(){
  
this.display = new TStaticVar();
  
this.onTimeout();
}

function 
onTimeout(){

  if(
this.disabled){
    if(
this.storedaccounts != NULL){
      
this.hideimgs(200200 this.displayindex);
      
this.displayindex 0;
      
this.display.clearVars();
      
this.storedaccounts NULL;
    }
    
this.setTimer(0.05);
    return;
  }

  
temp.hash = new TStaticVar();

  for(
temp.pl players){
    
temp.hash.(@ temp.pl.account) = true;
    if(
this.display.(@ temp.pl.account) == NULL){
      
this.displayedaccounts.add(temp.pl.account);
      
this.display.(@ temp.pl.account) = this.showimg(200 this.displayindex"light2.png"temp.pl.2.5temp.pl.2);
      
this.changeimgvis(200 this.displayindex0); 
      
this.changeimgcolors(200 this.displayindex188.8);
      
this.displayindex ++;
    }
    else{
      
this.display.(@ temp.pl.account).temp.pl.2.5;
      
this.display.(@ temp.pl.account).temp.pl.2;
    }
  }

  
//could also use this.display.getdynamicvarnames to accomplish the same thing, but while easier it's slower
  
for(temp.this.displayedaccounts){
    if(!
temp.hash.(@ temp.a)){
      
this.hideimg(this.display.(@ temp.a).imageindex);
      
this.displayedaccounts.delete(temp.i);
    }
    else{
      
temp.++;
    }
  }

  
this.setTimer(0.05);

When it comes to things like nicknames instead of storing the singular display object I store an array such as {player.nick, player.ap, player.ispaused, displayobject} then use this to check for a change in order to update text or colour.

I suppose in the instance of a light effect this method would be more consuming than a gani attr, but it does provide you with a few advantages.
This prevents the problem of the light being affected by something such as player zoom/red/green/blue/alpha/rotation, it also allows you to easily disable it on your own client.

Last edited by ffcmike; 07-09-2011 at 10:37 PM..
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 08:02 AM.


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