ID:263930
 
How Would I make a Mass Delete verb for a building game...where GMs can click 1 button in there verbs,click the name of the person they want to delete all there objects of, and BAM world << "[usr] deletes all objects in the world by [M]!"


mob/GM
verb
Mass_Delete(M as mob,var/obj/o in view())
del o
world << "[usr] deletes all objects in the world by [M]
The players would need a list objects they created:
mob
var/list/created_objects
proc/add_object(atom/a)
if(!created_objects) created_objects = new
created_objects += a

proc/delete_created_objects()
for(var/atom/a in created_objects) del a

//Then, with your implementation, it would be like this:
GM/verb/Mass_Deleted(client/c as client) //I think client is valid here. You wouldn't want to use mob here
//because there are likely NPCs.
c.mob.deleted_created_objects()

world << "[src] deleted all objects in the world by [c.key]."

If you just have a basic owner var for all the objects, an easy way to do it would be...

mob/GM/verb/Mass_delete(var/mob/M in world)
switch(alert(usr,"Would you really like to delete [M]'s objects?","Delete","Yes","No"))
if("No") return
for(var/obj/O in world)
if(O.owner==M.key) del(O)
In response to Jeff8500
That's a poor and screwed-up way of doing it, I must say.
In response to Popisfizzy
Yeah, but it works and its easy...


Or atleast I think it works xD
In response to Jeff8500
Easy does not make it good. Good practice comes first.
In response to Popisfizzy
Yes, but it helps to start out easy and work your way up.
In response to Jeff8500
Not if someone gives you code that works better.
In response to Popisfizzy
How can you learn from something you don't understand though?
In response to Popisfizzy
You might also want to make the created_objects list a tmp var, just so it doesn't save them...
In response to Jeff8500
...by asking questions.
In response to Jeff8500
I'd think you'd want to save what they created, as a player could simply relog to avoid getting all their stuff deleted, causing problems for the administration.
Yo...Jeff and Pop...Jeff, where would you put - world << "[src] deleted all objects in the world by [M.key]." -in that code u gave me? and Pop..Yours world message thing works but it doesnt delete the objects..
In response to Popisfizzy
Yes, but creating alot of objects upon loading could cause problems for the server...

I'm not sure if that would cause problems in 4.0 with its object limit, but if someone's objects aren't periodically deleted while they are on it could eventually cause problems.
In response to Reno Kujika
In mine, you would put it below the switch/if part and above the for proc. Also, if your using Popisfizzy's code, you have to remember to make your build verbs look kind of like this.

mob/verb/Build_Pie()
var/obj/Pie/O = new(usr.loc)
usr.add_object(O) //whatever the name of the proc is
In response to Jeff8500
Then you modify it so that the list is saved for a time, and then deleted, giving the administration time to handle clean up.
In response to Popisfizzy
Popisfizzy wrote:
I'd think you'd want to save what they created, as a player could simply relog to avoid getting all their stuff deleted, causing problems for the administration.

Uh, that's what you could do if they were saved. If they weren't saved, you couldn't do that.
In response to Jeff8500
Your a life savor Jeff :P really needed that verb
In response to Popisfizzy
Thanks Jeff for a working code, thanks Popisfizzy for trying. I appreciate it ^_^
In response to Reno Kujika
...no, you see, mine does work. Whether or not you could implement it is irrelevant.
Page: 1 2