Frictional Games Forum (read-only)

Full Version: Teleportation!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Im having trouble getting my script right. I'm trying to get my character to teleport when he touches a script area. Any help or a code I can copy would be awesome. Thanks!
TeleportPlayer( area );


make sure the area type is PlayerStart
I've done that. However I've had trouble linking it to a collide callback. And naming the function. When I try and test it, it says unexpected variable '{'.
Post your code. You likely have one too many opening brackets somewhere.
void OnStart()
{
AddEntityCollideCallback("Player", "SATeleport", "PlrTeleport", true, 1); //SATeleport is the area where you teleport.
}

void PlrTeleport(string &in asParent, string &in asChild, int alState)
{
TeleportPlayer("PlrStart"); //PlrStart is the area where you will be teleported.
}
That's what i thought, as I've encountered this problem before, but i didnt find any when I looked.

void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_4", "FloorFall1", true, 1);
}
void FloorFall1(string& asStartPosName);
{
TeleportPlayer(PlayerStartArea_2);
}

///also this is just a section of my script, let me know if you want the entire thing. also i messed up on the error, it says unexpected token, not variable.
I found one error. There could be more so just to be on the safe side, post the whole script.


BTW, here's the error.
void FloorFall1(string &in asParent, string &in asChild, int alState) //It was wrong.
OK i changed that,but now it comes up with an error saying that 'PlayerStartArea_2' is not declared. ill post my whole script in a bit.

void OnStart()
{
AddUseItemCallback("", "key_laboratory_1", "mansion_8", "OpenDoor", true);
AddEntityCollideCallback("Player", "ScriptArea_2", "Falling", true, 1);
AddEntityCollideCallback("Player", "MorgueInsanity", "MorgueDoorClose", true, 1);
AddEntityCollideCallback("Player", "SkullFall", "FallingSkull", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_3", "PlaySound1", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_4", "FloorFall1", true, 1);
}




void OpenDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
RemoveItem(asItem);
}
void Falling(string &in asParent, string &in asChild, int alState)
{
AddPropForce("box_1", 0, 0, -2000, "world");
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
GiveSanityDamage(6.0f, true);
}
void MorgueDoorClose(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);
SetSwingDoorLocked("door_red_1", true, true);
SetSwingDoorClosed("door_red_1", true, true);
}
void FallingSkull(string &in asParent, string &in asChild, int alState)
{
AddPropForce("lab_cryo_head_1", 1800, 0, 0, "world");
SetPlayerActive(false);
GiveSanityDamage(6.0f, true);
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
AddTimer("", 1.0f, "lookatskull");
}
void lookatskull(string &in asTimer)
{
StartPlayerLookAt("lab_cryo_head_1", 10.0f, 10.0f, "");
AddTimer("", 1.0f, "skulllook");
}
void skulllook(string &in asTimer)
{
StartPlayerLookAt("corpse_male_torso_1", 10.0f, 10.0f, "");
PlaySoundAtEntity("", "react_scare", "Player", 0, false);
AddTimer("", 0.5f, "stoplook");
}
void stoplook(string &in asTimer)
{
StopPlayerLookAt();
SetPlayerActive(true);
}
void PlaySound1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "00_faint.snt", "Player", 0, false);
}
void FloorFall1(string &in asParent, string &in asChild, int alState)
{
TeleportPlayer(PlayerStartArea_2);
}
void OnEnter()
{
}

void OnLeave()
{
}
void OnStart()
{
AddUseItemCallback("", "key_laboratory_1", "mansion_8", "OpenDoor", true);
AddEntityCollideCallback("Player", "ScriptArea_2", "Falling", true, 1);
AddEntityCollideCallback("Player", "MorgueInsanity", "MorgueDoorClose", true, 1);
AddEntityCollideCallback("Player", "SkullFall", "FallingSkull", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_3", "PlaySound1", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_4", "FloorFall1", true, 1);
}




void OpenDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
RemoveItem(asItem);
}
void Falling(string &in asParent, string &in asChild, int alState)
{
AddPropForce("box_1", 0, 0, -2000, "world");
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
GiveSanityDamage(6.0f, true);
}
void MorgueDoorClose(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);
SetSwingDoorLocked("door_red_1", true, true);
SetSwingDoorClosed("door_red_1", true, true);
}
void FallingSkull(string &in asParent, string &in asChild, int alState)
{
AddPropForce("lab_cryo_head_1", 1800, 0, 0, "world");
SetPlayerActive(false);
GiveSanityDamage(6.0f, true);
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
AddTimer("", 1.0f, "lookatskull");
}
void lookatskull(string &in asTimer)
{
StartPlayerLookAt("lab_cryo_head_1", 10.0f, 10.0f, "");
AddTimer("", 1.0f, "skulllook");
}
void skulllook(string &in asTimer)
{
StartPlayerLookAt("corpse_male_torso_1", 10.0f, 10.0f, "");
PlaySoundAtEntity("", "react_scare", "Player", 0, false);
AddTimer("", 0.5f, "stoplook");
}
void stoplook(string &in asTimer)
{
StopPlayerLookAt();
SetPlayerActive(true);
}
void PlaySound1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "00_faint.snt", "Player", 0, false);
}
void FloorFall1(string &in asParent, string &in asChild, int alState)
{
TeleportPlayer("PlayerStartArea_2");
}
void OnEnter()
{
}

void OnLeave()
{
}

Fixed.
Awsome. Thank you very much. It works perfectly now. what did you change?
EDIT: nevermind i found it.