Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-20-2008, 06:22 AM
GULTHEX GULTHEX is offline
Registered User
Join Date: Jul 2008
Posts: 148
GULTHEX can only hope to improve
Unhappy [health script help] <read

ok when i press s to punch it turns my char invis but only if they have this script
and the punch script works fine allso
but this only happens if they have this script
so whats the prob with the script

PHP Code:
//#CLIENTSIDE
function onCreated(){

setTimer(.05);
}
function 
onTimeout(){
hideimgs(0,200);
  for (
i=0this.hps.size(); i++) {
    
showtext(i,this.hps[i][1],this.hps[i][2],"Arial","cb",this.hps[i][0]);
    if (
this.hps[i][0] < 0changeimgcolors(i,1,0,0,1);
     else 
changeimgcolors(i,0,1,0,1);
    
changeimgzoom(i,.8);
    
this.hps[i][2]-=.1;
    
this.hps[i][3]--;
    if (
this.hps[i][3] == 0) {
      
this.hps.delete(i);
    }
  }
  
  if (
client.hp clientr.hpmaxclient.hp clientr.hpmax;
  if (
player.hearts 0this.dead 1;
  if (
this.dead) {
    if (
player.hearts != 0) {
      
this.dead 0;
      
client.hp clientr.hpmax;
      
player.hearts 3;
    }
  }else if (
client.hp <= 0) {
    
player.hearts 0;
    
this.dead 1;
  }else if (
player.fullhearts == 20) {
    if (
player.hearts != 3) {
      
this.php = (player.hearts 3) * 2;
      
client.hp += int(this.php);
      
player.hearts 3;
      
this.hps.add({this.php,player.x+1.5,player.y-1,80});
    }
  }else 
serverwarp("login1");
  
  
setTimer(.05);
}
function 
onPlayerenters(){
this.hps NULL;

Reply With Quote
  #2  
Old 07-20-2008, 06:27 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Any chance that punch script has a for loop? Correct me if I'm wrong, but having the normal variables of i (as opposed to this.i), will change the player's value for i. If the punch script uses a variable by the same name, you'll run into problems.
Change all instances of "i" to "this.i" and see if that works. You have to remember that the player stores all the variables, not the individual script, unless they're temporary (temp.) or specific to a set of brackets (this.) (that is how this. works, right?).
I haven't scripted in over a year, but I think that may be the problem.
Reply With Quote
  #3  
Old 07-20-2008, 07:41 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
No Cali, that isn't the problem.
Try commenting out the entire script then narrowing down what is commented out till you discover what part of the script is causing the problem.
__________________
Do it with a DON!
Reply With Quote
  #4  
Old 07-20-2008, 07:59 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Quote:
Originally Posted by zokemon View Post
No Cali, that isn't the problem.
Try commenting out the entire script then narrowing down what is commented out till you discover what part of the script is causing the problem.
Is it that you know the punch script does not use 'i', or is the i variable local to that block, and I was wrong in my thinking?
Reply With Quote
  #5  
Old 07-20-2008, 08:03 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
Quote:
Originally Posted by excaliber7388 View Post
Is it that you know the punch script does not use 'i', or is the i variable local to that block, and I was wrong in my thinking?
'i' should be declared at least once; something like this:

PHP Code:
for ( temp.foo )
{
  echo( 
);

is perfectly acceptable.

Like Zero said, try to debug it.
__________________
Reply With Quote
  #6  
Old 07-20-2008, 02:52 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
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
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by cbk1994 View Post
'i' should be declared at least once; something like this:

PHP Code:
for ( temp.foo )
{
  echo( 
);

is perfectly acceptable.
I've encountered several occasions where declaring the variable only once, and then reading it without a temp. header, simply do not work. It's a lazy way to do things, you should always be arsed to type out the whole thing.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #7  
Old 07-20-2008, 08:18 PM
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
Quote:
Originally Posted by excaliber7388 View Post
Is it that you know the punch script does not use 'i', or is the i variable local to that block, and I was wrong in my thinking?
Well it is good practice to use a header when defining a temporary variable in a function for the first time but unless the scripter of the punch script was really bad and used global variables for storing data (such as i instead of this.i) it wouldn't matter.

I don't see why someone would use i to store something like that though.
__________________
Do it with a DON!
Reply With Quote
  #8  
Old 07-20-2008, 08:20 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
I've encountered several occasions where declaring the variable only once, and then reading it without a temp. header, simply do not work. It's a lazy way to do things, you should always be arsed to type out the whole thing.
I disagree; I've never had problems with this. I don't see it as lazy; I actually don't like reading code where the 'temp' prefix is included over and over.
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 06:24 AM.


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