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

- - - - -

  • Please log in to reply
3 replies to this topic

#1
OFFLINE   tapir76

tapir76

    Member

  • Subscriber
  • PipPip
  • 31 posts
1
A step in the right direction
  • LocationPoland Krk

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



#2
OFFLINE   Sol

Sol

    Regular Member

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

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, 17 September 2013 - 02:53 PM.


#3
OFFLINE   tapir76

tapir76

    Member

  • Subscriber
  • PipPip
  • 31 posts
1
A step in the right direction
  • LocationPoland Krk

Thank you
And how do you add more commands operating in the same way?

in CVARNAME?



#4
OFFLINE   Sol

Sol

    Regular Member

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

Thank you
And how do you add more commands operating in the same way?

in CVARNAME?

No, you have to add another cvar for it, but there's no point doing it in such a way.

You sould use MySQL or file






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users