ETMods.net

N!tmod, a Wolfenstein: Enemy Territory Modification!

You are not logged in.

Announcement

You can donate to help us keeping services online.

#1 08-Jan-11 09:39:48

The Doc
Member
Registered: 08-Jan-11
Posts: 2

Re: Request pmspec.lua

Hello guys,

I am searching for a working LUA script called pmspec.lua.
I've found 2 files on the etpub forums but there seem to be
problems with those scripts as I restart my server for loading them.

Btw is there also a script for adding banners on custom places?


Thanks in advance,


The Doc

Offline

#2 08-Jan-11 20:31:09

yori
Member
Registered: 07-Jan-11
Posts: 2

Re: Request pmspec.lua

--
-- pmspec.lua by s1a
-- http://www.ai-jo.com
--
-- This mod allow admins that have the shrubbot flag "4" to see
-- all clients private messages, fireteam chat and team chat
-- Those admins have to use the commands /pmspec, /ftspec or /stspec.
-- That will trigger their habitility to see the chats.
-- The setting is conserved as long as the admin stay on the server.
--

-------------------------------------------------------------------------------------
-------------------------------CONFIG START------------------------------------------

--#client# is replaced by the client that used the command
--#message# is replaced by the message that the client said
--#recipient# is replaced by the target of the private message command
--Put the message "" to disable that particular message. Example : (SAYTEAM_MSG = "")
SAYTEAM_MSG          = "^4sayteam^7: #client#^7: ^3#message#"
SAYBUDDY_MSG          = "^3saybuddy^7: #client#^7: ^3#message#"
PRIVMSG_MSG            = "^1privmsg^7: #client# ^3-> ^7#recipient#^7: ^3#message#"

--Print only to spectators(1) or always (0)
SPECSONLY             = 1

