ID:261253
 
I can get two people in my game and not let anyone else in after that just fine, but I need a little help with something else. When a person logs in, I make their Walk var = 0 so they can't move, then when the second person logs in, I make their Walk var = 0 also. I want to make a verb that starts the game, and makes the people's walk var = 1 so they can walk. I can do this, but not the way I want it. I want it so when one of the players clicks the "Start" verb, it asks the other person if they are ready to start, and when he/she agrees, it changes both of the players Walk var to one. Here's what I've made so far...

mob
verb
Start()
usr.Walk = 1

I don't like this because the verb only affects the person that clicks it, obviously, so one person can easily start before the other person does. Can somone point me in the right direction please?
Thank you.
The Wizard of How wrote:
I can get two people in my game and not let anyone else in after that just fine, but I need a little help with something else. When a person logs in, I make their Walk var = 0 so they can't move, then when the second person logs in, I make their Walk var = 0 also. I want to make a verb that starts the game, and makes the people's walk var = 1 so they can walk. I can do this, but not the way I want it. I want it so when one of the players clicks the "Start" verb, it asks the other person if they are ready to start, and when he/she agrees, it changes both of the players Walk var to one. Here's what I've made so far...

mob
verb
Start()
usr.Walk = 1

I don't like this because the verb only affects the person that clicks it, obviously, so one person can easily start before the other person does. Can somone point me in the right direction please?
Thank you.

mob
verb
Start()
for(var/mob/M in world)
switch(M.alert(M,"Do you wish to start?","Start","Yes","No"))
if("Yes")
src.Walk = 1
M.Walk = 1

never use usr inside of mob, you have to always use SRC inside of a mob.

im pretty sure this will work, didnt test it. im a little rusty, and not so good at making code off the top of my head while being rusty =D

FIREking
In response to FIREking
Thank you FIREking, There is a little prob that I can't fix

M.alert:bad proc

What can I do to fix this? Thank you
In response to The Wizard of How
Instead of M.alert use alert(M,"Blah","Blah","Blah")
In response to The Wizard of How
try this

switch(alert(M, "msg", "title", "Yes", "No"))

i forgot that you just call alert, and give the REF before the msg. =D

FIREking
In response to Nadrew
*sigh*
didnt you even read what i wrote!?
thats what i said!
In response to FIREking
They were posted at the same time...
In response to Nadrew
oh lol!
In response to FIREking
One minor problem with your code: The alert() will be called for the user who clicked the verb as well; this is not the desired behavior. You should try something like this:
for(var/mob/player/M in world) if(M!=usr) break

Then go about asking M if they want to start. If they say no, you should have some code to handle that case, returning a message to the person who clicked the verb.

Lummox JR
In response to FIREking
When I use....

mob
proc
Start()
for(var/mob/M in world)
switch(alert(M, "Are you ready to begin?", "Begin", "Yes", "No"))
if("Yes")
src.Walk = 1
M.Walk = 1
if("No")
alert("Hurry up!")

I don't get any errors, but it asks the person who clicked it if they are ready.

Then when I use...

mob
proc
Start()
//line 15 for(var/mob/player/M in world) if(M!=usr) break
//16 switch(alert(M, "Are you ready to begin?", "Begin", "Yes", "No"))
if("Yes")
src.Walk = 1
//19 M.Walk = 1
if("No")
alert("Hurry up!")

I get these errors....

Test.dm:15:error:M:undefined type: M
Test.dm:15:error:M:undefined type: M
Test.dm:16:error:M:bad var
Test.dm:19:error:M.Walk:bad var
Test.dm:16:error::invalid expression
Test.dm:15:M :warning: variable defined but not used

Why does it say M is an undefined type?

In response to The Wizard of How
are you wanting it to ask both users? or just one of them?
In response to FIREking
I only want it to ask ONE user. When the person clicks start, I'm assuming THEY are ready, so I just want it to ask the other player. Then when the OTHER player says "Yes" they can both move.
In response to The Wizard of How

mob
verb
Start()
for(var/mob/M in world)
if(M == src)
break
else
var/list/L = new
L += "Im Ready!"
L += "Im Not Ready!"
var/answer = input(M,"Blah") in L
switch(answer)
if("Im Ready!")
alert("He is ready, lets go!")
if("Im Not Ready!")
alert("He isnt ready...")

try this?
In response to FIREking
I'm going with this....

mob
proc
Start()
for(var/mob/M in world)
switch(alert(M, "Are you ready to begin?", "Begin", "Yes", "No"))
if("Yes")
src.Walk = 1
M.Walk = 1
if("No")
alert("Hurry up!")

I made it so when the first person logs in, they get the "Start" proc. Here's the problem, say the usr tries to move before he clicks the start button. He can't because his walk var is 0, but as soon as he/she clicks the "Start" button, he/she starts off in the direction they hit last, before they even say "Yes" or "No". It is not like this for the other mob that doesn't have the start proc. What is causing this to happen?
In response to The Wizard of How
looks like you need to take out this line:

src.Walk = 1
In response to The Wizard of How
I made it so when the first person logs in, they get the "Start" proc. Here's the problem, say the usr tries to move before he clicks the start button. He can't because his walk var is 0, but as soon as he/she clicks the "Start" button, he/she starts off in the direction they hit last, before they even say "Yes" or "No". It is not like this for the other mob that doesn't have the start proc. What is causing this to happen?

You've got it set up so it STILL asks both players, but any time either player clicks yes, it will automatically give walking to that player AND the person who hit start. As was said before, you need to make the loop skip the person who used the start verb... but break isn't the command you want, because that stops the loop dead. Instead, you can either

1. Indent the whole switch statement and everything inside it over one to the right, and put an if (M != src) at the top, or

2. Just insert an
if (M == src) continue
line right before the switch statement. continue will cause the loop to skip the thing it's currently on and go on to the next thing (break causes it to stop the loop and skip down in the code to the end of your for loop).

This way, only the second player will be asked, and when they hit yes, both players will start simultaneously.