ID:1445557
 
(See the best response by Ter13.)
How do i make a bot that helps me with the admin system for example i can say

DarklightX: Sam ban Uroper12 24 reason: No Reason
Sam: Uroper12 has been banned for 24 hours for no reason
Uroper12 logs out

How do i make a admin system like that that checks the key of the user that says that to make sure is a admin and has a lot of commands

DarklightX: Sam is stupid
Sam: DarklightX has been booted by Sam reason: Hurting my feelings.

You probably need to use findtext() and copytext() to do that, it's not that useful from my point of view though, you should just find an effective way to organize your admin verbs.
I'm having a trouble looking for the name of a person within the text the admin says.
This doesn't seem to work

mob
verb
OOC(var/t as text)
world << "[src.name]: [t]"
if(findtext(t, "Sam"))
if(findtext(t, "ban"))
if(src.Admin == 1)
for(M as mob in world)
if(findtext(t, M))
world<<"Sam: [M] has been banned"


loading SAO.dme
loading Graphics\Skin.dmf
Coding\Verbs.dm:8:error: M: undefined var
Coding\Verbs.dm:9:error: M: undefined var
SAO.dme:23:error: M: undefined var
SAO.dmb - 3 errors, 0 warnings
I know this may not solve the problem full stop but the reason you are getting the errors is explained in the code below.

mob
verb
OOC(var/t as text)
world << "[src.name]: [t]"
if(findtext(t, "Sam"))
if(findtext(t, "ban"))
if(src.Admin == 1)
for(var/mob/M in world)//your problem was here you forgot to define M as a variable.
if(findtext(t, M))
world<<"Sam: [M] has been banned"
Best response
You are more than likely going to want to create a string tokenizer. and parser.

var
chatbot/bot
mob
verb
say(msg as text)
if(lowertext(copytext(msg,1,4))=="sam")
bot.parse(src,lowertext(msg))
world << "[src]: [msg]."

#define get_token(x,y) (copytext((x),(y),findtext((x)," ",(y),0)))

chatbot
var
list/reactions = list("is"="selfReference","kick"="kickTask","ban"="banTask")
proc
parse(mob/speaker,msg)
var
place = 4
t = get_token(msg,place)
place += length(t)+1
if(length(t))
switch(t)
if(",")
if(length(msg)==4)
addressed()
return
if("'s")
if(length(msg)==4)
confused()
return
if("?")
if(length(msg)==4)
addressed()
return
if(".")
if(length(msg)==4)
addressed()
return
if("!")
if(length(msg)==4)
scolded()
return
else
return
if(place<=length(msg))
t = get_token(msg,place)
place += length(t)+1
if(t=="please")
if(place>=length(msg))
confused()
else
t = get_token(msg,place)
place += length(t)+1
if(t in reactions)
call(src,reactions[t])(speaker,msg,place)
else
confused()


The more behavior and flexibility you write in, the more likely you will be to see the pointless fun of it.
i'm a novice at coding and that whole thing just got me confused o.o
This is how I would go about completing the task your looking at, but I won't do it exactly for you. I will use the example of advertising. I will add comments to help you understand the code.

mob
var
muted = 0

mob
verb
OOC(var/t as text)
if(muted == 1)
return
if(FilterText(t,ADList))//The filtertext proc, which will make sure people don't advertise on your game
usr<<"<font color=red><b>Please do not try to advertise on this game</b></font color>"//Give them a mesasge on what they did wrong
muted = 1//Mute them
world<<"<font color=green><b>Punishment:</b> </font color>[usr] ([usr.key]) has been auto-muted for trying to advertise"//send the world the message that they are muted
return
else
world << "[src.name]: [t]"


var
list
ADList = list("games.byond","http://games.byond.com","www.byond.com/games","byond://","BYOND.world","byond: //")