-------------------------------CONFIG END -------------------------------------------
------------(DON'T CHANGE ANYTHING BELOW THIS UNLESS YOU KNOW WHAT YOU DO)-----------
-------------------------------------------------------------------------------------

MODNAME = "pmspec.lua"
MODVERSION = "1.0.3"

wannaSpecTable = {}

function et_InitGame(leveltime, randomseed, restart)
    et.RegisterModname(string.format("%s %s", MODNAME, MODVERSION))
   
    for i=1,et.trap_Cvar_Get("sv_maxclients"),1 do
        wannaSpecTable[i] = {}
        for j=1,3,1 do
            wannaSpecTable[i][j] = 0
        end
    end

    local fd, len = et.trap_FS_FOpenFile("pmspec.dat", et.FS_READ)
    if len ~= -1 then
        local filestr = et.trap_FS_Read(fd, len)
   
        for line in string.gfind(filestr, "[^\r\n]+") do
            id, st1, st2, st3 = string.match(line, "(%d),(%d),(%d),(%d)")
            wannaSpecTable[tonumber(id)] = {tonumber(st1), tonumber(st2), tonumber(st3)}
        end
    end
   
    et.trap_FS_FCloseFile(fd)
end

function et_Quit()
    local fd, len = et.trap_FS_FOpenFile("pmspec.dat", et.FS_WRITE)
   
    local toWrite
    for i=1,et.trap_Cvar_Get("sv_maxclients"),1 do
        toWrite = tostring(i) .. "," .. tostring(wannaSpecTable[i][1]) .. "," .. tostring(wannaSpecTable[i][2]) .. "," .. tostring(wannaSpecTable[i][3])
        et.trap_FS_Write(toWrite, string.len(toWrite), fd)
    end
   
    et.trap_FS_FCloseFile(fd)

end

function et_ClientCommand(clientNum, command)
    command = string.lower(command)
    if (et.trap_Cvar_Get("g_tyranny") == "1") then
        if (command == "stspec") and (et.G_shrubbot_permission(clientNum, "4") == 1) then
            wannaSpecTable[clientNum+1][1] = invertValue(wannaSpecTable[clientNum+1][1])
            et.trap_SendServerCommand(clientNum, "print \"stspec changed to ".. tostring(wannaSpecTable[clientNum+1][1]) .."^7\n\"")
            return 1
        elseif (command == "ftspec") and (et.G_shrubbot_permission(clientNum, "4") == 1) then
            wannaSpecTable[clientNum+1][2] = invertValue(wannaSpecTable[clientNum+1][2])
            et.trap_SendServerCommand(clientNum, "print \"ftspec changed to ".. tostring(wannaSpecTable[clientNum+1][2]) .."^7\n\"")
            return 1
        elseif (command == "pmspec") and (et.G_shrubbot_permission(clientNum, "4") == 1) then
            wannaSpecTable[clientNum+1][3] = invertValue(wannaSpecTable[clientNum+1][3])
            et.trap_SendServerCommand(clientNum, "print \"pmspec changed to ".. tostring(wannaSpecTable[clientNum+1][3]) .."^7\n\"")
            return 1
        elseif (command == "say_team") and (SAYTEAM_MSG ~= "") then
            local name = et.Info_ValueForKey(et.trap_GetUserinfo(clientNum), "name" )
            local toShow = string.gsub(SAYTEAM_MSG, "#client#", name)
            toShow = string.gsub(toShow, "#message#", et.ConcatArgs(1))
            printToAdmins(toShow,1)
        elseif (command == "say_buddy") and (SAYBUDDY_MSG ~= "") then
            local name = et.Info_ValueForKey(et.trap_GetUserinfo(clientNum), "name" )
            local toShow = string.gsub(SAYBUDDY_MSG, "#client#", name)
            toShow = string.gsub(toShow, "#message#", et.ConcatArgs(1))
            printToAdmins(toShow,2)
        elseif (command == "m") and (PRIVMSG_MSG ~= "") then
            local name = et.Info_ValueForKey(et.trap_GetUserinfo(clientNum), "name" )
            local firstSpace = string.find(et.ConcatArgs(1), "%s")
            local recipient = string.sub(et.ConcatArgs(1), 1, firstSpace - 1)
            local message = string.sub(et.ConcatArgs(1), firstSpace + 1)
            local toShow = string.gsub(PRIVMSG_MSG, "#client#", name)
            toShow = string.gsub(toShow, "#recipient#", recipient)
            toShow = string.gsub(toShow, "#message#", message)
            printToAdmins(toShow,3)
        end
    end
    return 0
end

function et_ClientDisconnect(clientNum)
    for j=1,3,1 do
        wannaSpecTable[clientNum+1][j] = 0
    end
end

function invertValue(value)
    if (value == 0) then
        return 1
    end
    return 0
end

function printToAdmins(text, sayType)
    for i=0,et.trap_Cvar_Get("sv_maxclients")-1,1 do
        if (et.gentity_get(i,"inuse") == 1) then
            if (et.G_shrubbot_permission(i, "4") == 1) and ((SPECSONLY == 0) or (et.gentity_get(i, "sess.sessionTeam") == 3)) and (wannaSpecTable[i+1][sayType] == 1) then
                et.trap_SendServerCommand(i, "print \"".. text .."^7\n\"")
            end
        end
    end
end

function ConsolePrintf(...)
    et.G_Print(string.format("%s: %s\n", MODNAME, string.format(unpack(arg))))
end

Offline

#3 11-Jan-11 20:47:05

The Doc
Member
Registered: 08-Jan-11
Posts: 2

Re: Request pmspec.lua

Thanks mate!
I've added it and when I issue /lua_status it says the script is being loaded.

But now i've a problem when I try for example /pmspec (I have flag 4 granted) there comes:
unknow cmd pmspec


Some help please smile
But it does write a .DAT file in my mod folder smile

Offline

#4 11-Jan-11 23:52:25

N!trox*
Administrator
Registered: 30-Mar-10
Posts: 1,098

Re: Request pmspec.lua

There's a built-in "pmspec" feature in N!tmod.

It is controlled by the "pmspec" shrubbot flag.

If you or your level has this flag, then you will always be able to read pm's while in spectator team (No need to use the /pmspec command)


iluvnitmod.png

Offline

Board footer

Powered by FluxBB