ID:144023
 
Code:
mob
verb
Request_Reboot()
if(usr.voted==1)//If they voted recently...
usr << "<font color = red>Please wait atleast 3 minutes between votes."
if(usr.voted==0)//If it has been a minute.
usr.voted = 1
usr.rebootreason = input("Why are you rebooting?","Reason","[usr.rebootreason]")//The reboot reason.
if(length(usr.rebootreason)>300)//If it is over 300 letters...
usr << "That reason is to long. You still need to wait a 3 minutes to vote again."
return
else
world << "<b><font color = green>[usr.key] has requested a reboot because '</b><i>[html_encode(usr.rebootreason)]</i>'<b><font color = green> You have 30 seconds to input your vote.</b></font>"//Notice the html_encode? Protects from spam.
for(var/mob/M in world)//For a mob..
M.rvote()//Calls the proc.
sleep(300)//30 seconds
if(rYes==rNo)//If they are equal...
world << "<b><font color = green>There has been a tie. A revote will now occur."
usr.Request_Reboot()
if(rYes>rNo)//If Yes wins
world << "<b><font color = green>Reboot has won! Here is what was voted.<br></b><font color = blue>Yes = [rYes]<br>No = [rNo]"
world.rebootv()
if(rNo>rYes)//If no wins.
world << "<b><font color = green>Reboot has lost! Here is what was voted.<br></b><font color = blue>Yes = [rYes]<br>No = [rNo]"
rNo = 0
rYes = 0
return
sleep(1800)//3 minute delay.
usr.voted = 0

mob
proc
rvote()//Everything in this proc is obvious.
switch(alert("Would you like a reboot?","Reboot voting.","Yes","No"))
if("Yes")
rYes+=1
if("No")
rNo+=1


Problem description:
The problem is on the for(mob/M in world).....There were 2 other people logged in plus me. I did that proc, and I got the alert 3 times...They didn't get it.

You want to call it to every client/C in world, not mob/M in world.
In response to Derekjeterisgod
Let me try it...
In response to Derekjeterisgod
Ok, I did, but then the alert didn't pop up to anyone. So I made if(!M.client) which I must say thanks for making me do that, but my original problem still exist.
To quote Lummox JR, "No put usr in proc. Ungh."

alert() has usr as a default argument.
In response to Jon88
I see....Hmm...Should I switch it to a hidden verb or something?
In response to Revojake
Revojake wrote:
I see....Hmm...Should I switch it to a hidden verb or something?

No, you should just use the appropriate argument, instead of usr.
In response to Jon88
So, switch from usr to src in switch(alert("Would you like a reboot?","Reboot voting.","Yes","No"))
?

How would I?
In response to Jon88
Oh, would it be src.rvote()...Let me try that
In response to Jon88
Ok, maybe that is not what you meant because it still didn't work.
In response to Revojake
Look up alert() in the reference. It'll show you how to call it for whoever you want instead of the default (which is usr).
In response to Revojake
The reason for that is that clients are part of the world. You want for(var/client/C) instead of for(var/client/C in world) (if you want to loop through clients that is).
In response to Revojake
alert(Usr=usr,Message,Title,Button1="Ok",Button2,Button3)

Use M instead of usr...
In response to Abhishake
I read it and the only thing I could see is the Usr=usr...So Usr=src may work...
In response to Bobthehobo
mob
proc
rvote(mob/M)//Everything in this proc is obvious.
switch(alert(M,"Would you like a reboot?","Reboot voting.","Yes","No"))
if("Yes")
rYes+=1
return
if("No")
rNo+=1
return

Well...Now it won't show the alert.
In response to Revojake
Revojake wrote:
I read it and the only thing I could see is the Usr=usr...So Usr=src may work...

Or just plain old src.

alert("Hi") = alert(usr, "Hi")
In response to Jon88
Thanks alot Jon! It just shows me that one word changes it all.
for(var/mob/M in world)
spawn() M.rvote() //Spawn it! :-)

Thats the reason its only sending it to you, I'm not sure exactly why it never loops through the mobs the other way. But I know it has something to do with the fact that it has to run through M.rvote() before it can go back through the loop.

-KirbyAllStar
In response to KirbyAllStar
mob
proc
Vote()
if(alert(src,"Reboot","Vote To Reboot","Yes","No")=="Yes")
return 1
return 0
mob/verb/Reboot()
unique = new
if(!canvote) return
canvote = 1
var/neededvotes
var/totalvotes
for(var/client/C)
if(C.address in unique) continue
unique.Add(C.address)
neededvotes++
totalvotes += C.mob.Vote()
neededvotes >>=1
if(totalvotes > neededvotes)
world.Reboot()
else
world << "We need [neededvotes - totalvotes] more votes to reboot"
world << "You can reboot in [votetime] minutes"
var/const/votetime = 20 // 20 minutes
var/canvote = 1
var/list/unique
proc
VoteTimer()
sleep(votetime*600)
canvote = 1

Now people cant multikey.