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 help

- - - - - lua

  • Please log in to reply
No replies to this topic

#1
OFFLINE   roissgil

roissgil

    Member

  • Members
  • PipPip
  • 25 posts
2
A step in the right direction

I'm a lua noob, but would appreciate any help.  I'm trying to modify some code I found.   I want it to be used as a shrubbot command that would return in console to the requestor the number of empty slots on the server (excluding private slots).  This is the code I'm using and I'm sure there's a lot wrong with it as it doesn't do anything at all.

	function et_ClientCommand(clientNum, command)
             if et.trap_Argv (0) == "lua" then	
		if et.trap_Argv( 1 ) == "free" then
			local playercount = 0
			local slots = 0
                        maxclients = tonumber( et.trap_Cvar_Get( "sv_maxClients" ) )
		          for i = 6, (maxclients - 1) do
			    if et.gentity_get(i, "sess.sessionTeam") ~= 0 then
                            playercount = playercount + 1
			  end	
		-- -7 = 6 for priv slots and 1 because of slots are numbered from 0-33
		slots = maxclients - playercount - 7  
		et.trap_SendServerCommand(clientnum, 'print "^qFree Slots " slots' )  
		end
             end
         end

The shrubbot command is:

[command]
command = free
exec = lua free [1]
desc = displays number of free slots (not including private slots)
levels = 0 1 2 3 4 5

Would anyone please point out the multitude of things I probably did wrong?  :D

Thanks

 







Also tagged with one or more of these keywords: lua

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users