lua: removed nested ifs

hopefully this is much better
This commit is contained in:
Rafał Pawlak 2016-10-20 19:55:37 +02:00
parent 8ef8943618
commit 8fabe956de

View file

@ -1,5 +1,5 @@
modname = "Banners"
version = "0.2"
version = "0.3"
welcome = "^WELCOME MESSAGE" -- Welcome message here when client finished connecting to the server
@ -22,53 +22,42 @@ timer5 = 0
-------------------- SAMPLE -----------------------------------------------------------------------------------
-- timer = 100000
-- timer1 = 5000
-- timer2 = 6000 ARE THOSE VALUES CORRECT AND MAKE SENSE HERE
-- timer3 = 7000 OR ALL THEY SHOULD BE REPLACED BY 1000 ? (BUT THIS WAY MIGHT GET MESSY)
-- timer4 = 8000
-- timer5 = 9000
-- timer1 = 105000
-- timer2 = 106000 ARE THOSE VALUES CORRECT AND MAKE SENSE HERE
-- timer3 = 107000 OR ALL THEY SHOULD BE REPLACED BY 1000 ? (BUT THIS WAY MIGHT GET MESSY)
-- timer4 = 108000
-- timer5 = 109000
-------------------------------------------------------------------------------------------------------------------
------------------ TODO! ------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------
-- print welcome message to connected client to show gratitude for client
-- Get millisec value then increase it with timer's values
-- Get millisec value
-- FIND OUT HOW TO MAKE IT INTO LOOP!!
-- Do a conditional statement if/elseif/else comparing
-------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------
------------------------------------------!!DO NOT CHANGE BELOW!!--------------------------------------------------
function et_InitGame( levelTime, randomSeed, restart )
et.RegisterModname( modname .. " " .. version )
local milliseconds = et.trap_Milliseconds() -- is this right way ?
local a = (milliseconds*1000)/60
if(milliseconds == timer)
if(a == timer)
et.trap_SendServerCommand(clientNum, "cpm \"" .. banner .."^7\n")
if(milliseconds == timer1)
elseif(a == timer1)
et.trap_SendServerCommand(clientNum, "cpm \"" .. banner1 .."^7\n")
if(miliseconds == timer2)
elseif(a == timer2)
et.trap_SendServerCommand(clientNum, "cpm \"" .. banner2 .."^7\n")
if(miliseconds == timer3)
elseif(a == timer3)
et.trap_SendServerCommand(clientNum, "cpm \"" .. banner3 .."^7\n")
if(miliseconds == timer4)
elseif(a == timer4)
et.trap_SendServerCommand(clientNum, "cpm \"" .. banner4 .."^7\n")
if(miliseconds == timer5)
elseif(a == timer5)
et.trap_SendServerCommand(clientNum, "cpm \"" .. banner5 .."^7\n")
end -- is every if() statement needs else() ??
end
end
end
end
else
et.trap_SendServerCommand(clientNum, "cpm \"" .. "NO BANNERS" .."^7\n")
end
@ -77,7 +66,6 @@ end
function et_ClientConnect( clientNum, firstTime, isBot )
et.trap_SendServerCommand(clientNum, "cpm \"" .. welcome .."^7\n")
end
function et_ShutdownGame( restart )