ID:707280
 
(See the best response by Nadrew.)
Code:
mob/var/banned=0
mob/Admin/verb/banned(mob/M in world)
set category = "Admin"
M.banned=1
usr<<"You banned [M.name]"
M<<"You have been banned"

mob/Admin/verb/Unban(mob/M in world)
set category = "Admin"
M.banned=0
usr<<"You have unbanned [M.name]"
M<<"You have been unbanned"


Problem description: How do i make it so that it will ban and unban the save data instead of the mob because if the mob is not online one day and i want to unban him

You should probably consider using a text document. Basically you would want to add the person you wish to bans key into a list, or text document, and keep track of any additional info you might need along with that. Such as the length of the ban, the reason, and so on and so forth. You can search resources for ban, and likely find tons of things you could learn from.

Don't just copy and paste it, though. Make your own. You'll be more likely to learn more that way, and get something more suitable for your goals.

This is assuming that by save data you mean a person who is offline, and not one specific character of theirs; which seems logical since I see no reason to ever ban one save file of a player and not the others.
i mean the ban verb is good but the unban needs work like i want to save the bans some where and load it i got my place already.
Best response
The ban verb is a terrible way of doing it, you should always be using a global list.

var/list/bans = list()

mob/verb/Ban(mob/M as mob in world)
if(M == usr) return
if(!M) return
bans += M.ckey
del(M)

mob/verb/Unban()
var/unban_key = input("Who do you want to unban?")as null|text in bans
if(!unban_key) return
bans -= unban_key

client/New()
if(bans.Find(ckey)) del(src)
..()


The way you're doing it is mob-specific and you'd actually have to load the player before checking if they're banned, not exactly the most efficient method.
Then use a text file.

Just use a proc to add a message.

proc/log_action(file, message)
file(file) << message


Then just pass something like this in your ban verb:
log_action("ban_tracker.txt", "[usr] banned [M].  [time2text(world.timeofday)]")


It will either create ban_tracker.txt or grab it, and send the message to it. Then you can just open up the file on the host computer and get all of the bans in one file.
I also need to do something with the Mute i want it to send a message
In response to Nadrew
Nadrew wrote:
The ban verb is a terrible way of doing it, you should always be using a global list.

> var/list/bans = list()
>
> mob/verb/Ban(mob/M as mob in world)
> if(M == usr) return
> if(!M) return
> bans += M.ckey
> del(M)
>
> mob/verb/Unban()
> var/unban_key = input("Who do you want to unban?")as null|text in bans
> if(!unban_key) return
> bans -= unban_key
>
> client/New()
> if(bans.Find(ckey)) del(src)
> ..()
>

The way you're doing it is mob-specific and you'd actually have to load the player before checking if they're banned, not exactly the most efficient method.


loading Darkeyes.dme
Verbs.dm:103:warning: it is recommended that you use an object filter or 'anything' when combining constant input types with lists
loading Skin.dmf
loading AlphaMap.dmm
saving Darkeyes.dmb

In response to Whybe
Whybe wrote:
I also need to do something with the Mute i want it to send a message

To who? The mutee?

M << "[usr] muted you."


If you are talking about sending a message to a file, then do exactly what I did.

If you cannot apply a concept that I clearly demonstrated with an example, then you need to get back to studying.

I showed you an example procedure and how to use that example procedure. It isn't that hard to realize how the procedure works; not only is it self-explanatory, but I explained what it does.

As for your problem with Nadrew's code:

Don't try to copy and paste someone else's code unless you know what it does. You now know what happens when you do that. You get errors and can't explain why.
The mute and it are the same code and stuff but is not only that when i try to add something to this it gives me a error
mob/verb
ooc(t as text)
set name="OOC"
set category="Communicate"
if(usr.muted){return 0}
else world<<"<font color=gold><b>[src]</b> Says</font><font color=silver>:</font><font color=gold> [t]</font>"
In response to Whybe
Whybe wrote:
The mute and it are the same code and stuff but is not only that when i try to add something to this it gives me a error

I'm not able to enter your mind and see what error it gives you. You're going to have to tell me.
My bad not a error but i dont know how to add that like when i add it next to {return 0} it doesnt do something under it it just adds it to something under it it adds it what it says before the OOC message appears
1. I don't understand a word of what you just said.

2. Don't use brackets and short-hand techniques if you can't even grasp code that is separated by 10 lines of whitespace.

3. If you can't convey your problem to me in a way I can understand, I can't help you.
Whybe, we have some fairly serious communication errors here. If you're not able to better describe what the problem is, we can't really help you.

Firstly, just to clarify this; is this your own code, written from scratch, or are you trying to repurpose someone's code?
When i write
usr << " you have been muted" under the If(usr.mute) it shows up every time i use ooc
Unless you can address Albro1's points, we still can't really help you, Whybe. Remember; we can't see your code or into your brain, so you saying something like that still doesn't really explain the whole problem to us.

We could probably, with some discussion, fix that particular issue; but you're going to have an underlying cause for all these questions you keep asking in Developer Help.
am using a code i saw a lib
In response to Whybe
That's because you are using braces and you don't even understand what they do. Stick to using tabs to keep everything organized. Put return 0 onto the next line, tab it over, and delete the braces.
Okay, you're using some code from a library. What library, and how old is it? Are you using the whole library, or have you just copied code from it and started adding your own code to it?

It would be much easier for you to just start writing your own code from scratch; it will really make much more sense.
K let me try this
Oh my bad i got it from a turtoial
Page: 1 2