ID:154782
 
Hello, I need to do one Teleport and Summon verb with topic, but It's not working... I made it:

        Summon2()
set desc = "() Create an object of any type"
set name = "Summon2"
set category = "Staff"
if(usr.ADM == "OFF")
usr<<"Você não é ADM e nao pode usar o comando"
del(usr)
var/html = "<html><body bgcolor=black text=#CCCCCC link=white vlink=white alink=white>"
var/L[] = PlayernoMundo // Playernomundo it's a list, when you log in the server it automaticly add you on it.
for(var/X in L)
html += "<a href=byond://?src=\ref[src];action=summon;type=[X]>[X]</a><br>"
usr << browse(html,"window=info")

client/Topic(href,href_list[],hsrc)
switch(href_list["action"])
if("summon")
var/mob/E = href_list["type"]
E<<"Pronto"
E.loc = locate(1,1,1)


But ingame appears Runtime error: cannot modify Luan.loc

anyone can help me make it?

Best Resgards,
Luan

Merry Xmas btw
Just a hunch, try moving the mob instead of the client.
In response to Lugia319 (#1)
Ok, I get it...

mob/Topic(href,href_list[],hsrc)
switch(href_list["action"])
if("summon")
var/mob/E = href_list["type"]
for(var/mob/M in world)
if(E == M.name)
M.loc = locate(usr.x,usr.y-1,usr.z)
M.dir = SOUTH


It works well with this

Thanks you
In response to Luan12 (#2)
Oh, I can't teleport or summon people who name cotain space in the nick, example Weapon's Seller

How can I fix this?

Thanks
In response to Luan12 (#3)
There are two methods:

1) Instead of sending X = mob's name, use X = \ref text macro (I think it was something like type=\ref[X]... look up text macros in the DM reference). Then, in the Topic(), use locate(list["type"] <-- \ref code) to find the mob.

2) Encrypt the name via encrypt_HTML... or something like that. it's been a long time, look it up in the DM reference... and then decrypt it in the Topic()
In response to GhostAnime (#4)
I tried the second method and it doesn't work, when I use the verb appears at the game "cannot read "Luan".key), and I didn't understood the first method, can you explain with codes please? thanks
In response to Luan12 (#3)
Luan12 wrote:
Oh, I can't teleport or summon people who name cotain space in the nick, example Weapon's Seller

if(E.name == M.name)

That's the quick and dirty solution to your problem (you're comparing the actual mob to the name). But I strongly suggest revising it entirely, you're putting way too much effort into it.

You need to backup a little, and think about what you're doing, what you've done and what you've already got. You've already done the loop (in the verb to get the list of clients, I assume), so you don't need to do it again.

For the sake of example, here is a quick and dirty method of getting a list of players in an HTML window:
mob
verb
Summon()
var/html = ""
for(var/client/C) html += "<div><a href=?src=\ref[C.mob]&c=summon>[C.mob.name]</a> ([C]|[C.key])</div>"
src << browse(html, "window=summon")


As you can see, we've done a loop though the clients, and grabbed the mobs reference\ref[C.mob] and passed a command for summonc=summon. We did that to make managing topics easier.

So now we've got our stock Topic() setup:
client
Topic(href, href_list[], hsrc)
. = ..()


We added the c[ommand] parameter to make managing topics easier, we'll do this with a switch() statement. From there we'll proceed to make the summon verb.

client
Topic(href, href_list[], hsrc)
. = ..()
switch(href_list["c"])
if("summon")
var/mob/M = locate(href_list["src"])
M.loc = locate(src.mob)
src << "You have summoned [M.name]."
M << "[src.mob.name] has summoned you!"


Because we passed a reference to the clients mob in all the links, we can easily make a variable that points directly to it, without the need to loop through clients or mobs againvar/mob/M = locate(href_list["src"]).

Then we set their location to our own as you'd expect, and give everyone a message of what's going on.

Teleport will be much the same, only with the directions reversed.
In response to Tiberath (#6)
Wow!! It's amazing man, you did it so easier, you rocks!! ahahah

How can I put the NPC's in the list too?? but only once, to don't pollute the list, you know??

Thanks by the way
In response to Luan12 (#7)
Change

for(var/client/C)

to
for(var/mob/M in world)
In response to A.T.H.K (#8)
if I put mob/M appears all the NPCS's, more than one time... I wanna only once you know?
In response to Luan12 (#9)
Luan12 wrote:
if I put mob/M appears all the NPCS's, more than one time... I wanna only once you know?

Well yes because you haven't grouped them at all, I simply displayed ALL the mobs in the world...