Jump to content


MTA Contributors
  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About driver2

  • Rank
    MTA Contributor


  • Gang
    Hells Angels

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Just one thing about that admin login. Maybe it was just an excercise to learn scripting, but you should be aware that clientside scripts are not safe for that kind of things. That password could simply be read by looking at the script, since it is downloaded to each player. They are stored in MTA\mods\deathmatch\resources. Clientside scripts should never be used to do anything security related.
  2. "Table" is the datastructure of Lua that can be used as an array, list or even class. The ipairs() iterator only works with increasing indices (1,2,3,4, ..). If you want to loop through all numbers, use a numeric for loop: for i = 1,10 do .. end -- loops from 1 to 10 in steps of 1 If you want to loop through all elements of a table in no particular order, use pairs(): for k,v in pairs(table) do .. end Maybe you also want to use table.insert() and table.remove() which shifts the indices to create increasing indices. http://lua-users.org/wiki/ForTutorial http://www.lua.org/manual/
  3. You have to use onClientRender to draw the lines, because it only draws them for one frame. It won't be any stress for the server, since it's clientside. The Client however may loose a considerable amount of fps, depending on how much static you draw and how. I just made a quick test: local w,h = guiGetScreenSize() local startX = 1 local time = 0 local previousTime = nil local direction = 1 local waitFor = 0 local static = {} local amountOfStatic = 2 local waitChance = 1 function draw() local amount = w/10 if not previousTime then previousTime = getTickCount() return end if math.random
  4. Adding rows to SQLite is considerably slower than reading data. However, you also have to use it correctly to make a fair comparison. I'm certainly no expert, but here's an interesting comparison: I added 100 rows to an empty table, which took about 8.8590 seconds. Then I used "BEGIN" and "COMMIT" (http://www.sqlite.org/lang_transaction.html) to send it all in one transaction, and it took only 0.1090 seconds. That's not always usable of course, but if you add much data at once, it can be useful (much like prepared statements in MySQLi, even if the method might be different). Also, if you comp
  5. Hi, I was thinking how the performance of using account data compares to using SQLite for saving/accessing account-related stuff. The advantage of account data is that it's easy to use and it is stored together with the accounts, which is sensible for stuff closely related to the account (like register date or something). However if you have a lot of accounts (let's say a few hundred) and want to filter or sort them by register date (or anything else), I was wondering if SQLite wasn't better suited for that. What do you think? Greetings
  6. What about if it's not in the meta.xml? Note that I would NOT like to have that function, so other servers CAN'T read the file. The server who has written it obviously knows the filename.
  7. Hi, say there's a file saved in a clienside resource directory called '8902342348092349908.xml'. Is there any way to read that from a clientside resource without knowing it's name? Like list all files in the directory? I want to save a file that can only be read by the server who has written it. Greetings
  8. You could probably use string.find() while looping through all players. Be careful to set the plain-argument to true, or else you might accidently use lua patterns. You should also check if there was more than one match, else you could accidently execute the command on someone you didn't intend to.
  9. driver2


    How about reading the readme?
  10. This is what it says in the WIKI Yes, but only if you use parameter binding. If you just put the values directly in the query string, it can't escape them to prevent SQL Injection. The function doesn't prevent you from doing it 'wrong'. Just use the method with the questionmarks, that way the function will know which part of the query is a value and create a safe query for you.
  11. driver2


    Maybe try this: http://community.mtasa.com/index.php?p= ... ils&id=612
  12. onClientPlayerJoin is not triggered for the local player. What you want is onClientResourceStart: addEventHandler("onClientResourceStart",getResourceRootElement(),LoginWindow)
  13. Something like that seems problematic to me or is SQL Injection no issue in MTA/SQLite? Why not use parameter binding? executeSQLQuery("UPDATE yourTableName SET SpawnX = ?, SpawnY = ?, SpawnZ = ? WHERE Name = ?",x,y,z,getPlayerName(theplayer)) Of course it depends on where you get your data from. But even something like the player name is a value the user inputs. I don't know if or how much damage could be done, but I guess parameter binding should be safer.
  14. I think lua is pretty easy and flexible to use. The tables are extremely versatile, e.g. you can use anything as a key, even another table. You don't have to predefine the size or somehting. Functions can return multiple values, which can come in very handy, e.g. you could return a boolean to say if a function succeded, as well as a message that contains the reason. And of course there are functions like getElementPosition() which you can use like that: local x,y,z = getElementPosition() Instead of: local pos = getElementPosision() -- would have to return a table to return several val
  • Create New...