NPC script help requested

chimera

LOMCN VIP
VIP
Jul 30, 2003
1,054
23
235
UK
Help please :)

I like to challenge myself - I've tried this on my own and it keeps coming out with "You havn't enough integrals" - where am I going wrong?


;;;;;;I have made new field in tbl_char called FLD_INTEGRAL- same format as gold, ie integer, etc...

[@main]

#say
do you want to buy anything with integrals?\\
<yes/@yes> <no/@exit>

[@yes]
#say
what do you want to buy?\\
<Vitality Potion Integral/@getit(VitalityPotion,10)>\

[@getit()]
#act
mov a2 %arg(1)
mov d1 %arg(2)
#say
are you sure?\
<yes/@getit2> <no/@exit>

[@getit2]
#act
mov %a0 %username
formatstr "FLD_CHARACTER='%s'" %a0
readvaluesql "TBL_CHARACTER" %a9 "FLD_CHARACTER,FLD_INTEGRAL" [@si1]
close

[@si1()]
#act
mov d2 %arg(2)
#if
elarge d2 %d1
#act
mov a0 %a9
goto @si2
#elsesay
You havn't enough integrals\\
<exit/@exit>

[@si2]
#act
give %a9
formatstr "fld_character='%s'" %a0
dec d2 %d1
formatstr "fld_integral='%s'" %d2
updatevaluesql "tbl_character" %a0 %d2
#say
You have aquired <$output/%a9>\\

<buy something else/@buy>
<exit/@exit>
 

idaBigA

Holley Mir 3!!
VIP
Oct 28, 2003
1,966
110
310
Stoke, UK
[@getit2]
#act
mov %a0 %username
formatstr "FLD_CHARACTER='%s'" %a0
readvaluesql "TBL_CHARACTER" %a9 "FLD_CHARACTER,FLD_INTEGRAL" [@si1]
close
[@getit2]
Mov A0 %USERNAME ;No % on the first variable
FormatStr "FLD_CHARACTER='%s'" %A0
ReadValueSQL "TBL_CHARACTER" %A9 "FLD_CHARACTER,FLD_INTEGRAL" [@si1] ;I assume you have added a field in the CHARACTER Table called FLD_Integral
;Close not needed

[@si1()]
#act
mov d2 %arg(2)
#if
elarge d2 %d1
#act
mov a0 %a9
goto @si2
#elsesay
You havn't enough integrals\\
<exit/@exit>
All OK apart from this line.. not needed at all as A9 is empty and A0 should contain your USERNAME which you don't want to overwrite :)
mov a0 %a9

And this line.. variables reversed
elarge d2 %d1
Should be
ELarge D1 %D2

[@si2]
#act
give %a9
formatstr "fld_character='%s'" %a0
dec d2 %d1
formatstr "fld_integral='%s'" %d2
updatevaluesql "tbl_character" %a0 %d2
#say
You have aquired <$output/%a9>\\

<buy something else/@buy>
<exit/@exit>
This one is a bit messed up.. see below for fixed version (Assuming the you do have a field called FLD_Integral in the TBL_CHARACTER Table

Code:
[@si2]
#ACT
   Give  %A2
   FormatStr "FLD_CHARACTER='%s'" %USERNAME
   Mov  A8     %A9
   Dec  D2    %D1
   FormatStr "FLD_INTEGRAL='%s'" %D2
   UpdateValueSQL "TBL_CHARACTER" %A8 %A9
#SAY
   You have aquired <$output(A2)>\\
   <Buy Something Else/@Buy>\
   <Exit/@exit>\\[/QUOTE]
 
Upvote 0

chimera

LOMCN VIP
VIP
Jul 30, 2003
1,054
23
235
UK
Thank you :D

Except:

And this line.. variables reversed
elarge d2 %d1
Should be
ELarge D1 %D2


That was the right way round originally :)

Anyway all working now :D :bounce:
 
Upvote 0

Coly

LOMCN Developer
Developer
Mar 31, 2005
1,399
33
195
Germany
To understand for all ...

ELarge is >=
Large is >
ESmall <=
Small <
EQUAL =

DEC -
INC +

Mov X %Y Move the Value from Y to X

Most Problem is 0 , in most things you need check 0 at first.
 
Upvote 0