Variable - Not saving after loggin in out

Bon

Legend
Legendary
Jul 29, 2004
6,741
342
330
Kent, UK
k so read through the variable guide, and understood it all mostly

everything works fine, like checks how many u killed, and when u killed them it gives prize etc. if i complete the quest then log in and out npc is all fine etc

however..... if im half way through the quest, and i log in and out, then refer back to the NPC, it says 'variable not found'
and m2 server says this

[03/03/2008 11:43:21] [Npc Condition Error] Cmd:CHECKVAR NPC:PetTamer Map:0 (321:274) Param1:Human Param2:SCKilled Param3:> Param4:19 Param5:

this is the npc script im usin...

[@main]
#IF
checknamelist CompleteSCQuest.txt
#SAY
You have already completed this quest
#ELSEACT
goto @main1
[@main1]
#IF
checknamelist SCquest.txt
#ACT
goto @quest1
#ELSESAY
Hello <$USERNAME> welcome to the beginners quest. \
To complete this quest you need to kill 20 scarecrows. \\
<Attempt the quest/@attempt> \
<Not now thanks/@exit>
[@attempt]
#IF
#ACT
addnamelist SCquest.txt
SET [300] 1
Var Integer Human SCKilled
#SAY
Good luck, come back to me to check \
how many scarecrows you have killed. \\
<Exit/@exit>
[@quest1]
#IF
CheckVar Human SCKilled > 19
#ACT
give ShortSword 1
addnamelist CompleteSCQuest.txt
#SAY
Well done, you have killed enough scarecrows! \
Take this reward. \\
<Exit/@exit> \
#ELSESAY
Number of scarecrows killed : <$HUMAN(SCKilled)> \\
<Exit/@exit>

so the

#IF
CheckVar Human SCKilled > 19

isnt workin properly... right?

yet if i check the variables it says...

[PureOldSkool]
SCKilled=29



have i gotta put soemthing for the Param5:? i tried this

#IF
CheckVar Human SCKilled > 19 ..\QuestDiary\Variables\Integral.txt
but still wasnt workin

also qmanage has this

[@Login]
#ACT
Var Integer Human SCKilled
LoadVar Human SCKilled ..\QuestDiary\Variables\Integral.txt

and qfunction has this

[@onKillMob(Scarecrow)]
#ACT
CalcVar Human SCKilled + 1
SaveVar Human SCKilled ..\QuestDiary\Variables\Integral.txt


any ideas/help please and tys!!!


i thought if icant find a solution... maybe add a custom comand like @resetquest to qfunc that does something liek this

[@restartquest]
#ACT
Var Integer Human SCKilled
SaveVar Human SCKilled ..\QuestDiary\Variables\Integral.txt

that basically resets it back to 0 so u start over again right? :x
 
Last edited:

lewis

LOMCN Veteran
Veteran
Jan 15, 2004
327
0
43
Southampton
i also have a problem with mine similar to this. Works on some mobs but gets stuck halfway through. I will be looking into it, if i can fix it i will show you my script.
 
Upvote 0

Bon

Legend
Legendary
Jul 29, 2004
6,741
342
330
Kent, UK
found another way around it aswell

changed the qfunction to

[@onKillMob(Scarecrow)]
#ACT
Var Integer Human SCKilled
CalcVar Human SCKilled + 1
SaveVar Human SCKilled ..\QuestDiary\Variables\Integral.txt

so if you log in and otu half way thro... u talk 2 NPC it says "variable not found" but then u go kill a few scarecrows and it will reset the variable back to 0 and go frm there

got a feelin the loggin on bit is wrong
 
Last edited:
Upvote 0

Bon

Legend
Legendary
Jul 29, 2004
6,741
342
330
Kent, UK
nvm i dont think it will save when u log out, so ive worked around it with NPC script

altho if ne1 knows why it aint saving / loadin or knows how to fix would still be good for longer quests, as restartin every time u log in out is kinda gay
 
Last edited:
Upvote 0

NewHope

Golden Oldie
Golden Oldie
Nov 18, 2005
1,311
28
184
Its to do with the Q-Manage and where you place that actual script in that file, don't place it first or last. Try and place it in the middle of the Q-Manage, is how i fixed mine. :)
 
Upvote 0

Bon

Legend
Legendary
Jul 29, 2004
6,741
342
330
Kent, UK
yer ur right... i deleted everything from qmanage and just left the login bit and it works now ><
 
Upvote 0

Liandrin2

Golden Oldie
Golden Oldie
Loyal Member
Jan 14, 2004
890
6
105
Your problem is that the @login bit isn't running for some reason as the error your getting is due to the variable not existing.

You can tell as changing the bit to
[@onKillMob(Scarecrow)]
#ACT
Var Integer Human SCKilled
CalcVar Human SCKilled + 1
SaveVar Human SCKilled ..\QuestDiary\Variables\Integral.txt

means that it's recreating the variable.

Not sure why, but you need to figure out whats up with @Login

Edit: oops, too late ;D
 
Upvote 0

Bon

Legend
Legendary
Jul 29, 2004
6,741
342
330
Kent, UK
its as newhope said,

with nothing but that script login script in the qmanage = everything works fine

at start of qmanage = dont work at all

half way down = doesnt say "variable not found" but does reset it...


bit silly rly lol -_-
 
Upvote 0

Killmaster

Legend
Legendary
Golden Oldie
Loyal Member
Nov 13, 2003
3,967
27
274
As far as I was aware... the variables didnt save once you relogged anyway.
 
Upvote 0

Liandrin2

Golden Oldie
Golden Oldie
Loyal Member
Jan 14, 2004
890
6
105
Well, there should be ways around it. You don't really need to create the variable on login.

What if it was create every time you talked to the npc or killed the mob? i can't see why that wouldn't work. E.g:

For npc
[@main]
#IF
checknamelist CompleteSCQuest.txt
#SAY
You have already completed this quest
#ELSEACT
Var Integer Human SCKilled
LoadVar Human SCKilled ..\QuestDiary\Variables\Integral.txt
goto @main1
[@main1]

And for the kill mob
[@onKillMob(Scarecrow)]
#ACT
Var Integer Human SCKilled
LoadVar Human SCKilled ..\QuestDiary\Variables\Integral.txt
CalcVar Human SCKilled + 1
SaveVar Human SCKilled ..\QuestDiary\Variables\Integral.txt

Might need some editing on the NPC as I cba to recheck it would work, but in theory just loading the Var when it's needed should be fine.

Or, is there anyway around the @Login problem?
Maybe try:
[@Login]
#act
goto @loadvars

[@loadvars]
etc

Thats a wild guess as I've never seen this bug, but maybe worth a try.
 
Last edited:
Upvote 0

Bon

Legend
Legendary
Jul 29, 2004
6,741
342
330
Kent, UK
yer theres a few ways of doin it

ill either put all my login stuff (its only for titles and few other things) into the tele npc and keep my qmanage with only the variables stuff

or ill add the load to the npc, always ways around it
 
Upvote 0