ID:272384
 
mob
Stat()
statpanel("Votes")
stat("Testing")
stat(/obj/RebootVote)
stat("Testing")


How would I be able to make somthing that If there are no Owners in the world that This stat panel shows up? And how come I cant see the stat(/obj/RebootVote)?
mob
Stat()
for(var/mob/Owners/O in world)//Assuming you coded Owners as mob/Owners
var/obj/RebootVote/P=new()
if(!O)
statpanel("Votes")
stat("Testing")
stat([P]) // I don't know if this will work, it's a long shot in the dark.
stat("Testing")

In response to Andre-g1
Andre-g1 wrote:
mob
> Stat()
> for(var/mob/Owners/O in world)//Assuming you coded Owners as mob/Owners
> var/obj/RebootVote/P=new()
> if(!O)
> statpanel("Votes")
> stat("Testing")
> stat([P]) // I don't know if this will work, it's a long shot in the dark.
> stat("Testing")


Almost got it it would be stat(P) nice try though.
King killer 113711 wrote:
mob
> Stat()
> statpanel("Votes")
> stat("Testing")
> stat(/obj/RebootVote)
> stat("Testing")

How would I be able to make somthing that If there are no Owners in the world that This stat panel shows up?
if(no owners in world)
stat("My Stat Yo")

Initially, since you're a beginner (or at least you're having beginner errors) keep it simple. This would involve keeping track of the owner status (you likely want any GM to disable triggering this, not only the owner, too). You'd probably best do it by keeping a global list of GMs logged in, which would come in use for other things. Basically, you could then check if there are any GMs on by checking the list.

And how come I cant see the stat(/obj/RebootVote)?

Because it's a type path, not an object instance. You really should read this. Get studying with ZBT's tutorials and then the DM Guide, or you're going to be making topics about relatively simple things like this for a long long time.
In response to A.T.H.K
Thanks for the help all of you
In response to A.T.H.K
The issue there wouldn't be quite that, but that doing extensive operations in Stat() itself is a bad idea, as well as the creation of an object per mob (player in this case), due to the fact Stat() is re-called with a frequency of 1-3 ticks or so.
You have to have a reference to the object, not just a typepath.

Also, it's better to have a datum than an /obj for handling votes, as well. I'd set the whole system up like this:
#define WINNER  -1
#define LOSER -2
#define RESULTS -3

proc/CloseVote(votes/v, get = WINNER)
//This closes the votes (by deleting the /votes object),
//and returns whatever you wish it to. By default, it
//returns the winner. It can also choose the loser, or
//just a list of results. If it's not any of these three
//values, the value returns is the value of get (i.e.,
//with a value of 3, it'll return the 3rd place winner).

switch(get)
if(WINNER) . = v.GetWinner()
if(LOSER) . = v.GetLoser()
if(RESULTS) . = v.Sort(v.vote_options)
else . = V.GetN(get)

del v

votes
var
//The question being asked.
query

//This is the amount of options (i.e. "Yes", "No")
list/vote_options
//This is the proc that will query the players.
method

New(q = query, list/options = vote_otpions, m = method)
query = q
vote_options = options
method = m

//If no method is chosen, pick one based on the
//number of arguments.
if(isnull(method))
if(options <= 3)
method = /votes/proc/_alert
else if(options > 3)
method = /votes/proc/_input

query()

proc
Add(r) if(r in vote_options) vote_options[r] ++
GetResult(o) return vote_options[r]

//This gets what is in the Nth place.
GetN(n)
. = Sort(vote_options)
return .[n]

//This outputs the one with the highest votes.
GetWinner() return GetN(vote_options.len)
//This outputs the one with the lowest votes.
GetLoser() return GetN(1)

//This sorts the list.
Sort(list/l)
. = list()

var/list/copy = l.Copy()
while(copy.len)
var/min = min(copy)
. += min
copy -= min

proc/query()
for(var/client/c)
spawn() call(method) (c, query, options, src)

proc/_alert(client/c, query, list/options, votes/v)
switch(options.len)
if(1) . = alert(c, query, null, options[1])
if(2) . = alert(c, query, null, options[1], options[2])
if(3) . = alert(c, query, null, options[1], options[2], options[3])

v.Add(.)

proc/_input(client/c, query, list/options, votes/v)
. = input(c, query) in options
v.Add(.)

//As I believe you're doing a reboot query, this is a
//shortcut.
votes/reboot
query = "Should we reboot?"
vote_options = list("Yes", "No")

//When you wish to query about a reboot, do
//robot_query = new, in your code.
var/votes/reboot/reboot_query

Now, onto your problem with the owner. One way to handle it would be as such:
//This is assuming there is only a single owner.
var
owner_ckey = "billjones" //For an example.
client/game_owner

client
New()
//When the player enters, check to see if their
//ckey is the same as the owner's ckey.
if(ckey == owner_ckey)
//If it is, set the game_owner variable.
game_owner = src

..()

Del()
//Similiar situation as in new.
if(ckey == owner_ckey)
//But in this case, as the player left, the
//variable has to be null.
game_owner = null

..()

Now, to tie it in with your statpanel system:
mob/Stat()
..()

if(game_owner)
//If game_owner is true, meaning the owner is
//currently playing.

statpanel("Votes")
stat("Question:", reboot_query.query)

//Show the "Yes" and "No" votes.
stat("Yes:", reboot_query.GetResult("Yes"))
stat("No:", reboot_query.GetResult("No"))
In response to Popisfizzy
Popisfizzy wrote:
Also, it's better to have a datum than an /obj for handling votes, as well.

His usage of the /obj was obviously pretty much purely for making it initiate-able through a click. Which also can't be done through a datum (only).