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 06-30-2007, 08:53 PM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Bit of a Problem

PHP Code:
public function applyStatChange(statamt) {
  
temp.string 0;
  
tem.plyr 0;
  
  
plyr findPlayer(this.account);
  
  if (
makevar("plyr.clientr.mud." stat) == NULL) return;

  if (
amt != NULL) {
    if (
amt == (abs(amt))) {
      if (
stat == "hp" || "mp") {
        if ((
makevar("plyr.clientr.mud." stat) + amt) <= makevar("plyr.clientr.mud.max" stat)) {
          
makevar("plyr.clientr.mud." stat) += abs(amt);
        }
        else {
          
makevar("plyr.clientr.mud." stat) = makevar("plyr.clientr.mud.max" stat);
        }
      }  
    }
    else {
      if ((
makevar("plyr.clientr.mud." stat) - amt) > 0) {
        echo(
"setting a negative");
        
makevar("plyr.clientr.mud." stat) -= abs(amt);
      }
      else if ((
makevar("plyr.clientr.mud." stat) - amt) <= 0) { 
        echo(
"changing to zero");
        
makevar("plyr.clientr.mud." stat) = 1;
      }
    }
  }
  
reflect("player"3);
  echo(
this.mp);

The adding portion of it works perfectly fine, doesn't go over the max amount or anything like that. However as for the subtracting portion, it tends to go over to -599 before it sets it back to 1 the next time I update. What could be the issue?
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #2  
Old 06-30-2007, 09:22 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
PHP Code:
public function applyStatChange(statamt) {
  
temp.limited = {"hp""mp"};
  
temp.max 0;
  
temp.min 0;

  if (
amt.type() != 0) return; // not a number
  
with (findPlayer(this.account)) {
    
clientr.mud.(@ stat) += amt;
    if (
stat in limited) {
      
max clientr.mud.(@ "max" stat);
      
min clientr.mud.(@ "min" stat);
      if (
clientr.mud.(@ stat) > max)
        
amt max;
      if (
clientr.mud.(@ stat) < min)
        
amt min;
    }
  }

__________________
Reply With Quote
  #3  
Old 06-30-2007, 09:31 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by killerogue View Post
PHP Code:
      if (stat == "hp" || "mp") { 
Does not do what you think it does.

Quote:
Originally Posted by killerogue View Post
PHP Code:
      if ((makevar("plyr.clientr.mud." stat) - amt) > 0) { 
If amt is negative.... -amt is positive, so (makevar("plyr.clientr.mud." @ stat) - amt) is adding. So, change the - to + and voila.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #4  
Old 06-30-2007, 09:31 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Or just use mine as base.
__________________
Reply With Quote
  #5  
Old 06-30-2007, 09:39 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by Inverness View Post
Or just use mine as base.
It's probably a bad idea to have variables with names min and max.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #6  
Old 06-30-2007, 09:47 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Tolnaftate2004 View Post
It's probably a bad idea to have variables with names min and max.
Easy enough to change.
__________________
Reply With Quote
  #7  
Old 06-30-2007, 10:12 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
tem.plry = 0;? :P
__________________
Do it with a DON!
Reply With Quote
  #8  
Old 06-30-2007, 10:14 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by zokemon View Post
tem.plry = 0;? :P
I noticed that too :P
*coughrookiecough*
__________________
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:50 PM.


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