Jump to content

lua help


tapir76

Recommended Posts

  • Subscriber

hello

I need help
how to put expand this script to be able to use this command to enable or disable something

I mean to use the command " blabla on" " blabla off"

 

 

 

 

 

use_cmd = 1

         

  

function et_ClientCommand(clientNum, command)

        

         command = string.lower(command)

   if (command == "blabla")

  and (use_cmd == 1) then

   for i=1,1 do

         et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^...............     \n")

   end

  return 1

 

end

end

Link to comment
Share on other sites

It can not be used like this way, you have to storage value somewhere.

The best way to storage values is MySQL or Filesystem but its more advanced.

You can do this instead:

CVARNAME = "storage"

function et_InitGame( levelTime, randomSeed, restart )
	if et.trap_Cvar_Get( CVARNAME ) == nil then
		et.trap_SendConsoleCommand(et.EXEC_APPEND, string.format("seta %s 0\n", CVARNAME ))
	end
end

function et_ClientCommand( num, cmd )
	if cmd == "blabla" then
		if tonumber(et.trap_Cvar_Get( CVARNAME )) == 0 then
			-- Enable something
			et.trap_Cvar_Set(CVARNAME, 1)
		else
			-- Disable something
			et.trap_Cvar_Set(CVARNAME, 0)
		end
	end
end
Edited by Sol
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...