Page 1 of 2

lua end map

Posted: Fri Feb 08, 2008 2:07 pm
by crazyfrag
i want a lua which ends the map
but not with the timelimit cmd cause i dont want to have timelmit vote activated but a new cmd that ends the map !

greetz crazy

Posted: Sat Feb 09, 2008 7:00 am
by Deus
good luck

Re: lua end map

Posted: Sat Feb 09, 2008 7:45 am
by =FF=im2good4u
crazyfrag wrote:i want a lua which ends the map
but not with the timelimit cmd cause i dont want to have timelmit vote activated but a new cmd that ends the map !

greetz crazy
even if u have the vote disabled u cna still do it whit lua :P

Re: lua end map

Posted: Sun Feb 10, 2008 6:26 am
by Luk4ward
crazyfrag wrote:i want a lua which ends the map
but not with the timelimit cmd cause i dont want to have timelmit vote activated but a new cmd that ends the map !

greetz crazy
etadmin mod on? If yes just create new rcon cmd with timelimit 1

in lua:

Code: Select all

function et_ConsoleCommand()
   -- use string.lower to catch miscapitalized commands
   local command = string.lower(et.trap_Argv(0)) 
   
      if command == "endmap" then
      et.trap_SendConsoleCommand( et.EXEC_APPEND, "timelimit 1\n" )
      return 1
              
       else
       --for all other commands we return 0
       return 0
       
       end
end
but best way is: ref surrender imo...

Posted: Sun Feb 10, 2008 8:02 am
by crazyfrag
it tried it like this :

i create a callvote button ( callvote map mapend)
lua detectes -> Vote Passed: Change map to mapend -> sets the timelimit to 0.1

Code: Select all

function et_Print(text)
  -- text = "Vote Passed: Change map to mapend"
	 if text == "Vote Passed: Change map to mapend" then
	  et.trap_SendConsoleCommand(et.EXEC_NOW, "timelimit 0.1\n")
	
	end
end
dont work :-(

Posted: Sun Feb 10, 2008 9:20 am
by Luk4ward
crazyfrag wrote:it tried it like this :

i create a callvote button ( callvote map mapend)
lua detectes -> Vote Passed: Change map to mapend -> sets the timelimit to 0.1

Code: Select all

function et_Print(text)
  -- text = "Vote Passed: Change map to mapend"
	 if text == "Vote Passed: Change map to mapend" then
	  et.trap_SendConsoleCommand(et.EXEC_NOW, "timelimit 0.1\n")
	
	end
end
dont work :-(
eh, what a mess ;p

simply ways:
1) set vote_allow_surrender "1" (u can edit surrender to like end map)
2) set vote_allow_surrender "1" (u can edit surrender to 'end map' + change the cmd to timelimit 1)

Posted: Sun Feb 10, 2008 2:43 pm
by crazyfrag
surrender can be called by attacking team only and u need all on server to vote yes

that is a mess :-)

Posted: Sun Feb 10, 2008 9:44 pm
by Luk4ward
crazyfrag wrote:surrender can be called by attacking team only and u need all on server to vote yes

that is a mess :-)
not really, gl in complicating things

Posted: Tue Feb 12, 2008 5:03 am
by crazyfrag
i have no idea how to manage it :-(

Posted: Tue Feb 12, 2008 7:13 am
by Luk4ward
i see u want to do this via menu, so:

1) enable surrender & timelimit vote
2) edit surrender:

Code: Select all

BUTTONEXT( 6, 176, WINDOW_WIDTH-12, 14, "SURRENDER", .24, 11, exec "cmd callvote surrender"; uiScript closeingame, voteFlag CV_SVF_SURRENDER )
to

Code: Select all

BUTTONEXT( 6, 176, WINDOW_WIDTH-12, 14, "END MAP", .24, 11, exec "cmd callvote timelimit 1"; uiScript closeingame, voteFlag CV_SVF_SURRENDER )
3) create a lua cmds.lua:

Code: Select all

function et_ClientCommand(cno, cmd)

-- start of client's cmds mod:

  entered_command = string.lower(et.trap_Argv(0))
	entered_argument1 = string.lower(et.trap_Argv(1))
	entered_argument2 = string.lower(et.trap_Argv(2))


if entered_command == "callvote" then
		 
		 if entered_argument1 == "timelimit" then
	   timel = tonumber(entered_argument2)
	                  if &#40;timel <= 0&#41; or &#40;timel > 1&#41; then
	          				et.trap_SendServerCommand&#40;cno, "cpm \"^1You can vote only for end the map!\n\"" &#41;
										return 1
									  end
		 
		 elseif entered_argument1 == "surrender" then
		 et.trap_SendServerCommand&#40;cno, "cpm \"^1You can't vote for this option !\n\"" &#41;
		 return 1	
		 
		 end 
	end	 	
	

  return 0
