Jump to content

Cassandra

Members
  • Posts

    200
  • Joined

  • Last visited

Everything posted by Cassandra

  1. This is the code: local tempDat = { "hasAccount", "loggedIn" } function PlayerSave(player) for k, v in pairs(getAllElementData(player)) do for z, x in pairs(impDat) do if k ~= x then print(tostring(k) .." " .. tostring(v)) dbExec(db, "UPDATE `account` SET `??` = ? WHERE `username` = ?", k, v, getPlayerName(player)) end end end end What I want to do is to ignore the values as keys in tempDat when updating the database. But the problem is that it still includes those values. What should be done in order to fix it? Is there another way to solve the problem?
  2. I will try to study it a bit by experimenting with it. If any problem, I will share it here.
  3. The ACL thingy is really confusing. More confusing than building the MTA system
  4. Wouldn't it be much simpler using this? > name="Police"> name="command.arrest" access="true" /> > name="Criminal"> name="command.arrest" access="false" /> >>
  5. Could you please elaborate your statement?
  6. I want to know the difference between acl and group.
  7. Hello Guys/Gals. I'm looking for an in-depth tutorial about ACL. I have already saw this https://wiki.multitheftauto.com/wiki/ACL
  8. Cassandra

    Button color

    Is it dxGUI or MTA GUI? If it's MTA GUI then you cannot change it because the style is derived from the theme file.
  9. As I said earlier it's not OOP but a part of it, thus the heading says "Object Behavior".
  10. It's not oop. Learn http://lua-users.org/wiki/ObjectOrientedProgramming It's part of OOP.
  11. [TIPS & TRICKS] LUA Prolusion I want to depict few tips and tricks on LUA which new scripters may/may not know. Assigning a value which is not nil I saw most scripters does that using the following code: local someVar = anotherVar if someVar == nil then someVar = 10 end Which can be shortened to this: local someVar = anotherVar or 10 This is what LUA is doing. It takes the anotherVar, and if it's nil or false it will use the value which is after the or statement. You can also do it more than once: local someVar = anotherVar or otherAnotherVar or justSomeVar or 10 The same thing can be done inside a function as well. Singular Check This is a nice trick which allows you to make singular checks more efficient than before. The following code: local someCondition = "Yes" local someVar = 5 if someCondition == "Yes" then someVar = 10 else someVar = 0 end Which can be shortened to this: local someVar = (someCondition == "Yes") and 10 or 5 This is how LUA understand. If the condition is true(which is someCondition on the example) it will assign the value of someVar to whatever the value is after the and operator and if it's false or nil the value after or operator will be assigned. Ignore Parenthesis Yet another simple trick. The following code: function doSomething(doWhat) if type(doWhat) == "string" then print(doWhat) end end doSomething("Hey now brown cow.") Which can also written like this: function doSomething(doWhat) if type(doWhat) == "string" then print(doWhat) end end doSomething"Hey now brown cow." When the first and only argument to a function is a string or a table you can ignore the parenthesis. Named Arguments Named arguments is a system where a function takes a table of named arguments instead of individual arguments. This allows the function to be called with missing arguments. That's how I define it Use the following code: local function someThing(player) print(player.Name) print(player.Exp) print(player.Health) end someThing{Name = "Cassandra", Age = 199, Health = 0.5} Then you can also ignore argument: someThing{Name = "Cassandra", Health = 0.5} Instead of: someFunc("Cassandra", nil, 0.5) For Loop Optimization Access to external locals (that is, variables that are local to an enclosing function) is not as fast as access to local variables, but it is still faster than access to globals. The following code: for i = 1, 1000000 do x = x + math.sqrt(i) end Can be optimized to: local squareRoot = math.sqrt for i = 1, 1000000 do x = x + squareRoot (i) end Object Behavior from OOP You can use object behavior from Object Oriented Programming inside LUA too using tables. Consider using this: AnObject = {}; AnObject.AFunction = function () print"I am an object yeppie!" end AnObject.AFunction(); --Which call the AFunction inside AnObject class. Whenever I discover something new, I will attempt to share it here.
  12. Cassandra

    Delete This!

    This isn't even worth 1 pence.
  13. It's quite nice despite your first mission with no experience or whatsoever.
  14. That's true, MTA:SA needs more fixes and to start another project while another popular game is still running, well that would be disappointing for all the SA players... plus we have a small team of MTA Devs... SA is one of those games that adds another life/gameplay in our lives, even though we would like to see it in HQ/HD, but that's what the MTA Devs tried to do by adding shaders and more, just to increase the graphics on SA. I agree.
  15. It's 15%. It's 100% You are talking about 1.4 right? Check out the road map once again.
  16. Cassandra

    EURO 2012

    But at the end, it's going to be Spain who will win it. The final would be Germany against Spain and the score would be 2-1 (Torres, Iniesta, Ozil/Gomez)
  17. And the one which is made by MTA Team works faster and simpler than the module.
  18. Cassandra

    MTASA: 1.3.1

    If I'm not mistaken, Isn't MTA 1.3.1 already released?
  19. A: Einstein does. Q: How to get the radius of a rectangular field?
×
×
  • Create New...