Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google Log In with Steam Sign In
  • Create Account
Photo

Will this LUA work? (Novice needs help :P)

- - - - -

  • Please log in to reply
5 replies to this topic

#1
OFFLINE   Chuckun

Chuckun

    Regular Member

  • Members
  • PipPipPip
  • 130 posts
20
On a distinguished road

I know that typing [g] shows your silEnT GUID and typing it into fireteam chat whilst not in a fireteam will work to do it privately, but for absolute security, I wanted to make a custom command of !myguid so I made this LUA script.. Problem is I have never ever touched anything LUA or ET related, so I have no idea if this will even work and I have no means of testing it.. So I wonder if someone can tell me if I've done anything wrong, and/or if it will actually work?

----------------------------------------------------------------------
-- Filename: myguid.lua
----------------------------------------------------------------------
-- MyGUID - Prints your silEnT GUID just like /cl_guid would for etkey based GUIDs.
----------------------------------------------------------------------
-- Created by =F|A=Chuckun
-- If you use it, please donate to our clan to help fund the servers
-- Any amount will help!!
-- Fearless-Assassins.com
----------------------------------------------------------------------
-- For use with shrubbot, exec 'getmyguid'
----------------------------------------------------------------------

description = "silEnT GUID Command"
version = "1.0"   


function et_InitGame(levelTime,randomSeed,restart)
    local modname = string.format("%s", description)
    et.G_Print(string.format("%s loaded\n", modname))
    et.RegisterModname(modname)
end



function et_ConsoleCommand(command)
    if et.trap_Argv(0) == "getmyguid" then
        local userinfo = et.trap_GetUserinfo( playerID )
        local guid     = et.Info_ValueForKey( userinfo, "sil_guid" )
        et.trap_SendServerCommand(clientNum, "print \"^osilEnT GUID: ^7"..guid.."\n")
    end
    return 1
end

Or perhaps there's an easier way to simply print the GUID within the command's exec line, with no need for any LUA mod?


Edited by Chuckun, 27 January 2014 - 10:04 PM.


#2
OFFLINE   gaoesa

gaoesa

    Advanced Member

  • Management
  • PipPipPipPip
  • 4391 posts
341
Will become famous
  • LocationFinland

 

[command]
command  = myguid
exec     = m [i] [g]
desc     = Tell me my guid
syntax   =
levels   = 0 1 2 3 4 5

 

You could make a custom command that sends you a private message. As an alternative.



#3
OFFLINE   loudness

loudness

    Newbie

  • Members
  • Pip
  • 13 posts
6
A step in the right direction
  • LocationBucharest

----------------------------------------------------------------------
-- Filename: myguid.lua
----------------------------------------------------------------------
-- MyGUID - Prints your silEnT GUID just like /cl_guid would for etkey based GUIDs.
----------------------------------------------------------------------
-- Created by =F|A=Chuckun
-- If you use it, please donate to our clan to help fund the servers
-- Any amount will help!!
-- Fearless-Assassins.com
----------------------------------------------------------------------
-- For use with shrubbot, exec 'getmyguid'
----------------------------------------------------------------------

description = "silEnT GUID Command"
version = "1.0"   -- is not used in any function


function et_InitGame(levelTime,randomSeed,restart)
    local modname = string.format("%s", description)
    et.G_Print(string.format("%s loaded\n", modname))
    et.RegisterModname(modname)
end



function et_ConsoleCommand(clientNum, command)
    if et.trap_Argv(0) == "getmyguid" then

           local guid = et.Info_ValueForKey(et.trap_GetUserinfo(playerID),"sil_guid")

           et.trap_SendServerCommand(clientNum, "print \"^osilEnT GUID: ^7"..guid.."\n")

    return 1  ---return 1 here...if  not have getmyguid comand will be 0..unreconize comand 

   end

end

 

 

im begginer too...usualy i hunt logs for errors ....but i thik like this will work :) 

gaoesa solution is better :) no lua


Edited by loudness, 27 January 2014 - 10:51 PM.


#4
OFFLINE   Chuckun

Chuckun

    Regular Member

  • Members
  • PipPipPip
  • 130 posts
20
On a distinguished road

Thank you gaoesa and loudness! :)

 

Although I like the simplicity of the PM idea, it's a bit sloppy for my taste (i'm just quite particular I guess), but I appreciate it's functionality..

 