end	
thats it...

btw surrender is working only for one side but executed from rcon the side doesnt matter, i tested it on my server with etadmin mod. You have to just create a cmd:

Code: Select all

end_map = surrender
and add

Code: Select all

end_map
to specified lvl

regards

Posted: Sun Mar 30, 2008 1:47 am
by Goomis
Luk4ward wrote: 3) create a lua cmds.lua:

Code: Select all

function et_ClientCommand&#40;cno, cmd&#41;

-- start of client's cmds mod&#58;

  entered_command = string.lower&#40;et.trap_Argv&#40;0&#41;&#41;
	entered_argument1 = string.lower&#40;et.trap_Argv&#40;1&#41;&#41;
	entered_argument2 = string.lower&#40;et.trap_Argv&#40;2&#41;&#41;


if entered_command == "callvote" then
		 
		 if entered_argument1 == "timelimit" then
	   timel = tonumber&#40;entered_argument2&#41;
	                  if &#40;timel <= 0&#41; and &#40;timel > 1&#41; then
	          				et.trap_SendServerCommand&#40;cno, "cpm "^1You can vote only for end the map!\n"" &#41;
										return 1
									  end
		 
		 elseif entered_argument1 == "surrender" then
		 et.trap_SendServerCommand&#40;cno, "cpm "^1You can't vote for this option !\n"" &#41;
		 return 1	
		 
		 end 
	end	 	
	

  return 0
end	

Code: Select all

if &#40;timel <= 0&#41; and &#40;timel > 1&#41; then
<with "and" between... lua doesn't work properly

Code: Select all

 if &#40;timel <= 0&#41; or &#40;timel > 1&#41; then
< must be "or"

>>full code

Code: Select all

function et_ClientCommand&#40;cno, cmd&#41;

-- start of client's cmds mod&#58;

  entered_command = string.lower&#40;et.trap_Argv&#40;0&#41;&#41;
   entered_argument1 = string.lower&#40;et.trap_Argv&#40;1&#41;&#41;
   entered_argument2 = string.lower&#40;et.trap_Argv&#40;2&#41;&#41;


if entered_command == "callvote" then
      
       if entered_argument1 == "timelimit" then
      timel = tonumber&#40;entered_argument2&#41;
                     if &#40;timel <= 0&#41; or &#40;timel > 1&#41; then
                         et.trap_SendServerCommand&#40;cno, "cpm "^1You can vote only for end the map!\n"" &#41;
                              return 1
                             end
      
       elseif entered_argument1 == "surrender" then
       et.trap_SendServerCommand&#40;cno, "cpm "^1You can't vote for this option !\n"" &#41;
       return 1   
      
       end
   end       
   

  return 0
end   

Posted: Sun Mar 30, 2008 2:46 am
by Luk4ward
yep, forgot to say u that xD

Posted: Sun Mar 30, 2008 6:49 am
by gotenks
Goomis wrote:

Code: Select all

if &#40;timel <= 0&#41; and &#40;timel > 1&#41; then
<with "and" between... lua doesn't work properly

Code: Select all

 if &#40;timel <= 0&#41; or &#40;timel > 1&#41; then
< must be "or"
actually if you use and... it will never execute... you can't be less then or equal to 0 and greater to 1 at the same time...
if you use or... it will always execute, so you don't even need the if statement... it will always execute, as you are always lessthen or equal to 0 or greater then 1

Posted: Sun Mar 30, 2008 3:28 pm
by Luk4ward
gotenks wrote:
Goomis wrote:

Code: Select all

if &#40;timel <= 0&#41; and &#40;timel > 1&#41; then
<with "and" between... lua doesn't work properly

Code: Select all

 if &#40;timel <= 0&#41; or &#40;timel > 1&#41; then
< must be "or"
actually if you use and... it will never execute... you can't be less then or equal to 0 and greater to 1 at the same time...
if you use or... it will always execute, so you don't even need the if statement... it will always execute, as you are always lessthen or equal to 0 or greater then 1
i know, i just said it above your post ffs.... :roll:. Goomis asked for the help so i looked into code, all the time was thinking about the or, but sent him the code with and. Ofc i know the difference, as soon as i spotted this forgot to correct the code as i said above, so dunno why u r posting all those things :shock:

Posted: Sun Mar 30, 2008 3:49 pm
by gotenks
but why do you have an if at all? it'd work the same if you removed the if statement all together, and just let the code execute,
just my stance against dirty programming