ID:264991
 
Code:
mob/proc/detectionbp(mob/m)
var/bp = round(src.scanpct/m.bp*100)
var/bpstop=0
var/bpis=0
while(src.scanning)

if(bpstop>=100)
bpis = m.bp
winset(src,"scouter.bp","text='[m.bp]'")
src<<'scouter.wav'
else
bpstop += src.scanpct
bpis += bp
winset(src,"scouter.bp","text='[bpis]'")

sleep(1)


mob/player/DblClick()

var/html
if(usr.scouter && usr.scanhigh)
view(8)<<'scanning.wav'
//usr.detection(src)
winshow(usr, "scouter", 1)
usr.scanning=1
winset(usr,"scouter.name","text='Name: [src.name]'")
winset(usr,"scouter.race","text='[src.race]'")
if(src.bp>5000000)
winset(usr,"scouter.bp","text='Un-Detectable'")
usr.scanning=0
else //winset(src,"scouter.bp","text='[jru_Commafy(src.bp)]'")
usr.detectionbp(src)


Problem description:
I am trying to make it so when you double click a player that the scouter will start at 0 and raise by your scanpct untill it gets to 100% of the players power. But all it does is repeat the loop as if the bp stop isnt at 100% and it keeps playing the scouter noise every tenth of a second.. Can anyone help me out? I'd greatly appreciate it.
you never identified scanning=0 in your loop
In response to Kaigne
No I did. But that wasn't working either, It still did the same thing.
How about something like this? I changed a few things I guess, of course you can customize the limit of bp it can read and all.
mob/proc/detectionbp(mob/m)
scanning=1
winshow(usr,"scouter", 1)
src<<'scanning.wav'
winset(src,"scouter.name","text='Name: [m.name]'")
winset(src,"scouter.race","text='[m.race]'")
if(m.bp>5000000)
winset(src,"scouter.bp","text='Un-Detectable'")
scanning=0
return
var/read_time=10 //Amount in milliseconds for the bp to be read
for(var/p=0,p<read_time,p++)
winset(src,"scouter.bp","text='[m.bp/read_time*p]'")
sleep(1)
winset(src,"scouter.bp","text='[m.bp]'")
src<<'scouter.wav'
scanning=0


mob/player/DblClick()
if(usr.scouter&&usr.scanhigh)
if(!usr.scanning)usr.detectionbp(src)
In response to Taitz
Awesome. Thanks alot. Appreciate it. I never knew you could use the for() proc in that type of way.
In response to Taitz
Can i ask why the way i had itndidnt work though?
In response to Ss4 core
It is because it continued to loop infinitely, since when it reached 100%, you didn't set scanning to 0.
In response to Taitz
Even when I set it to 0 after it being done it was still doing the same thing.
In response to Ss4 core
mob/proc/detectionbp(mob/m)
var/bp = round(src.scanpct/m.bp*100)
var/bpstop=0
var/bpis=0
while(src.scanning)

if(bpstop>=100)
scanning = 0 //<-- Did you set it here????
bpis = m.bp
winset(src,"scouter.bp","text='[m.bp]'")
src<<'scouter.wav'
else
bpstop += src.scanpct
bpis += bp
winset(src,"scouter.bp","text='[bpis]'")

sleep(1)
In response to Taitz
I know, The one I had up didn't have it, But I put it in there in my source is what I mean.. And it didn't work.. The thing was, was that, when the proc started, it would act as if it was already at 100% and would keep looping the, "if(bpstop>=100)" statement for a couple seconds...