ID:146186
 
Code:
    QuestCheck(var/mob/U)
if(U.QP >= U.QPN)
U << "[U.name] you gain a quest level!"
U.rating += 1
U.QP = 0
U.QPN += rand(10,15)
return 0


Problem description:
Debug says if(U.QP >= U.QPN) is a problem, QP is total quest points and QPN is quest points to next level and rating is just the integer of the level.

Could ya post the error? Also, what is the parent type of QuestCheck?
In response to Artekia
obj/KS
Kingsslime
name = "Kings Slime"
icon = 'monsters.dmi'
icon_state = "KS"
density = 1
verb
Catch()
if(usr.startedks == 0)//if they dont have the dog
usr << "This is an odd looking slime?"
return
if(usr.foundks == 1)//if they dont have the dog
usr << "You have caught the slime already!"
return
else
set src in oview (1)//if the dog is right next to the usr
usr << "<font color = blue>You catch the kings slime....Bring it to the king!"
Move(usr)//put it in the inventory
usr.KS = 1//says that the usr caught the dog



and the error is a runtime..

runtime error: Cannot read null.QP
proc name: QuestCheck (/proc/QuestCheck)
source file: battle sys.dm,271
usr: Test (/mob/player)
src: null
call stack:
QuestCheck(null)
Kings Quest(Test (/mob/player))
use(Test (/mob/player))
Test (/mob/player): Talk()
In response to Derekjeterisgod
Where are you calling QuestCheck? I'm thinking that your problem lies there.
In response to Audeuro
Audeuro wrote:
Where are you calling QuestCheck? I'm thinking that your problem lies there.

QuestCheck is the quest level proc
In response to Derekjeterisgod
Derekjeterisgod wrote:
Audeuro wrote:
Where are you calling QuestCheck? I'm thinking that your problem lies there.

QuestCheck is the quest level proc

I know, I didn't ask what it was, I asked you to show where all you call it. I'm thinking you passed an invalid argument, or perhaps you forgot to pass an argument.
In response to Audeuro
proc/findks()
set name = "Kings Quest"
set src in oview(1)
if(usr.foundks == 1)
return
if(usr.KS == 0)
if(usr.asked == 0)
switch(input("Would you like to do a quest for me?","QuestGuy") in list ("Yes","No"))
if("Yes")
usr << "I need you to get my slime for me."
usr.asked = 1
usr.startedks = 1
if("No")
alert("Ok")
if(usr.asked == 1)
usr << "Please, look for my slime!"
else
var/U
usr << "Thanks for finding my slime"
usr.QP += 5
usr.foundks = 1
usr.completedks = 1
QuestCheck(U)
usr.gold += 100
var/obj/KS/P
for(P in usr.contents)
del(P)
In response to Derekjeterisgod
Derekjeterisgod wrote:
proc/findks()
> set name = "Kings Quest"
> set src in oview(1)
> if(usr.foundks == 1)
> return
> if(usr.KS == 0)
> if(usr.asked == 0)
> switch(input("Would you like to do a quest for me?","QuestGuy") in list ("Yes","No"))
> if("Yes")
> usr << "I need you to get my slime for me."
> usr.asked = 1
> usr.startedks = 1
> if("No")//if they pick no
> alert("Ok")
> if(usr.asked == 1)
> usr << "Please, look for my slime!"//give them the question
> else
> var/U
> usr << "Thanks for finding my slime"
> usr.QP += 5
> usr.foundks = 1
> usr.completedks = 1
> QuestCheck(U)
> usr.gold += 100
> var/obj/KS/P
> for(P in usr.contents)
> del(P)
>


There's your problem. U isn't a mob. I think you want to remove U altogether and pass usr instead.
In response to Audeuro
If you call it with another proc, you may want to use M.findks() . Why not make the proc mob/proc/findks() ? That way the proc can belong to a person. This would help clear things up for you.
In response to Audeuro
Audeuro wrote:
There's your problem. U isn't a mob. I think you want to remove U altogether and pass usr instead.

Then it causes a synthax error, a mob has to be defined for it to call the proc
In response to Derekjeterisgod
Derekjeterisgod wrote:
Audeuro wrote:
There's your problem. U isn't a mob. I think you want to remove U altogether and pass usr instead.

Then it causes a synthax error, a mob has to be defined for it to call the proc

Have you even tried it? It shouldn't cause a syntax error as long as usr is type /mob.
In response to Rockinawsome
Rockinawsome wrote:
If you call it with another proc, you may want to use M.findks() . Why not make the proc mob/proc/findks() ? That way the proc can belong to a person. This would help clear things up for you.

i call findks with

if(istype(a,/turf/Quests/King))
call(/proc/findks)(U)

so you have to talk to the king to get the findks quest

i gtg, be on shortly, keep posting i gotta fix this problem
In response to Derekjeterisgod
Dude, you don't understand.

You're getting this runtime error because you're doing this:

var/U
QuestCheck( U )


You're passing a var, but it's not the correct type of var. If you check QuestCheck, it's asking for a var of type /mob, which you aren't giving it.


What you aren't understanding is that "U" IS NOT A MOB and "U" IS NULL.
In response to Audeuro
var/U
QuestCheck( U )
= Bad
QuestCheck(src)
</B>
= Good

Also.. The person that suggested putting usr in there, bad...
It was a proc() in procs, as long as you call the user as an argument, src will be good.

Example
<dm>
mob/Login()
Panda(src)//SRC is the person that's loging in and passes it through Panda

mob/proc/Panda()
world<<"[src] loves Mr. Panda!"
In response to Flame Sage
Why are you doing "src.Panda(src)"? =p
In response to Flame Sage
Flame Sage wrote:
var/U
QuestCheck( U )
= Bad
> QuestCheck(src)
> </B>
> = Good
>
> Also.. The person that suggested putting usr in there, bad...
> It was a proc() in procs, as long as you call the user as an argument, src will be good.
>
> Example
> <dm>
> mob/Login()
> Panda(src)//SRC is the person that's loging in and passes it through Panda
>
> mob/proc/Panda()
> world<<"[src] loves Mr. Panda!"
>


Thanks, it worked