executing punkbuster rcon commands via lua

Discussions about ET modding (sdk code, player/weapon modeling)

Moderators: Forum moderators, developers

Post Reply
User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

executing punkbuster rcon commands via lua

Post by Luk4ward »

As u may notice or not, it is impossible to use et_Console function to call pb_ rcon commands. Until now it was possible only in etadmin mod, but what i spot the only way to do that is executing a file via function. So i made smth like this:

Code: Select all


function rconexecute (by,cmd,arg1,arg2)

local fd,len,file, data
len = 0
line = ""
data = 0

local admin
admin = trim(uncol(et.Info_ValueForKey(et.trap_GetUserinfo(by), "name" )))

if arg1 ~= nil and arg2 == nil then
   line = "" .. cmd .. " " .. arg1 .. ""
   elseif arg1 ~= nil and arg2 ~= nil then
   line = "" .. cmd .. " " .. arg1 .. " " .. arg2 .. ""

end

  data = string.len( line )

     --local hash = "" .. admin .. "_" .. os.date("%m_%d_%Y_%H%M%S") .. ""
     local hash = "" .. admin .. "_" .. os.date("%m_%d_%Y_%H%M%S") .. "_" .. leveltime .. ""

     file = "rcon_logs/rconcmds_" .. hash .. ".cfg"

     fd, len = et.trap_FS_FOpenFile( file, et.FS_APPEND )
     et.trap_FS_Write( line, data, fd )
     et.trap_FS_FCloseFile( fd )
     et.trap_SendConsoleCommand( et.EXEC_APPEND, "exec " .. file .. "\n" )
     
     et.trap_SendServerCommand(by, ("tc " .. by .. " \"^1SERVER private to ^7(^1You^7): ^2 executing rcon command: ^3" .. cmd .. " " .. arg1 .. " " .. arg2 .. "^7\n"))

end

Due to not existing any way to remove a file or reset it i have to create every time a new file (thats why i use some kind of hash). Its working very well, but maybe You know a better way?,

regards
wolFTeam.pl
McSteve
Posts: 113
Joined: Tue Sep 12, 2006 7:41 am

Post by McSteve »

Do you mean issue pb commands? Its been a while, but I remember using pb commands with et.trap_SendConsoleCommand and et.exec_now without any problems; I'm almost certain I used pb_kick for one.

As for resetting the file, opening it in et.FS_WRITE mode rather than et.FS_APPEND mode will clear the contents each time. I don't think I've ever used it but I would imagine os.remove(filename) would allow you to simply delete the file if that is what you prefer.
GhosT:McSteve
Ghostworks Gaming Community
User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

Post by Luk4ward »

Uhm, i just looked into kmod and there are pb_sv_ cmds idd, so its propably working. Weird that afaik it wasnt working for me :p. Thx for help :)
wolFTeam.pl
Post Reply