ID:163917
 
I set up a system like this:
mob
verb
Say(T as text)
view() << "[src] says: [T]"
admins << "[src] says: [T]"

I am trying to make it if someone said something, it would be sent to the view and admins in case it was something against the rules. How can I do that?
Here's one way of doing it..
mob
verb
Say(T as text)
view(10//why no number here) << "[src] says: [T]"
for(var/mob/m in world)
if(m.gm) //or whatever makes them a gm
m << "[src] says: [T]"


Personally, I wouldn't want to be spammed by what the players were saying. If it was inappropiate, other players should tell you or you could just keep a text log.(you can most likely find out how to do on the hub)


Okay, here is an example of what you can do. But its not recommended because you will be spammed if your game has a lot of people on.

mob
verb
Say()
var/a = input("")as text
view(usr)<<"[usr] says: [a]"
for(var/mob/M in world)
if(M.gm) //or whatever var makes them a GM
M<<"++NIV: [usr] says: [a]" //++NIV is so that you can tell if its coming from someone in view or not




However, this one is recommended. I set up a code you can use for admins so that if they toggle the verb, they can start hearing view chat, and toggling again will deactivate it. You'll have to edit the variables of this code to match your own game.

mob/var/toggled
mob/admin
verb
Toggle()
if(usr.toggled)
usr.toggled=0
usr<<"You toggle on."
if(!usr.toggled)
usr.toggle=1
usr<<"You toggle off."
mob
verb
Say()
var/a = input("")as text
usr.view()<<"[usr] says: [a]"
for(var/mob/M in world)
if(M.toggled) //if the admin toggled that they can hear view say
M<<"++ViewHear: [usr] says: [a]"


If you want, I can help you set up a chat log like Mecha said that only admins can read. Reply to this message telling me if you want me to.
In response to Learned
Learned wrote:

However, this one is recommended. I set up a code you can use for admins so that if they toggle the verb, they can start hearing view chat, and toggling again will deactivate it. You'll have to edit the variables of this code to match your own game.

> mob/var/toggled
> mob/admin
> verb
> Toggle()
> if(usr.toggled)
> usr.toggled=0
> usr<<"You toggle on."
> if(!usr.toggled)
> usr.toggle=1
> usr<<"You toggle off."
> mob
> verb
> Say()
> var/a = input("")as text
> usr.view()<<"[usr] says: [a]"
> for(var/mob/M in world)
> if(M.toggled) //if the admin toggled that they can hear view say
> M<<"++ViewHear: [usr] says: [a]"
>

If you want, I can help you set up a chat log like Mecha said that only admins can read. Reply to this message telling me if you want me to.

The coding is dreadfull for starters you are using usr and your used usr.view() which is totally wrong and why did you define "a" this is an example of what you should do. You also switched the boleen varibles and the on off varible.



mob/var/toggled = 0
mob/admin
verb
Toggle()//Verb name
if(!toggled)//if the user has it toggled off
toggled=1
src<<"You toggle on."
else//if its on
toggle=0
src<<"You toggle off."
mob
verb
Say(msg as text)//Verb Name and Message imput
view()<<"[src] says: [msg]"//sends the message
for(var/mob/M in world)//Loops for players in the word
if(M.toggled) //if the admin toggled that they can hear view say
M<<"ViewHear: [src] says: [msg]"
In response to Miran94
True, youre very right, after reading over it i messed up on usr.view() it should say view(usr). =/ Sorry about that im going to edit my post right now.

but in your code you used src which is unnecessary in verbs, src is more used in procs. usr should be used in verbs as far as i know.

and the way you set up the "msg" var is good for starters but as he gets better he might have to build off of the way i put it, so he might as well learn now.
In response to Learned
Actually usr should never be used excepect if your call a mob proc on a non mob.
In response to Miran94
Wrong. usr fits just fine in verbs. Where usr should never be used is in procs.