Jump to content

driver2

MTA Contributors
  • Posts

    139
  • Joined

  • Last visited

Everything posted by driver2

  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/5.1/manual.html#5.5
  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(0,1000) == 0 then return end time = time + getTickCount() - previousTime previousTime = getTickCount() for i=1,amountOfStatic do if static[i] == nil then static[i] = { direction=1, waitFor=0, startX=0 } end if math.random(1,100*i*waitChance) == 1 then static[i].waitFor = getTickCount() + math.random(100,2000) end if static[i].waitFor > getTickCount() then break end if math.random(1,20) == 1 and time > 1*1000 then static[i].startX = math.random(1,w) time = 0 else if math.random(1,20) == 1 then static[i].direction = math.random(-4,4) end static[i].startX = static[i].startX + static[i].direction end local startX = static[i].startX local startY = 1 while startY < h do local length = math.random(1,6) if math.random(1,4) == 1 then local x = startX + math.random(1,2) dxDrawLine(x,startY,x,startY+length,tocolor(255,255,255,math.random(80,150))) end if math.random(1,4) == 1 then local x = startX + math.random(-30,30) dxDrawLine(x,startY,x,startY+1,tocolor(255,255,255,math.random(100,255))) end startY = startY + length end end for i=1,amountOfStatic*10 do local x = math.random(1,w) local y = math.random(1,h) local length = 1 local color = tocolor(255,255,255,math.random(100,255)) --dxDrawLine(x,y,x+1,y+length,color,1,true) end end local showStatic = true addCommandHandler("static",function() if showStatic then addEventHandler("onClientRender",getRootElement(),draw) else removeEventHandler("onClientRender",getRootElement(),draw) end showStatic = not showStatic end) Maybe it is useful for you, just play with it a bit. There may be better way to do it though. It also shows the addEventHandler/removeEventHandler which works fine for me.
  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 compare it with MySQL, you also have to take into account that not everyone may have access to a MySQL database on the same server and sending it to another takes again more time, depending on the connection.
  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

    Teams

    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

    Teams

    Maybe try this: https://community.multitheftauto.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 values local x = pos.x local y = pos.y local z = pos.z Of course you first have to get used to a new language.
  15. I don't know exactly how Pawn works, but you don't need to predefine the keys you want to use in a table. -- structura pInfo = { pSQLID, pAdmin, pLevel,} gPlayerInfo = {} for i=1,100 do gPlayerInfo[i] = pInfo end What you do here is create a table that contains no element at all, because you add 3 variables to it (pSQLID, pAdmin, pLevel) that will have the value "nil" if you haven't assigned a value to them before. This is basicially the same as: pInfo = {} pInfo[1] = nil pInfo[2] = nil pInfo[3] = nil This obviously doesn't do you any good. Then you add the empty table 100 times to the gPlayerInfo table. function joinHandler() gPlayerInfo[source][pLevel] =1; end This doesn't work because gPlayerInfo[source] is not a table, so you can't access it. And again, pLevel is used as a variable, and is probably nil, unless you defined it as a global (at least to the file) variable. What you want to do here is: function joinHandler() gPlayerInfo[source] = {} -- create an empty table for this player element gPlayerInfo[source].pLevel = 1 -- Add the number '1' to the table element with the key 'pLevel' (this is the same as gPlayerInfo[source]["pLevel"] = 1 end function DebugFunction() outputChatBox ( "Variabila are " .. gPlayerInfo[source][pLevel] .. " valoarea ",thePlayer ) end This won't work for the same reason, gPlayerInfo[source] doesn't exist and pLevel is expected to be a variable. Also, I don't think that "source" exists in this context. Also you haven't defined "thePlayer", so it will be nil and thus displayed for all players (since the default will be used then, which is getRootElement()). You can access the value like that: function DebugFunction() local player = ... outputChatBox("Value: "..tostring(gPlayerInfo[player].pLevel)) end You have to define "player" somehow though. You could use getPlayerFromName() or just loop through the whole table, for example: function DebugFunction() for k,v in pairs(gPlayerInfo) do outputChatBox("Value for player "..getPlayerName(k).." is "..tostring(v.pLevel)) end end
  16. First of all: It is unlikely that you will find a scripter for your project here. Most scripters are already busy with their own projects and don't have time for something else. And even if they have time, they will most likely only work on something they think is cool (unless maybe you pay them). So, if you still want to try it, at least give some information about your project, for example: - What exactly are you planning to do (not just "a new gamemode", give more details). - What do you already have (have you already started or does it have to be done from scratch). - What do you expect the scripter that helps you to do (e.g. do you script yourself and only need someone for the GUI). - If you are willing to pay for the work or not. This way you MIGHT catch someone's interest. There might also be someone else already working on someone similiar, who could be willing to pool resources. But of course there's no guarantee that you will find someone. There are many threads where someone searches for a scripter, and it seems without much success: https://forum.multitheftauto.com/viewtop ... 91&t=26538 https://forum.multitheftauto.com/viewtop ... 91&t=26510 https://forum.multitheftauto.com/viewtop ... 91&t=26504 You could also check out https://community.multitheftauto.com/index.php?p=resources and maybe you will find what you want to make to be already there. PLEASE NOTE This is not a thread for REQUESTING scripters. This is a thread to avoid people requesting scripters, because there used to be dozens of those threads and almost NONE of them actually got what they asked for. Addition by robhol
  17. Hi, from what I understand element data is only synced when it is set, is that correct? So if I was to set element data once at the start of the script, it should only be synced and not cause anymore network traffic. Greetings
  18. I guess most scripters are working for free, but on their OWN projects. So if you want to have any chance of finding a scripter, you shoud at least describe your project, maybe show some screenshots or whatever. That way, MAYBE someone will think its worth contributing to. Maybe someone even works on something similiar and you can pool your resources. But if you just say "a new gamemode", that doesn't sound very exciting.
  19. Your resource is probably not allowed to use this function. To change this, you need to edit the ACL. You can do this by editing the acl.xml file or via the webadmin. You can either simply add your resource to the "Admin"-group or create your own group with the rights your resource needs. The admin-resource is in the "Admin"-group, that's why it is allowed to use this function: <group name="Admin"> <acl name="Moderator" /> <acl name="SuperModerator" /> <acl name="Admin" /> <acl name="RPC" /> <object name="resource.admin" /> <object name="resource.webadmin" /> </group>
  20. Maybe calculate a score based on how many different servers an IP is banned. Then let the serverowner decide what to do with this score, when a suspected cheater joins. Ban him or maybe just warn. If you want to make it even more complicated, you could assign the individual servers a score based on how many 'good' bans he had in the past and calculate the 'ban score' based on that as well. This would of course delay the banning of cheaters, since the cheater must be banned on several servers using this system before he is banned on others (there would still be the benefit of warning that a cheater may have joined though), but also prevent abuse by a single severadmin. You should maybe also not save every ban in the blacklist. Sometimes someone might be banned for different reasons than cheating (after all, it's up to the individual serverowner who to ban) which would not be compliant with the blacklist. Maybe only send it to the blacklist, when it contains the reason "cheat" or something (maybe also make it optional). I also suggest you use the built-in settings system, which will enable the serveradmins to change the settings via the admin resource, which might be a bit more comfortable than editing a file (and players won't need to download the file again when joining another server, since it stays the same).
  21. Maybe calculate a score based on how many different servers an IP is banned. Then let the serverowner decide what to do with this score, when a suspected cheater joins. Ban him or maybe just warn. If you want to make it even more complicated, you could assign the individual servers a score based on how many 'good' bans he had in the past and calculate the 'ban score' based on that as well. This would of course delay the banning of cheaters, since the cheater must be banned on several servers using this system before he is banned on others (there would still be the benefit of warning that a cheater may have joined though), but also prevent abuse by a single severadmin. You should maybe also not save every ban in the blacklist. Sometimes someone might be banned for different reasons than cheating (after all, it's up to the individual serverowner who to ban) which would not be compliant with the blacklist. Maybe only send it to the blacklist, when it contains the reason "cheat" or something (maybe also make it optional). I also suggest you use the built-in settings system, which will enable the serveradmins to change the settings via the admin resource, which might be a bit more comfortable than editing a file (and players won't need to download the file again when joining another server, since it stays the same).
  22. driver2

    Licensing

    Hi, from what I know from other places, released programs are usually put under some sort of license, which is then mentioned in each file. I've haven't seen any sort of license notice in a MTA resource yet and I wonder why. 1. Don't people want to release their code under a 'free' license (no license normally means it's protected under copyright or similiar laws) 2. Don't people know about licenses in general 3. Do people not consider MTA resources 'real' programs 4. Do they just not care I would like to know your opinion on this. Greetings
  23. driver2

    Licensing

    Hi, from what I know from other places, released programs are usually put under some sort of license, which is then mentioned in each file. I've haven't seen any sort of license notice in a MTA resource yet and I wonder why. 1. Don't people want to release their code under a 'free' license (no license normally means it's protected under copyright or similiar laws) 2. Don't people know about licenses in general 3. Do people not consider MTA resources 'real' programs 4. Do they just not care I would like to know your opinion on this. Greetings
  24. Hi, I finally released my speedometer. I wasn't really satisfied with the speedometers that were already there, and of course it's fun to make something yourself. So what is special about this one? It's design is pretty plain, but it's still quite versatile. It includes a speedometer (obviously), but also an altimeter (that shows your height while in a plane/helicopter) and an odometer. I always liked to see an analog odometer in MTA that resembles the ones in real cars (with turning digits), so I made one using dx-functions. It's quite hacky (with dxDrawText and boundingbox/cutting off overlapping text), but it seems to work. Since the scale of the speedometer (0, 20, 40, ..) is not a static picture but instead drawn by dx-functions as well, it can be changed easily. Every vehicle can have it's own scale based on it's approximate maximum speed. And of course there's an extensive GUI that let's each player customize the appearance of the speedometer and save the changes in a local file. Pictures and of course download are in resource center, if you are interested: https://community.multitheftauto.com/index.php?p= ... ils&id=559 Greetings
×
×
  • Create New...