1function canJoin(player)
2 if player:getGroup():getAccess() then
3 return true
4 end
5
6 return false
7end
8
9local function cleanGlobalVariables()
10 _G["cid"] = nil
11 _G["player"] = nil
12 _G["creature"] = nil
13 _G["pos"] = nil
14 _G["tile"] = nil
15 _G["container"] = nil
16 _G["group"] = nil
17 _G["vocation"] = nil
18 _G["town"] = nil
19 _G["house"] = nil
20 _G["party"] = nil
21end
22
23function onSpeak(player, type, message)
24 local pos = Position(player:getPosition())
25 local tile = Tile(pos)
26
27 _G["cid"] = player:getId()
28 _G["player"] = player
29 _G["creature"] = Creature(player:getId())
30 _G["pos"] = pos
31 _G["tile"] = tile
32 _G["container"] = player:getSlotItem(CONST_SLOT_BACKPACK)
33 _G["group"] = player:getGroup()
34 _G["vocation"] = player:getVocation()
35 _G["town"] = player:getTown()
36 _G["house"] = tile:getHouse()
37 _G["party"] = player:getParty()
38
39 local res, err = loadstring(message)
40 if res then
41 local ret, err = pcall(res)
42 if not ret then
43 player:sendChannelMessage(player:getName(), "Lua Script Error: " .. err .. ".", TALKTYPE_CHANNEL_O, 7)
44 cleanGlobalVariables()
45 return false
46 end
47 else
48 player:sendChannelMessage(player:getName(), "Lua Script Error: " .. err .. ".", TALKTYPE_CHANNEL_O, 7)
49 cleanGlobalVariables()
50 return false
51 end
52
53 player:sendChannelMessage("", player:getName() .. ">> " .. message, TALKTYPE_CHANNEL_Y, 7)
54 cleanGlobalVariables()
55 return false
56end