ID:1746065
 
So I am trying to make a Challenge system on my game, but I keep getting errors about how i'm using wrong indention and stuff

mob
verb
Challenge(mob/playerM in world)
set hidden = 1
if(M ==usr)
usr<<"[world] You can not Challenge yourself."
return
else
challengee = usr
challenger = M
sleep(600)
M<<"Chicken"
usr<<"They Chickened out."
challengee=null
challenger=null


The compiler isn't lying—your indentation is way off. To start with, none of your statements should be aligned with the verb keyword or your verb declaration.
You also wrote mob/playerM, when I see you using M.
I'm sorry, I am just stressing out over this. I have not been having a god few days with coding.
Try this as FKI said but im not sure if you caught on you used
mob/playerM

your supposed to put a / between player and M
mob/player/M

mob
verb
Challenge(mob/player/M in world)
set hidden = 1
if(M ==usr)
usr<<"[world] You can not Challenge yourself."
return
else
challengee = usr
challenger = M
sleep(600)
M<<"Chicken"
usr<<"They Chickened out."
challengee=null
challenger=null
In response to Bebi Tuf
That sleep() call will cause an error, too. It doesn't work like spawn(), so you don't need to indent the code under it. The else statement will also cause one, as there is no preceding if statement on the same indentation.

As for how the system works, it currently doesn't actually do much of anything.

Here's my quick rendition:
mob
player
var
challengee // this is our accepted challenge mob
challenger // this is our requesting challenge mob

verb
Challenge(mob/player/M in world) // make a list of all mobs of type /mob/player/ in world
//set hidden = 1
if(!src.challengee && !src.challenger && !M.challenger && !M.challengee) // checks to make sure neither of you are in a challenge/being challenged
if(M == src) // if your target is yourself
src << "You cannot challenge yourself!"
else
src.challenger = M // mark your request mob as your target
M.challenger = src // mark their request mob as you
spawn() // spawn their challenge alert
M.GetChallenged(src)
var/timer = 600 // 60 second timer (the sleep() below is in 1/10ths of seconds)
while(src && src.challenger && src.challenger == M && M.challenger == src && timer) // each tick make sure all of these are true
sleep(1) // wait 1/10th of a second
timer -- // reduce timer by 1
if(M.challenger == src) // this will happen AFTER while() escapes (ends) [check if challenge wasn't accepted in time]
src << "[M] hasn't responded to your challenge so it has expired!"
M << "You didn't respond to [src]'s challenge so it has expired!"
src.challenger = null // reset both your request mobs
M.challenger = null // ^^^^^^^^^^^^^^^^^^
else // reasons why the challenge couldn't work
if(src.challenger) // you have a challenge request inbound/outbound
src << "You have a challenge pending already! Deal with that one first!"
else
if(src.challengee) // you are already in a challenge
src << "You are already participating in a challenge!"
else
if(M.challenger) // your target has a challenge request inbound/outbound
src << "This person already has a pending challenge!"
else
if(M.challengee) // your target is already in a challenge
src << "This person is already participating in a challenge!"

proc
GetChallenged(mob/player/M)
switch(alert(src, "[M] has challenged you! Do you accept?", "", "Yes", "No")) // make switch() statement with an alert() options menu
if("Yes") // if they press Yes
if(src.challenger == M && M) // make sure the challenge hasn't expired
src << "You have accepted [M]'s challenge!"
M << "[src] has accepted your challenge!"
src.challengee = M // set accepted mob as each other
src.challenger = null // ^^^^^^^^^^^^^^^
M.challengee = src // reset both your request mobs
M.challenger = null // ^^^^^^^^^^^^^^^
// do challenge accepted stuff here
else
src << "The challenge offer has expired, try again!"
if("No") // if they press No
if(src.challenger == M && M)
src << "You have declined [M]'s challenge!"
M << "[src] has declined your challenge!"
src.challenger = null // reset both your request mobs
M.challenger = null // ^^^^^^^^^^^^^^^^^^
else
src << "The challenge offer has expired, try again!"

It's not thoroughly tested, and I would do it much different for my own projects, but comparing this to the original you should notice that there was a lot of logic missing from the original code.
In response to Reformist
This system would utterly fall apart when 2 people challenge the same person before that person can respond to the first challenger. Thus is the problem when trying to use just a single variable for a whole concept that's in need of its own class.
In response to Spunky_Girl
if(!src.challengee && !src.challenger && !M.challenger && !M.challengee)


You can't challenge someone who's already been challenged, so that instance would never happen.

But I agree, as I said, I would do it much different for my own projects.