lua end map

Discussions about ET modding (sdk code, player/weapon modeling)

Moderators: Forum moderators, developers

crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

lua end map

Post 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
User avatar
Deus
Posts: 1053
Joined: Fri Mar 12, 2004 2:24 am
Location: Germany
Contact:

Post by Deus »

good luck
User avatar
=FF=im2good4u
Posts: 3821
Joined: Wed Feb 05, 2003 7:30 am
Location: The Netherlands, HOLLAND
Contact:

Re: lua end map

Post 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
User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

Re: lua end map

Post 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...
wolFTeam.pl
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post 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 :-(
User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

Post 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)
wolFTeam.pl
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

surrender can be called by attacking team only and u need all on server to vote yes

that is a mess :-)
User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

Post 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
wolFTeam.pl
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

i have no idea how to manage it :-(
User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

Post 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
Last edited by Luk4ward on Sun Mar 30, 2008 3:29 pm, edited 1 time in total.
wolFTeam.pl
Goomis
Posts: 3
Joined: Sun Mar 25, 2007 1:34 am

Post 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   
User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

Post by Luk4ward »

yep, forgot to say u that xD
wolFTeam.pl
User avatar
gotenks
Posts: 3465
Joined: Fri Nov 15, 2002 4:12 pm
Location: out of my mind
Contact:

Post 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
My Website
Image
After a night of binge drinking:
=FF=im2good4u wrote:WTF wanst i on top ?
User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

Post 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:
wolFTeam.pl
User avatar
gotenks
Posts: 3465
Joined: Fri Nov 15, 2002 4:12 pm
Location: out of my mind
Contact:

Post 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
My Website
Image
After a night of binge drinking:
=FF=im2good4u wrote:WTF wanst i on top ?
Post Reply