The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function not Checking?!
Author Message
Chukwuemeka
Apprentice
*

Posts: 12
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Nov 2016
Reputation: 0



Post: #1
Function not Checking?!
Hey folks,
I'm editing a level system script and I'm getting a problem.

Code:
[FUNCTION f_levelup]
f_show_xp_title
IF (<TAG0.EXP> >= <TAG0.LEVELUP>)
   SYSMESSAGE @030 You gain a level!
    TAG0.EXP=0
    TAG0.LEVELUP += 1000
    TAG0.MYLEVEL += 1

When I use it with a player, it checks the TAG and works great.

Code:
ON=@DEATHCORPSE
REF1 = <ARGO.MORE2>

IF (<REF1.ISPLAYER>) && (<i.ISNPC>)
    LOCAL.EXP_GAIN=<EVAL ((<i.STR> + <i.DEX>)/5)>
    REF1.TAG0.EXP += <dLOCAL.EXP_GAIN>
    SAY @030 You gain <eval <dLOCAL.EXP_GAIN>> experience.
    REF1.f_levelup
    RETURN 0
ENDIF

Now, I want to make summons and pets give the player EXP. It says I got the right EXP, but I always level up.

Code:
IF (<REF1.FLAGS> & statf_pet) && (<REF1.ISNPC>) && (<i.ISNPC>)
LOCAL.EXP_GAIN=<EVAL ((<i.STR> + <i.DEX>)/5)>
TRY UID.<REF1.MEMORYFINDTYPE.memory_ipet.LINK>.tag0.exp += <EVAL <LOCAL.EXP_GAIN>>
    SAY @030 You gain <eval <dLOCAL.EXP_GAIN>> experience.
    TRY UID.<REF1.MEMORYFINDTYPE.memory_ipet.LINK>.f_levelup
    RETURN 0
ENDIF

It seems to be missing this check (<TAG0.EXP> >= <TAG0.LEVELUP>).
Where am I going wrong?

Thank you!
11-11-2016 03:30 AM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 245
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #2
RE: Function not Checking?!
Probably it's caused by the TRY command, when you use an operator like += Sphere does this:

x += y
x = <eval (x+y)>

So that TRY line becomes:

TRY UID.<REF1.MEMORYFINDTYPE.memory_ipet.LINK>.tag0.exp += <EVAL <LOCAL.EXP_GAIN>>

TRY UID.<REF1.MEMORYFINDTYPE.memory_ipet.LINK>.tag0.exp = <eval (<TRY <UID.<REF1.MEMORYFINDTYPE.memory_ipet.LINK>.tag0.exp> + <EVAL <LOCAL.EXP_GAIN>>)

Anyway, according to the Wiki the TRY is obsolete since 2006, so you can safely remove it.
11-11-2016 09:31 PM
Find all posts by this user Like Post Quote this message in a reply
ShiryuX
Journeyman
*

Posts: 249
Likes Given: 1
Likes Received: 19 in 14 posts
Joined: Mar 2010
Reputation: 4



Post: #3
RE: Function not Checking?!
Maybe you have to go basic at the start of the script.

Code:
ON=@DeathCorpse
if (!<uid.<argo.more2>.isplayer>)
  if <uid.<argo.more2>.memoryfindtype.memory_ipet>
  ref1 = <uid.<argo.more2>.memoryfindtype.memory_ipet.link>
  endif
else
ref1 = <argo.more2>
endif
// your normal gain code.

if your npcs gain level also, just put an "else" after setting the pet link as ref1.
11-12-2016 03:12 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Chukwuemeka
Apprentice
*

Posts: 12
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Nov 2016
Reputation: 0



Post: #4
RE: Function not Checking?!
Thanks a lot! TRY was indeed the problem.
11-13-2016 09:27 PM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)