Newbie scripting help

Posted by Jetpig on Fri 08 Oct 2004 11:38 PM — 3 posts, 13,293 views.

#0
I'm trying to write a script that changes my title after every mob I kill. I've got 2 triggers set up to retrieve my experience to the next level. The first trigger fires when i kill a mob and sends the word group. This displays the members of my party in a format that looks like:

[ 99 Arc] Synamyn 2459/2459 hp 3400/3796 mana 1940/1940 mv 1685 xp2go


The next trigger fires on seeing that. It sends the Level variable (99 in this case)the xp2go variable (1685 in this) to a script:

sub OnLevel (a, b, c)
cInt exp

SetVariable "level", "%1"
SetVariable "tnl", "%8"


if level = 99
exp = tnl + 5000
end if

if level = 100
exp = tnl + 2500
end if

if leve = 101
exp = tnl
end if

send "title has |i|y" exp "|b exp to |mhero!|n"

End Sub


I get an error bugging about the line if level = 99:

Error number: -2146827271
Event: Execution of line 1158 column 14
Description: Expected 'Then'
Line in error:
if level = 99
Called by: Immediate execution


I'm sure it's some newb error. but as this is really my first script, i'm not surprised
USA #1
Few problems. Make sure you read my last paragraph, since its the biggest problem youll have.

If (conditional) Then
Stuff
End If

For your 101 youll need to fix "leve" to level.

And then send line:
send "title has |i|y" & exp & "|b exp to |mhero!|n"

And you can simplify that whole thing:
((101-%8) * 2500) + %1) is your exp to go.

You could do:

send "title has |i|y" & ((101-%8) * 2500) + %1) & "|b exp to |mhero!|n"

And do that whole thing.

That eliminates the need to store TNL and level to a variable, unless of course, youre setting variables to use in other scripts.

Now, your BIGGEST problem is. You cant use %X in a script, since it doesnt exist. You need to use your array of variables (in your case 'c').
To use %1 and %8, you need to put your script routine (minus the sub/end sub) in the "send" box of your trigger, and change the "send to:" pulldown menu to script.
The latter (inside the trigger, not the script file) is the preferred method when feasible.
Amended on Sat 09 Oct 2004 01:37 AM by Flannel
#2
Thank you a ton. *scampers off to try it out*