Jump to content

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

Lua problem.

- - - - -

  • Please log in to reply
1 reply to this topic

#1
OFFLINE   Purple

Purple

    Advanced Member

  • Banned
  • PipPipPipPip
  • 157 posts
56
Getting Better

hello i'm having a small lua problem that i'm pretty sure i'm over looking could someone here take a look? 

function et_ClientConnect( cno, firstTime, isBot )
 
    if isBot ~= 1 and firstTime == 1 then
        local userinfo = et.trap_GetUserinfo(cno)
        local protocol = tostring(et.Info_ValueForKey(userinfo, "protocol"))
		
	--[[
	
	 Checking the protcol of each client that connects.
	
	--]]
        if protocol == nil then
            clientversion = "*unknown*"
        elseif protocol == "" then
            clientversion = "missing protocol"
        elseif protocol == "82" then
            clientversion = "2.55"
        elseif protocol == "83" then
            clientversion = "2.56"
        elseif protocol == "84" then
            clientversion = "2.60b"
        end
       -- ..playerName(cno).. / <country> / ..clientversion..  / ..client..
	    local message = "^1C^0onnect^1I^0nfo^1:^7 "..playerName(cno).."^7 connected from ^3<country> ^7using client (^3"..client.."^7)(^3"..clientversion.."^7)"
        local msg = string.gsub(message, ""..playerName(cno).."", et.Info_ValueForKey( et.trap_GetUserinfo( cno ), "name" ))
        local countryCode = et.gentity_get( cno, "sess.uci" )
        local countryName = countries[countryCode]
 
 	--[[
	
	 Grabbing the country name
	
	--]]
        if countryName then
            msg = string.gsub(msg, "<country>", countryName)
        else
            msg = string.gsub(msg, "<country>", countryCode)
        end
		
	--[[
	
	 Checking to see if TBS connects and removing it. Then printing out the actual connect message.
	
	--]]
		
		if playerName(cno) ~= "^nTBS" then
			et.trap_SendConsoleCommand(et.EXEC_APPEND,"qsay " .. msg)
		end
    end
 
end

and 

function et_ClientBinary( clientNum, checksum)
	local binary = checksum
	
	--[[
	
	 Checking users binaries so we can print them out in the connect line.
	
	--]]
	if binary == nil then
		client = "Unknown"
	elseif binary == "EB19F81EEFD8F300148BD73D2133304D" then
		client = "ET Legacy 2.71rc3"
	elseif binary == "C786FB8512A79E7910A111A0EE7CCF18" then
		client = "ET Gold 2.71"
	elseif binary == "1B9345CB23469C547E7E0BFA080C1B5B" then
		client = "ET Gold 2.72"
	elseif binary == "2FCE329CE3F5552C148E4BCE5803A60D" then
		client = "ET Gold 2.73"
	elseif binary == "5F12F1718A84B8FC45AAEE609CFC9C43" then
		client = "ET Offcial"
	elseif binary == "1364CA4CF09FE15BC9FE3DCD75C899F8" then
		client = "ET Offcial"
	end
	return 0
end 

So my problem is i'm wanting to check users client binaries and print them out when they connect to the server, but i am getting a small error when users connect. The error is "attempt to concatenate global 'client' (a nil value) I'm pretty sure its something small i'm doing wrong does anyone have any suggestions or a way to fix it Thanks in advanced.



#2
OFFLINE   Sol

Sol

    Regular Member

  • Coders
  • PipPipPip
  • 113 posts
28
On a distinguished road
  • LocationPoland

Probably et_ClientConnect is called first thats why 'client' is empty.

That's not good idea to use one global variable for all clients, you should consider to use a table.

Try to use et_ClientBegin instead of et_ClientConnect it's called after et_ClientConnect for sure.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users