MasterTobi Posted February 10, 2010 Posted February 10, 2010 hey hey in c++ or delphi , i can write switch(variable) { case 1: blalbla;exit case 2: blalbla;exit case 3: blalbla;exit ..... } it gives such a thing also in lua ?
50p Posted February 10, 2010 Posted February 10, 2010 There is no switch in Lua. You have to use if, elseif and else statements instead. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
robhol Posted February 10, 2010 Posted February 10, 2010 Technically, you can also assign anonymous functions to a table and call it with your "switch" value as an index. However, depending on how many possibilities there are, you may be better off with simple if/elseif/else constructs as 50p says. if there are only 4-5 possibilities, a table with functions would be kinda overkill. Do NOT PM ME for help unless invited. - New MTA Script Editor Scripting help "etiquette": understandable language, relevant code (ALL code if unsure), [Lua] tags, error messages with line numbers. Super simple stuff.
MasterTobi Posted February 10, 2010 Author Posted February 10, 2010 ah ok spezial thx then i use if elseif
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now