If anyone has a test server they could test the LUA on that would be handy :) (Moving the positive return into the scope of the IF clause as pointed out by loudness).. If not it will have to wait until I have time to do my first server setup :P


Edited by Chuckun, 28 January 2014 - 12:18 AM.


#5
OFFLINE   Micha!

Micha!

    Newbie

  • Members
  • Pip
  • 2 posts
0
Unknown

No it wont work because of:

function et_ConsoleCommand(clientNum, command)

--Called when a command is entered on the server console should be et_ClientCommand( clientNum, command ) -> Called when a command is received from a client

 
    if et.trap_Argv(0) == "getmyguid" then

           local guid = et.Info_ValueForKey(et.trap_GetUserinfo(playerID),"sil_guid")

--playerID is nil -> not defined

 

           et.trap_SendServerCommand(clientNum, "print \"^osilEnT GUID: ^7"..guid.."\n")
--clientNum is nil (see above)

    return 1  ---return 1 here...if  not have getmyguid comand will be 0..unreconize comand 

   end

end

 

 

 

fixed lua and I added !help myguid. You could also add a check level to just give it to some admins.

----------------------------------------------------------------------
-- Filename: myguid.lua
----------------------------------------------------------------------
-- MyGUID - Prints your silEnT GUID just like /cl_guid would for etkey based GUIDs.
----------------------------------------------------------------------
-- Created by =F|A=Chuckun
-- If you use it, please donate to our clan to help fund the servers
-- Any amount will help!!
-- Fearless-Assassins.com
----------------------------------------------------------------------
-- !myguid or /!myguid
----------------------------------------------------------------------

------------------------------------------ name ----------------------------------------------

Modname = "silEnT GUID Command"
Version = "1.0"

------------------------------------------ settings ----------------------------------------------

commandprefix              = "!"                --command prefix (! shrubbot like)
myguid_cmd               = "myguid"            --shrubbot command (can be shortened to example "myg"
                                            --just like !listplayers -> !list !listp !listplay
printposition              = "chat"            --message position

----------------------------------------- functions ---------------------------------------------

function et_InitGame(levelTime,randomSeed,restart)
   et.G_Print("["..Modname.."] Version: "..Version.." Loaded\n")
   et.RegisterModname(Modname.." "..Version.. " "..et.FindSelf())
end

---------------------------------- client command functions ------------------------------

function et_ClientCommand(client, command)
    local argv0 = string.lower(et.trap_Argv(0))    --first argv if you use / will be myguid_cmd
    local argv1 = string.lower(et.trap_Argv(1))    --et.trap_Argv(0) is say/say_buddy/say_team and et.trap_Argv(1) is myguid_cmd
    local argv2 = string.lower(et.trap_Argv(2))
                --string.lower so you ca write it in upper and/or lower letters
    -------//--------------------Command----------------------------
    if string.find(argv0, "^"..commandprefix.."" .. myguid_cmd .. "") or string.find(argv1, "^"..commandprefix.."" .. myguid_cmd .. "") then --use string.find so it's not needed to write full command.
        local userinfo = et.trap_GetUserinfo( client )
        local guid     = string.upper(et.Info_ValueForKey( userinfo, "sil_guid" ))
        if guid == nil or guid == "" then guid = "UNKNOWN" end    --in case client doesn't have no guid set it to UNKNOWN
        et.trap_SendServerCommand(client, ""..printposition.." \"^osilEnT GUID: ^7"..guid.."\"")
        if string.find(argv0, "^"..commandprefix.."" .. myguid_cmd .. "") then
            return 1    --return 1 so no error message will be printed^if /command is used
        end
    end
    if argv1 == ""..commandprefix.."help" and string.find(argv2, "^" .. myguid_cmd .. "") then -- !help myguid
        et.trap_SendServerCommand(client, ""..printposition.." \"^oFunction: ^7print your ^osilEnT GUID\"" )
    end
    
    return 0
end


#6
OFFLINE   Chuckun

Chuckun

    Regular Member

  • Members
  • PipPipPip
  • 130 posts
20
On a distinguished road

@Micha! - thanks for your help :) The LUA was actually to catch the server executed command via shrubbot (so user types !myguid, shrubbot catches it and execs the function defined in the LUA script - the script itsself was not supposed to catch "!myguid" as shrubbot will do that for you and exec the 'getmyguid' function :)

 

However, I've taken on board the other points you mentioned, and should be able to successfully finish the mod :)

Thank you!


Edited by Chuckun, 29 January 2014 - 09:49 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users