ID:262646
 
Code:
turf
no_attack
icon = 'stealth.dmi'
Entered()
usr.verbs-=/mob/verb/Attack


Problem description:k i tried to use return at the end of this to make it so once ur off the turf it goes back to normal and that didnt work, how would i make it so it does come back?

The smartter plan would probably be to use a var to see if the mob could attack or not, rather than taking away verbs, and possibly forgetting to give them back. consider revising this:
turf
no_attack
icon = 'stealth.dmi'
Entered()
usr.verbs-=/mob/verb/Attack

To something similar to this:
mob/var/attack=1
turf
no_attack
icon = 'stealth.dmi'
Entered()
usr.attack=0
Exited()
usr.attack=1

Then just add a check in your attack verb, to set it so that if the mobs attack var is one, they can attack, 0 if they cannot. Also, i belive Entered() and Exited() need to have arguments with them, but im not sure, and im to lazy to check. so u might wanna look that up.
In response to Yattasparagus
It doesn't need any arguments because it defaults to src.
In response to Sinoflife
oh. woops. i guess that my codes right then, if it defaults to src.
In response to Yattasparagus
isnt there another way tho to somehow make an if statement for entered and then else to bring it back??
In response to Yattasparagus
see but i dont wanna do it that way cause then i have to make up a attack = thing for every single attack and that would be a pain, cant i just do it with a if statement
In response to Kurosaki_Ichigo-San
Well, I guess if you insist on doing it by taking away the Attack verb, you could do it like this...
 turf
no_attack
icon = 'stealth.dmi'
Entered()
usr.verbs-=/mob/verb/Attack
Exit() //could also use Exited() I guess?
usr.verbs+=/mob/verb/Attack

.. But I don't like doing it that way, for the same reason stated earlier - You could easily forget to give it back, and have people stuck with no Attack verb at all. Not to mention it's pretty bareboned, doesnt check for what's Entering and Exiting.
In response to Detnom
Detnom wrote:
Well, I guess if you insist on doing it by taking away the Attack verb, you could do it like this...
>  turf
> no_attack
> icon = 'stealth.dmi'
> Entered()
> usr.verbs-=/mob/verb/Attack
> Exit() //could also use Exited() I guess?
> usr.verbs+=/mob/verb/Attack
>

.. But I don't like doing it that way, for the same reason stated earlier - You could easily forget to give it back, and have people stuck with no Attack verb at all. Not to mention it's pretty bareboned, doesnt check for what's Entering and Exiting.

No, no, no, you're abusing 'usr' in Entered()/Exit().
turf/no_attack
icon='stealth.dmi' //<--If it's invis, why do you need an icon file? o.O
Entered(mob/M)
if(M.client) M.verbs-=/mob/verb/Attack
Exited(mob/M)
if(M.client) M.verbs+=/mob/verb/Attack


If you don't know why 'usr' is bad in these procs, read the usr lecture by Lummox JR.
In response to Mega fart cannon
What if a freeflying object tried to enter? It'd give a runtime error. You need to check if it is a mob first before checking it's a client, since an obj doesn't have the client variable. You're assuming it's a mob.

On another note, using turfs for a non-attack zone is not such a good way to do it, since you'd have to program more turfs if you wanted to have noattack in a whole village. Areas are the way to go here.

area/noattack
Entered(mob/M)
if(ismob(M) && M.client)
M.verbs -= /mob/verb/Attack
Exited(mob/M)
if(ismob(M) && M.client)
M.verbs += /mob/verb/Attack


~~> Dragon Lord
In response to Unknown Person
Thanks for correcting me, Dragon.