ID:142860
 
Code:
    portal
icon_state = "portal"
Entered()
usr.loc=locate(src.X,src.Y,src.Z)
var
X
Y
Z
portal1
X = 53
Y = 59
Z = 4
portal2
X = 35
Y = 63
Z = 1
portal3
X = 24
Y = 63
Z = 1
portal4
X = 23
Y = 1
Z = 3
portal5
X = 10
Y = 4
Z = 5
usr << "HAHA you are now inside the arena!!! anyone can attack you but there are secrets in this place"
usr.attackable = 3
portal6
X = 34
Y = 6
Z = 1


Problem description:
while I'm trying to make it so if you enter portal5 you get the message "haha you entered the arena... etc." but i get there errors...
turf1\God's Meeting.dm:73:error:usr:duplicate definition
turf1\God's Meeting.dm:73:error:"HAHA you are now inside the arena!!! anyone can attack you but there are secrets in this place":duplicate definition
turf1\God's Meeting.dm:73:error:<< :instruction not allowed here
turf1\God's Meeting.dm:74:error:usr.attackable:undefined var


That's because you need to put that under Entered() for that particular portal.
    portal
icon_state = "portal"
/*
Entered()
usr.loc=locate(src.X,src.Y,src.Z)
//Don't use usr in procs.
*/

//A better way for your Entered() proc.
Entered(mob/m)
if(ismob(m))
m.loc=locate(X,Y,Z)
var
X
Y
Z
portal1
X = 53
Y = 59
Z = 4
portal2
X = 35
Y = 63
Z = 1
portal3
X = 24
Y = 63
Z = 1
portal4
X = 23
Y = 1
Z = 3
portal5
X = 10
Y = 4
Z = 5
/*
Here's your problem.
usr << "HAHA you are now inside the arena!!! anyone can attack you but there are secrets in this place"
usr.attackable = 3
*/

//Here's my solution.
Entered(mob/m)
..() //Call the default Entered() proc for portals first, which teleports you.
m<<"HAHA you are now inside the arena!!! anyone can attack you but there are secrets in this place"
m.attackable=3
portal6
X = 34
Y = 6
Z = 1
That's a pretty bad way to do teleporting. A better way to do it would be this way:
portal
icon_state = "portal"

var/transport_tag
Entered(mob/m) //Never use usr in a proc. *Especially* ones relating to entering or exiting.
if(istype(m) && m.client) //If it really has to be a player, this will filter out NPCs.
var/turf/t = locate(transport_tag)
if(t) //A safety check to make sure that the turf exists.
m.loc = t

Now, to explain how it works. Every /atom has a variable called tag. This variable can only be set at runtime or in the map editor. What you would do is go to the map editor, right-click on an /atom and then find an option like "Edit..." or something. I forget its exact name. Give the tag variable a unique name, and then find this portal and do the same, except give it te name that the other object's tag variable had for transport_tag. Whenever you enter the portal, it will take you to that object, provided it exists.
In response to Popisfizzy
Popisfizzy wrote:
Every /atom has a variable called tag.

Actually, tag is a datum variable.
In response to Garthor
I'm aware, but he very likely didn't know what a /datum is and I really didn't feel like explaining it to him.
In response to Popisfizzy
    portal
icon_state = "portal"
var/transport_tag
Entered(mob/m) //Never use usr in a proc. *Especially* ones relating to entering or exiting.
if(istype(m) && m.client) //If it really has to be a player, this will filter out NPCs.
var/turf/portal1 = locate(53,59,4)
var/turf/portal2 = locate(35,63,1)
var/turf/portal3 = locate(24,63,1)
var/turf/portal4 = locate(23,1,3)
var/turf/portal5 = locate(2,13,5)
var/turf/portal6 = locate(34,6,1)
var/turf/portal7 = locate(196,4,3)
var/turf/portal8 = locate(48,26,1)
if(portal1) //A safety check to make sure that the turf exists.
m.loc = portal1
if(portal2) //A safety check to make sure that the turf exists.
m.loc = portal2
if(portal3) //A safety check to make sure that the turf exists.
m.loc = portal3
if(portal4) //A safety check to make sure that the turf exists.
m.loc = portal4
if(portal5) //A safety check to make sure that the turf exists.
m.loc = portal5
m << "<FONT COLOR=BLUE><b>You enter the PK Zone!</b></FONT>"
m.attackable = 3
if(portal6) //A safety check to make sure that the turf exists.
m.loc = portal6
m << "You have left the PK Zone."
m.attackable = 0
if(portal7) //A safety check to make sure that the turf exists.
m.loc = portal7
if(portal8) //A safety check to make sure that the turf exists.
if(usr.MiningLvl >= 2)
m.loc = portal8
else
usr << "<b>You must be level 2 in Mining to leave."
return

if this is what you meen what it dos is gos through all of the portal definitions and teles to last one through the defined path /turf/portal

[EDIT]
sorry posted in wrong key but still not workin
In response to Elextra
No, that's not at all what I meant. You clearly didn't read the paragraph following the code. That code requires essentially no modifications (unless you wish that NPCs can enter).