Home Button Home Login Button Login Download Button Download Lua scripts list button Scripts list Lua documentation Button Lua scripting docs About FAQ Button FAQ

Player on screen alarm ignoring friends

Plays an alarm when you see player that is not in whitelist

                
local whitelist = {
    "FriendName1", 
    "FriendName2", 
    "FriendName3"
}

local function isInWhitelist(playerName)
    for , name in ipairs(whitelist) do
        if playerName == name then
            return true
        end
    end
    return false
end

local function checkForPlayers()
    local players = getScreenPlayers()
    for , player in ipairs(players) do
        local playerName = getCreatureName(player)
        if playerName and not isInWhitelist(playerName) then
            playSound("playerOnScreen.wav")
            break
        end
    end
end

autoRun(1000, checkForPlayers)