[DiscordArchive] oh so you can nest functions?
[DiscordArchive] oh so you can nest functions?
Archived author: Honey • Posted: 2022-11-04T17:33:13.477000+00:00
Original source
This uses the unique low guid of a player as a key and assigns the X coordinate as a value.
Archived author: jintao41 • Posted: 2022-11-04T17:35:06.028000+00:00
Original source
and any player could even be the same player so it stores new coordinates
Archived author: jintao41 • Posted: 2022-11-04T17:35:17.596000+00:00
Original source
I understand, thank you again
Archived author: Honey • Posted: 2022-11-04T17:36:14.871000+00:00
Original source
Right
![[Image: image0.gif?ex=690c33dd&is=690ae25d&hm=dc...521160b0a&]](https://cdn.discordapp.com/attachments/448835144564867094/1038144722822246503/image0.gif?ex=690c33dd&is=690ae25d&hm=dca6d64a93e59e3265c90d0a1a1940ae8859e9bec8f0746209f5e3f521160b0a&)
Archived author: Honey • Posted: 2022-11-04T17:36:29.752000+00:00
Original source
![[Image: image0.gif?ex=690c33dd&is=690ae25d&hm=dc...521160b0a&]](https://cdn.discordapp.com/attachments/448835144564867094/1038144722822246503/image0.gif?ex=690c33dd&is=690ae25d&hm=dca6d64a93e59e3265c90d0a1a1940ae8859e9bec8f0746209f5e3f521160b0a&)
Archived author: iThorgrim • Posted: 2022-11-04T22:02:09.873000+00:00
Original source
M, X, Z, O, Y are not global is local to block SwitchZone
Archived author: iThorgrim • Posted: 2022-11-04T22:04:47.428000+00:00
Original source
U Can use
```
player:SetData("pos_x", player:GetX())
player:GetData("pos_x")
```
Archived author: Foe • Posted: 2022-11-04T22:07:40.230000+00:00
Original source
If the code linked above is the full script, then those variables are indeed global
Archived author: Foe • Posted: 2022-11-04T22:09:44.194000+00:00
Original source
Declaration within the function SwitchZone without local doesn't inherently make them local to the script scope
Archived author: Foe • Posted: 2022-11-04T22:18:58.705000+00:00
Original source
```Lua
local function SwitchZone(event, player)
local t = {}
t.map = player:GetMapId()
t.x, t.y, t.z, t.o = player:GetLocation()
player:SetData("pos", t)
end
local function ReviveInDungeon(event, killer, killed)
local t = player:GetData("pos")
if(t) then
killed:Teleport(t.map, t.x, t.y, t.z, t.o)
killed:ResurrectPlayer(100)
killed:SendChatMessageToPlayer( 11, 0, "revived", killed )
end
end
RegisterPlayerEvent(27, SwitchZone)
RegisterPlayerEvent(8, ReviveInDungeon) -- PLAYER_EVENT_ON_KILLED_BY_CREATURE = 8, // (event, killer, killed)```