Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by johny46

  1. I wouldn't say he absolutely has to remove these, but indeed, these are a bit pointless.
  2. Have a look at lines 18. and 19. And then 34. and 35. too.
  3. Can you recommend any alternative? Where do you think such data should be stored?
  4. Both of the loops you mentioned in your post are used to iterate through all (not necessarily) elements of a table. Let's say you've got a table like this: myTable = {5, 4, 3, 2, 1} If you wanted to execute some specific code on each element of the table, you would have to iterate through it. It can be done in a lot of ways, but let's first take the one easiest to understand: for index = 1, #myTable, 1 do outputChatBox(myTable[index]) end What this code is, is basically a regular "for" loop, where the number of repetitions is determined by the length of the table. In this case, #myTable returns 5, so the code inside is executed 5 times, then it continues on something else. With each loop, the index variable gets increased by one, so you can then do myTable[index] in order to work with the values of the table. So with each loop you can output one value of the table, or do any other stuff with it. Now onto something slightly different, a for loop with an iterator: for index, value in ipairs(myTable) do outputChatBox(value) end This code should output exactly the same data as the earlier loop, but it uses different construct. What this loop does, is automatically going through the entire table and with each repetition, it updates the index and value variables with current ones. The value variable is going to be the same as myTable[index], but it is just more convenient because you don't have to read these values manually. For further reading and some more examples I recommend you to go to http://www.phailed.me/2011/02/learn-lua ... ay-tables/ It explains the whole thing really great. If you think you've understand everything I was talking about, then it will be really easy for you to spot the obvious misconceptions and errors in your code, so you will be able to fix it yourself.
  5. Could you elaborate on that?
  6. This function is client side only.
  7. Nie jest to najwydajniejsze rozwiązanie, bo za każdym razem musisz iterować po całej tablicy. Zamiast tego, mógłbyś zmienić sposób zapisywania elementów w tablicy: tablica[id] = true -- id zajęte tablica[id] = nil -- id wolne następnie aby sprawdzić, czy dane id jest zajęte, po prostu sprawdzasz taki warunek: if tablica[id] then -- id zajęte else -- id wolne end
  8. CEGUI is much easier to use, and the resulting code is probably going to be cleaner, but keep in mind it could look differently on each player's screen due to theming. Dx gui can be annoying and hard to write, but then you can be sure it will look exactly the same on all clients and it also means you have the full control over how windows look and behave, which isn't very true for CEGUI.
  9. Thank you for replies, guys. Appreciate it. It is a free VPS, so it's quite low power. No mistake here, it's only 128 MB RAM. I wanted to create a simple multi gamemode server with maybe 3 or 4 not so heavy gamemodes. Basically some mini games, as for example the haystack gamemode (I won't be using this one particularly, just an example). In my first post I made a typo, but I actually meant I will be hosting no MySQL or any other database. All I plan to have there is MTA server binaries and Nginx serving static files. Currently with only nginx running, the memory usage stays at 4 MB for the whole system, so there's like 124 MB left for the server, or even more including SWAP. I don't expect to even have as much as 20 - 30 players. I'd probably keep the player slots to 16 or maybe 20 when I see there's more traffic. With these specifications, and assuming the scripts are written properly without memleaks, do you think it could do the job?
  10. Hi. I've got a VPS with such parameters: Download250 MbpsUpload10 MbpsRAM128 MBSWAP256 MBCPUi7-2600 @ 848 MHzVirtualizationOpenVZDistributionDebian 7.0 with some modifications as a lighter SSH server and such Would it be possible to estimate how much players could such a server handle without too much lag? I'm already running nginx with gzip compression enabled, the MTA server is configured to save bandwidth and the sync intervals are a bit higher (that is longer) than default. I'll be running to MySQL database. If I'll need any database functionality, I'm going to use the MTA built in one. My scripts will be mainly clientside to not use the server CPU time too much. With all that, would it be possible to have let's say 16 players at the same time playing together? If not, can you tell me what would be the biggest bottleneck in such configuration? I'm worried the upload speed could be a bit too low. What do you think?
  11. I don't think the code you found allows you to have 3D voice. I think it's more about either letting you hear people or not, based on the distance between them and other players.
  12. johny46

    [HELP] Spawn

    addEventHandler("onPlayerLogin",root, function() local accName = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup("user."..accName, aclGetGroup("V.I.P")) then spawnPlayer(source,3227,-690,108) end end ) Try this. If it still doesn't work, please provide the debugscript output.
  13. Have a look at this: http://lua-users.org/wiki/TernaryOperator
  14. You could use Windows Grep's "replace" function. See http://www.wingrep.com/ for more details.
  15. johny46


    You're going to use these functions: getPlayerMoney() takePlayerMoney() setRadarAreaColor()
  16. johny46


    There's no function like that, but you could use setCameraMatrix instead.
  17. Try typing this in your server console: aclrequest allow <name of the gui editor resource> all
  18. To hide the HUD: removeEventHandler("onClientRender",getRootElement(),hudComponents) To show the HUD: addEventHandler("onClientRender",getRootElement(),hudComponents) Of course it's not the best solution at all, but it should do the trick.
  19. Element data is lost whenever the element is destroyed. In your case, the element is a player who is just about to leave your server. So his data is lost. You will have to find another way of storing your data. You can for example use setAccountData, or create an xml file where you'd store their serials next to their settings.
  20. johny46

    Car locking

    Why do you think it wouldn't work? Try it
  21. johny46


    Dealman, apparently you didn't check the code thoroughly. Notice how the same file is used for multiple levels. Eg. the "rank_24.png" file is used for the 26th, 27th, 28th, 29th and the 30th level, not only the 24th level.
  22. johny46


    Instead of all these if and elseif, similar to what bandi94 suggested.
  23. Nobody can help you without knowing what custom HUD do you use, or how does it work if you wrote it yourself. I guess it uses the dx function, and thus it can be easily hidden by either removing the event handler for the time the player logs in, or creating a variable that would be checked before the drawing functions, and if it doesn't match, then don't draw the HUD.
  24. You don't have to use the map editor at all. Just add the cars in your map file using any text editor. That makes the mapmanager resource responsible of creating all the vehicles and stuff, so you can concentrate on the script itself. It makes things just so much easier than using createVehicle() all the time.
  25. It would be better to create vehciles in your map file. From there you can easily set their data to certain values. Let's say the data name for vehicles is "owner", you can then set it to one of the values possible for "job" data name. Let's say you have a "Pizzaboy" job, and you've set it to a player. Now you have to create a vehicle with the "owner" data being "Pizzaboy" too, so they can use the vehicle. The script to allow/disallow certain players to use a vehicle is fairly simple. Things you're going to need: The "onVehicleStartEnter" - so you know when a player tries to enter a vehicle, The getElementData() function - so you can compare the player's "job" with the vehicle's "owner" The cancelEvent() function - so you can disallow the player to use a vehicle if the data don't match.
  • Create New...