- Joined
- Apr 1, 2012
- Messages
- 1,249
- Solutions
- 71
- Reaction score
- 621
- Location
- Hell
- GitHub
- idontreallywolf
I am a beginner in LUA, and i've made a script which checks wether a player exists in a room of 3SQM(s).
I believe this is not the most efficient version of it so I decided to came here and get some feedback.
I believe this is not the most efficient version of it so I decided to came here and get some feedback.
Lua:
local positions = {
{x=1005, y=992, z=6, stackpos=253},
{x=1006, y=992, z=6, stackpos=253},
{x=1007, y=992, z=6, stackpos=253}
}
local kickPos = {x=1006, y=994, z=6}
function onUse(cid, item, fromPosition, itemEx, toPosition)
for i=1, table.maxn(positions) do
-- (I am) the player in room, teleport me out.
if getTopCreature(positions[i]).uid == cid then
doTeleportThing(cid, kickPos)
doSendMagicEffect(getCreaturePosition(cid), 4)
return true
end
if isPlayer(getTopCreature(positions[i]).uid) then
-- Player Exists in room
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "There's someone in the room! Please wait. ")
doSendMagicEffect(getCreaturePosition(cid), 2)
return true
end
end
-- no player was found, teleport me in!
doTeleportThing(cid, positions[2])
doSendMagicEffect(getCreaturePosition(cid), MAGIC_EFFECT_FIREATTACK)
return true
end