ID:157423
 
I am trying to make a bounty system so that when I open up the tab it will show me and respawn in a certain amount of time but it shows nothing (and it isnt the icon or icon_state being masked/not there). Advice/comments please!

mob
var/Bounty = 100
var/hasbounty = 0

Stat()
statpanel("Bounty")
verb/switchbounty()
if(src.hasbounty == 0)
src.hasbounty = 1
else if(src.hasbounty == 1)
src.hasbounty = 0
mob/proc/HasBounty()
for()
if(src.Bounty>0)
src.hasbounty = 1
sleep(100)
..()
mob/proc/BountyCheck()
for()
if(src.hasbounty == 1)
statpanel("Bounty") << "<BIG>\icon[usr]</BIG> Bounty:[src.Bounty]"
sleep(300)
..()
else if(src.hasbounty == 0)
return
Those for() loops are the start of those two procs are just going to sit there, looping infinitely and doing nothing, as nothing is within them.

Additionally, statpanel() is invalid outside of Stat(), and the syntax you're using there is DEFINITELY not correct.

Also, why would you even have that HasBounty() proc? If hasbounty is to always be 1 if Bounty isn't 0, then why bother having it at all? Just use Bounty instead.

Really, there's no reason for you to have any loops here whatsoever. Whenever you change somebody's Bounty variable, and it was previously 0, add them to some list. Have Stat() display that list. Done.
In response to Garthor
I was trying to get it to not display if the person didn't have a bounty at all. I'll try to set up a list, they are a pain I havn't really got the jist of them yet!
In response to Garthor
/=...Still broken.

world/New()
for(var/mob/M)
if(istype(M))
if(M.mybounty==1)
BL.Add("<BIG>\icon[usr]</BIG> Bounty:[M.mybounty]")
sleep(100)
..()
mob
Stat()
statpanel("Bounty",BL)
var/list/BL()
mob/var/mybounty = 150
In response to Darkjohn66
Yes, that is because you are looping through every mob in the world once, at startup, then checking if they're a mob (hint: they are), and then blah blah blah abusing usr whatever point is: you do not need a loop for this. Ever. At any point. Let me repeat what I said earlier:

Have a list. Call it "duders".
When a player has their Bounty changed, if the bounty was 0, add them to the duders list.
Now, in mob/Stat(), display the duders list.

That's it.
In response to Garthor
Where should I make the bounty be constantly checked to see if it has changed.
In response to Darkjohn66
I am getting a runtime error with null.Add()

mob
Stat()
statpanel("Bounty",BL)



var/BL[]

mob/var/listexists = 0
mob/proc/bountycheck()
if(src.bounty!=0)
BL.Add("<BIG>\icon[src]</BIG> Bounty:[src.bounty]")
src.listexists = 1
..()
else if(src.bounty==0&&src.listexists==1)
BL.Remove("<BIG>\icon[src]</BIG> Bounty:[src.bounty]")
..()
mob/verb/test()
src.bounty+=1

mob
var/stunned = 0
Move()
if(src.stunned == 1)
return
else
bountycheck()
..()


Edit-Finished. I am still calling it in move just for testing but I am going to make a deathcheck one. Right now it doesn't update but I will fix that.

var/BL[0]

mob/var/listexists = 0
mob/var/isset = 0
mob/proc/bountycheck()
if(src.bounty!=0&&src.isset==0)
BL.len+=1
BL.Add(src,"Bounty:",src.bounty)
src.listexists = 1
src.isset=1
..()
else if(src.bounty==0&&src.listexists==1&&src.isset==1)
BL.len-=1
BL.Remove(src,"Bounty:",src.bounty)
src.listexists=0
..()
mob/verb/test()
src.bounty++
src << "Your bounty is [src.bounty]"
In response to Darkjohn66
That is because BL is null, because you never assigned it a value.

Additionally, you should not be constantly checking bounty. The only time you ever need to check bounty is when it changes. As gremlins are not screwing around with your damn game, you are in complete control of when the variable changes, so you can just throw in the check THERE.