Jump to content

AleksCore

Members
  • Posts

    103
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by AleksCore

  1. Thanks for the reply, but I'll try to use multi statements and see how it works. Need to enable it in dbConnect and use dbPrepareString
  2. I've been searching for a MySQL tips and noticed there is no such topics on this forum. So let's fix this little problem. I want to know more about optimising MySQL queries and how to interract with MySQL correctly, I am newbie in that. I learned that putting queries in the loop it's too performance-expensive, wrong, and very big chance it'll freeze your server for uncertain time. So if I want to get information from DB for a many players, better to make it using only 1 query. Example: "SELECT * FROM race_stats WHERE playerID IN(??)" Where "??" = table with logged in players. But, what if I want to update information for a many players at the same time? How such query should look like? For 1 player it looks like this: "UPDATE race_stats SET id1 = id1 + ?, id2 = id2 + ?, id3 = id3 + ?, id4 = id4 + ?, id5 = id5 + ? WHERE playerID = ?" But how to make the same for all players? Put query in the loop will be too performance-expensive I guess and will create laggs. P.S. Maybe for such thing as player stats better to learn MySQL procuderes and create procedure for this, I am newbie, just asking. Don't even know what is procedures exactly, just heard about it.
  3. function getSortedTable( tableToSort ) --this function will sort our unsorted table and return sorted table local sortedTable = {} for player, money in ipairs(tableToSort) do local playerName = getPlayerName(player) table.insert( sortedTable,{ ['name'] = playerName, ['value'] = money } ) end table.sort(sortedTable, function(a, b) return a.value > b.value end ) return sortedTable end function show10RichestPlayers() local sortedPlayers = getSortedTable(notSortedTable) --notSortedTable is our table with player element as a key and money number as value for i=1, 10 do outputChatBox(sortedPlayers[i].name.." - $"..sortedPlayers[i].value, root, 0, 255, 0) end end addCommandHandler('show10', show10RichestPlayers) This is how I did it. Here could be mistakes, I didn't tested this code. Maybe for somebody this info will be useful
  4. That's not exactly what I asked for. I want the key as a player and value as money amount Anyways thanks, seems like I'll get how to do it myself.
  5. Not a big deal however some users may have problems with it. click
  6. Oh yeah, He use shader to change paintjob. Guess he need to replace "vehiclegrunge256" texture name using engineApplyShaderToWorldTexture Something like this I guess (for elegy) engineApplyShaderToWorldTexture(shader, "vehiclegrunge256", 562) He is finally registered @Stroth
  7. How to sort a table where key is a player(userdata) and value is money(number). How to sort by value? Thanks!
  8. @darkdreamingdan I got this: Sorry, there is a problem You are not permitted to register a user account with this site. Error code: 2S129/1 @darkdreamingdan I think we are both banned on the every forum with IPB engine. Just a guess, can't be sure of course. Update: friend said he registered. And I have an account so I won't try Thank you! Oh wait, he said he used mobile internet.
  9. Hi, community! A friend of mine can't register on the forum, he asked me to post following:
  10. Please check registration. It's broken. Friend said he can't register. I tryed and I also can't
  11. Yes, I know. Thanks anyways! Mystery was in my mistake. Event was triggering 'onClientColShapeHit' and I totally forgot to make sure hitElement == localPlayer.
  12. Got problems in my script when changed second argument for "triggerServerEvent" to "resourceRoot" and removed "if source == client then " check. So I use the same way as in @DNL291's example. Mystery. Server receive different userdata, but it should be the same, because the same player element passed. P.S. outputChatBox( tostring(client) )
  13. I don't clearly understand why need this check: if source == client then But this small check helped me to fix my trouble. Thanks!
  14. VMWare works for me on Win10x64. It requires good PC but it works and installation is fast and easy.
  15. Привет ребята. Можно ли как-то оптимизировать МТА для старых и не очень старых компов? Вопрос скорее к девелоперам МТА и приближенным людям. Ведь можно же выгружать лишние объекты из памяти или просто относительно далёкие объекты, что в теории может поднять фпс. Наверняка так оно и работает, но хотелось бы более "жесткой" оптимизации. Может какие-то оптимизации можно сделать с помощью MTA API? Даже на не очень старых компах фпс на каком-нибудь Race с 32 игроками на старте не очень радует своей стабильностью. У кого какие мысли есть по этому поводу?
  16. Thanks man! The solution was so easy You helped very much, thanks!
  17. Sounds great. But who(what element) must be parent in this case? If it should be map root, then how can I get it?
  18. I need to getCreatedElements at first somehow
  19. I creating objects this way: addEventHandler("onClientResourceStart", resourceRoot, function() local objects = getElementsByType("object") for k, object in ipairs(objects) do if getElementModel(object) == 3851 then setObjectBreakable(object, false) local x, y, z = getElementPosition(object) local rx, ry, rz = getElementRotation(object) newObj = createObject(18000, x, y, z, rx, ry, rz) setElementAlpha(newObj, 0) end end end ) But how can I destroy all this objects when resource stop?
  20. Well seems like this is the only solution
  21. setObjectBreakable is bad, I stuck in object. onClientObjectBreak a bit better but still stuck
  22. I can show why setObjectBreakable function working bad for me on the video, but later
  23. Idk why it happens, maybe because object is too thin. In this case I must try to make a bit thicker collision and check it again. But I don't think that problem in this
  24. https://community.multitheftauto.com/ind ... s&id=11609 In this resource arrow-object is glass. But glass is breakable object. And I want unbreakable arrows. It is glass because when I use other objects, I can't make them transparent using shader that good as it works with glass. When I use lua function to make it unbreakable it works bad, because I can stuck in this arrows and car collides badly with them. So I have one solution in mind - attach normal dff to this arrows with alpha 0. But maybe someone knows better solution?
×
×
  • Create New...