banimod / etpro / ettv forums Forum Index banimod / etpro / ettv forums
Bani's Discussion Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

lua end map
Goto page 1, 2  Next
 
Post new topic   Reply to topic    banimod / etpro / ettv forums Forum Index -> ET Modding
View previous topic :: View next topic  
Author Message
crazyfrag



Joined: 01 Oct 2004
Posts: 105

PostPosted: Fri Feb 08, 2008 2:07 pm    Post subject: lua end map Reply with quote

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
Back to top
View user's profile Send private message MSN Messenger
Deus



Joined: 12 Mar 2004
Posts: 1053
Location: Germany

PostPosted: Sat Feb 09, 2008 7:00 am    Post subject: Reply with quote

good luck
_________________

http://spielwelt15.monstersgame.net/?ac=vid&vid=39033566
Back to top
View user's profile Send private message Visit poster's website
=FF=im2good4u



Joined: 05 Feb 2003
Posts: 3925
Location: The Netherlands, HOLLAND

PostPosted: Sat Feb 09, 2008 7:45 am    Post subject: Re: lua end map Reply with quote

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 Razz
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Luk4ward



Joined: 30 Jul 2006
Posts: 236
Location: Poland

PostPosted: Sun Feb 10, 2008 6:26 am    Post subject: Re: lua end map Reply with quote

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:

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
Back to top
View user's profile Send private message Visit poster's website
crazyfrag



Joined: 01 Oct 2004
Posts: 105

PostPosted: Sun Feb 10, 2008 8:02 am    Post subject: Reply with quote

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:
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 Sad
Back to top
View user's profile Send private message MSN Messenger
Luk4ward



Joined: 30 Jul 2006
Posts: 236
Location: Poland

PostPosted: Sun Feb 10, 2008 9:20 am    Post subject: Reply with quote

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:
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 Sad


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
Back to top
View user's profile Send private message Visit poster's website
crazyfrag



Joined: 01 Oct 2004
Posts: 105

PostPosted: Sun Feb 10, 2008 2:43 pm    Post subject: Reply with quote

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

that is a mess Smile
Back to top
View user's profile Send private message MSN Messenger
Luk4ward



Joined: 30 Jul 2006
Posts: 236
Location: Poland

PostPosted: Sun Feb 10, 2008 9:44 pm    Post subject: Reply with quote

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

that is a mess Smile


not really, gl in complicating things
_________________
wolFTeam.pl
Back to top
View user's profile Send private message Visit poster's website
crazyfrag



Joined: 01 Oct 2004
Posts: 105

PostPosted: Tue Feb 12, 2008 5:03 am    Post subject: Reply with quote

i have no idea how to manage it Sad
Back to top
View user's profile Send private message MSN Messenger
Luk4ward



Joined: 30 Jul 2006
Posts: 236
Location: Poland

PostPosted: Tue Feb 12, 2008 7:13 am    Post subject: Reply with quote

i see u want to do this via menu, so:

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

Code:

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


to

Code:

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:

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 (timel <= 0) or (timel > 1) then
                         et.trap_SendServerCommand(cno, "cpm \"^1You can vote only for end the map!\n\"" )
                              return 1
                             end
      
       elseif entered_argument1 == "surrender" then
       et.trap_SendServerCommand(cno, "cpm \"^1You can't vote for this option !\n\"" )
       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:

end_map = surrender


and add
Code:
end_map
to specified lvl

regards
_________________
wolFTeam.pl


Last edited by Luk4ward on Sun Mar 30, 2008 3:29 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Goomis



Joined: 25 Mar 2007
Posts: 3

PostPosted: Sun Mar 30, 2008 1:47 am    Post subject: Reply with quote

Luk4ward wrote:

3) create a lua cmds.lua:

Code:

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 (timel <= 0) and (timel > 1) then
                         et.trap_SendServerCommand(cno, "cpm \"^1You can vote only for end the map!\n\"" )
                              return 1
                             end
      
       elseif entered_argument1 == "surrender" then
       et.trap_SendServerCommand(cno, "cpm \"^1You can't vote for this option !\n\"" )
       return 1   
      
       end
   end       
   

  return 0
end   



Code:
if (timel <= 0) and (timel > 1) then
<with "and" between... lua doesn't work properly
Code:
 if (timel <= 0) or (timel > 1) then
< must be "or"

>>full code

Code:
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 (timel <= 0) or (timel > 1) then
                         et.trap_SendServerCommand(cno, "cpm \"^1You can vote only for end the map!\n\"" )
                              return 1
                             end
     
       elseif entered_argument1 == "surrender" then
       et.trap_SendServerCommand(cno, "cpm \"^1You can't vote for this option !\n\"" )
       return 1   
     
       end
   end       
   

  return 0
end   
Back to top
View user's profile Send private message
Luk4ward



Joined: 30 Jul 2006
Posts: 236
Location: Poland

PostPosted: Sun Mar 30, 2008 2:46 am    Post subject: Reply with quote

yep, forgot to say u that xD
_________________
wolFTeam.pl
Back to top
View user's profile Send private message Visit poster's website
gotenks



Joined: 15 Nov 2002
Posts: 4040
Location: out of my mind

PostPosted: Sun Mar 30, 2008 6:49 am    Post subject: Reply with quote

Goomis wrote:

Code:
if (timel <= 0) and (timel > 1) then
<with "and" between... lua doesn't work properly
Code:
 if (timel <= 0) or (timel > 1) 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

After a night of binge drinking:
=FF=im2good4u wrote:
WTF wanst i on top ?
Back to top
View user's profile Send private message Visit poster's website
Luk4ward



Joined: 30 Jul 2006
Posts: 236
Location: Poland

PostPosted: Sun Mar 30, 2008 3:28 pm    Post subject: Reply with quote

gotenks wrote:
Goomis wrote:

Code:
if (timel <= 0) and (timel > 1) then
<with "and" between... lua doesn't work properly
Code:
 if (timel <= 0) or (timel > 1) 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.... Rolling Eyes. 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 Shocked
_________________
wolFTeam.pl
Back to top
View user's profile Send private message Visit poster's website
gotenks



Joined: 15 Nov 2002
Posts: 4040
Location: out of my mind

PostPosted: Sun Mar 30, 2008 3:49 pm    Post subject: Reply with quote

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

After a night of binge drinking:
=FF=im2good4u wrote:
WTF wanst i on top ?
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    banimod / etpro / ettv forums Forum Index -> ET Modding All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group