mob
proc
FilterText(T as text, var/list/L)//You need to filter the text, such as the "ADList" above, so they cannot spam and ruin everyones good time :P
for(var/O in L)//Basic for() call
if(findtext(T,O))//Finds the message in a filter, if it is found, it will return a 1
return 1//^|^


I hope this helps you. Here is a tip do not copy and paste code type it out as doing so will help you learn.
In response to DarklightX
You should incorporate a much more modular administration system. That said, there are some errors in your code below.

for(M as mob in world)

You aren't defining M here. A better iteration might be:
for(var/mob/M in world)

I also believe, though am not entirely sure, that the line:
if(findtext(t,M))

probably should not work, because M is a mob object.

That all said, I would scrap this entirely. You are going to run into errors later on, and there are far more efficient implementations that iterating through strings (runtime on this verb is something to O(N^3 * M), where N is the length of t and M is the number of mobs in the world, which is horribly inefficient.

Reconsider a different structuring, one where you don't need to do such tedious work. It will be much easier on you later on. Something more ideal may be an Admin datum that processes such events for you. Filtering through strings is almost guaranteed to give you a runtime headache, and your CPU won't be happy.
In response to Insomniaddikt
Insomniaddikt wrote:
You should incorporate a much more modular administration system. That said, there are some errors in your code below.

for(M as mob in world)

You aren't defining M here. A better iteration might be:
for(var/mob/M in world)

I also believe, though am not entirely sure, that the line:
if(findtext(t,M))

probably should not work, because M is a mob object.

That all said, I would scrap this entirely. You are going to run into errors later on, and there are far more efficient implementations that iterating through strings (runtime on this verb is something to O(N^3 * M), where N is the length of t and M is the number of mobs in the world, which is horribly inefficient.

Reconsider a different structuring, one where you don't need to do such tedious work. It will be much easier on you later on. Something more ideal may be an Admin datum that processes such events for you. Filtering through strings is almost guaranteed to give you a runtime headache, and your CPU won't be happy.

^String parsing is necessary for bots. OP asked for a bot.

Second, running through every mob in the world looking for a player to kick/ban is probably a bad idea.

Try this instead:

var/mob/M
for(var/client/c in world)
M = c.mob
This was actually done in kidpaddle's sever of my Myclassroom where Falacy and Xirre helped me so i no longer need any help but i will give the askers choice to ter because he was the one that actually got xirre to work.
In response to Ter13
Ter13 wrote:
You are more than likely going to want to create a string tokenizer. and parser.

> var
> chatbot/bot
> mob
> verb
> say(msg as text)
> if(lowertext(copytext(msg,1,4))=="sam")
> bot.parse(src,lowertext(msg))
> world << "[src]: [msg]."
>
> #define get_token(x,y) (copytext((x),(y),findtext((x)," ",(y),0)))
>
> chatbot
> var
> list/reactions = list("is"="selfReference","kick"="kickTask","ban"="banTask")
> proc
> parse(mob/speaker,msg)
> var
> place = 4
> t = get_token(msg,place)
> place += length(t)+1
> if(length(t))
> switch(t)
> if(",")
> if(length(msg)==4)
> addressed()
> return
> if("'s")
> if(length(msg)==4)
> confused()
> return
> if("?")
> if(length(msg)==4)
> addressed()
> return
> if(".")
> if(length(msg)==4)
> addressed()
> return
> if("!")
> if(length(msg)==4)
> scolded()
> return
> else
> return
> if(place<=length(msg))
> t = get_token(msg,place)
> place += length(t)+1
> if(t=="please")
> if(place>=length(msg))
> confused()
> else
> t = get_token(msg,place)
> place += length(t)+1
> if(t in reactions)
> call(src,reactions[t])(speaker,msg,place)
> else
> confused()
>

The more behavior and flexibility you write in, the more likely you will be to see the pointless fun of it.

Sorry pretty late on this. But can you explain how Sam will react how to put that down or code that? Also can you explain more information on your code?
There isn't much to explain. It recognizes its name, and is able to recognize the next token as a command based on your list of defined reactions.